8000 compare version using PHP_VERSION_ID by xabbuh · Pull Request #12497 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

compare version using PHP_VERSION_ID #12497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2014

Conversation

xabbuh
Copy link
Member
@xabbuh xabbuh commented Nov 17, 2014
Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

To let opcode caches optimize cached code, the PHP_VERSION_ID
constant is used to detect the current PHP version instead of calling
version_compare() with PHP_VERSION.

@xabbuh
Copy link
Member Author
xabbuh commented Nov 17, 2014

I modified the changes from #12372 as suggested by @stof.

However, there are much more calls to version_compare(). I think it does make sense to update them as well. What do you think?

@fabpot
Copy link
Member
fabpot commented Nov 17, 2014

@xabbuh Looks like a good idea to me.

@stof
Copy link
Member
stof commented Nov 17, 2014

Indeed, it is a good idea to change this everywhere

@xabbuh xabbuh force-pushed the php-version-id-constant-check branch from 9c322b9 to 6f6ddf3 Compare November 17, 2014 15:55
@xabbuh
Copy link
Member Author
xabbuh commented Nov 17, 2014

It's updated now. I hope I didn't mess anything up.

@xabbuh
Copy link
Member Author
xabbuh commented Nov 17, 2014

I was not sure how to replace something like this:

version_compare(PHP_VERSION, '5.5.0-dev', '>=')

Is PHP_VERSION_ID >= 50500 sufficient?

@stof
Copy link
Member
stof commented Nov 17, 2014

@xabbuh yes. Unreleased versions on 5.5.0 were already using the 50500 id (this id constant does not take pre-release versions into account)

@@ -30,7 +30,7 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c
*/
public function testRoutingErrorIsExposedWhenNotProtected($config)
{
if (strpos(PHP_OS, "WIN") === 0 && version_compare(phpversion(), "5.3.9", "<")) {
if (strpos(PHP_OS, "WIN") === 0 && PHP_VERSION_ID < 50309) {
Copy link
Member

Choose a reason for hiding this comment

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

strpos(PHP_OS, "WIN") === 0 should be changed to defined('PHP_WINDOWS_VERSION_BUILD') to be consistent with all other windows detection done in Symfony

Copy link
Member Author

Choose a reason for hiding this comment

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

make sense

To let opcode caches optimize cached code, the `PHP_VERSION_ID`
constant is used to detect the current PHP version instead of calling
`version_compare()` with `PHP_VERSION`.
@xabbuh xabbuh force-pushed the php-version-id-constant-check branch from 6f6ddf3 to 367ed3c Compare November 17, 2014 16:27
@xabbuh
Copy link
Member Author
xabbuh commented Nov 17, 2014

Should be good now.

@@ -49,7 +49,7 @@ public function testGenerateCsrfTokenOnUnstartedSession()
{
session_id('touti');

if (!version_compare(PHP_VERSION, '5.4', '>=')) {
if (PHP_VERSION_ID < 50400) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't mean >= ?

Copy link
Member

Choose a reason for hiding this comment

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

@pborreli no. there was a negation before the version_compare

@stof
Copy link
Member
stof commented Nov 17, 2014

👍

@pborreli
Copy link
Contributor

👍 thanks @xabbuh

@fabpot
Copy link
Member
fabpot commented Nov 17, 2014

Thank you @xabbuh.

@fabpot fabpot merged commit 367ed3c into symfony:2.3 Nov 17, 2014
fabpot added a commit that referenced this pull request Nov 17, 2014
This PR was merged into the 2.3 branch.

Discussion
----------

compare version using PHP_VERSION_ID

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

To let opcode caches optimize cached code, the `PHP_VERSION_ID`
constant is used to detect the current PHP version instead of calling
`version_compare()` with `PHP_VERSION`.

Commits
-------

367ed3c compare version using PHP_VERSION_ID
@xabbuh xabbuh deleted the php-version-id-constant-check branch November 17, 2014 20:55
xabbuh added a commit to xabbuh/symfony that referenced this pull request Nov 23, 2014
This continues the work started in symfony#12497 on the `2.3` branch.
@staabm
Copy link
Contributor
staabm commented Nov 25, 2014

To let opcode caches optimize cached code, the PHP_VERSION_ID

@xabbuh do you have any background/docs on this?

@GromNaN
Copy link
Member
GromNaN commented Nov 25, 2014

The first advantage is that this removes a function call:

And depending on the configuration of opcache.optimization_level, the new code can be optimized.

fabpot added a commit that referenced this pull request Nov 28, 2014
This PR was merged into the 2.5 branch.

Discussion
----------

compare version using PHP_VERSION_ID

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This continues the work started in #12497 on the `2.3` branch.

Commits
-------

d2f846b compare version using PHP_VERSION_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0