Skip to content

Conversation

@greg0ire
Copy link
Contributor

No description provided.

The new code should be used as soon as 2.8.0 is available
@greg0ire greg0ire changed the base branch from master to 2.7 September 19, 2016 14:48
code to use::

if (Kernel::VERSION_ID <= 20800) {
if (Kernel::VERSION_ID < 20800) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong to me. The code for Symfony 3.0 would now also be executed on Symfony 2.8 which might not be what you want to do (as all the deprecated code would not be available anymore).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing is sure : if it can be executed on 2.8.1, it should also be executed in 2.8.0, right? And looking at the condition as it is before my change, it can be executed for symfony 2.8.1, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh : not sure if you're saying that my change is wrong, or that the thing before is even wronger for other reasons, can you please clarify?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I did not think about 2.8.1. What do you think if we changed the condition to something like Kernel::VERSION_ID < 30000 then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the time, you do want to get the shift on 2.8.0, that's what we do on sonata :

if ($conditionAbout2.8) {
    // use  new way, that way we don't get the deprecation notice
} else {
   // use old way
}

See for instance : https://github.com/sonata-project/SonataAdminBundle/blob/48cc780dbcd026193e0e98fb2ad6a2a997e2ec22/Form/Type/AclMatrixType.php#L39

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please change this to 2 === Kernel::MAJOR_VERSION?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wouterj I don't think it is relevant, because this will be true for both 2.7 and 2.8, right? And the code change should generally apply when switching from 2.7 to 2.8, instead of between 2 and 3, otherwise you get deprecation notices for 2.8.

Copy link
Contributor Author

@greg0ire greg0ire Sep 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course there are situations when you can need both switches, like choices_as_values, but IMO the most frequent and encourages should be 2.7 to 2.8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabbuh @wouterj still think this "Needs Work" ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think you are right. When targetting Symfony 2.8 you will not want to use the deprecated code paths.

@xabbuh
Copy link
Member

xabbuh commented Sep 27, 2016

👍

Status: Reviewed

@javiereguiluz
Copy link
Member

👍

1 similar comment
@wouterj
Copy link
Member

wouterj commented Oct 1, 2016

👍

@xabbuh
Copy link
Member

xabbuh commented Oct 14, 2016

Thank you @greg0ire.

@xabbuh xabbuh merged commit 2c1986f into symfony:2.7 Oct 14, 2016
xabbuh added a commit that referenced this pull request Oct 14, 2016
This PR was merged into the 2.7 branch.

Discussion
----------

Use strict comparison

Commits
-------

2c1986f Use strict comparison
@greg0ire greg0ire deleted the use_strict_comparison branch October 14, 2016 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants