-
-
Notifications
You must be signed in to change notification settings - Fork 127
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
Discourage libevent on PHP 7 #62
Conversation
The docs (https://pecl.php.net/package/libevent) suggest libevent requires PHP < 6.0? How would one install libevent on PHP 7 in the first place? Note there's also a PR that aims to add compatibility with PHP 7: php/pecl-event-libevent#2 I'm undecided if it makes sense to explicitly discourage libevent. I'm perfectly fine with lowering its priority and/or removing it from the |
I've seen a couple issues where users were able to install the extension on PHP 7 even though it's not officially supported yet and were complaining about segfaults. This PR doesn't prevent people from using the extension as it only triggers a warning and the Factory will not select a loop that segfaults. |
Any other feedback ? I'm looking for using PHP 7, so I'm too interested about this issue |
IMHO we should make this clear that we are not aware of any issues in React and this is likely an issue with the unofficial libevent bindings like so #55 (comment):
And in the same vein then actively encourage users to check out recommended extensions for PHP 7 like so:
|
What's the benefit of keeping factory order unchanged? I see a negative in segfaults but I don't see a positive to keeping it as-is. |
src/Factory.php
Outdated
return new LibEvLoop; | ||
} elseif (class_exists('EventBase', false)) { | ||
return new ExtEventLoop; | ||
} elseif (function_exists('event_base_new') && version_compare(PHP_VERSION, '7.0.0', '<')) { | ||
return new LibEventLoop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes perfect sense to lower priority here and do not pick this extension on PHP 7+ at all 👍
src/LibEventLoop.php
Outdated
@@ -31,6 +31,10 @@ class LibEventLoop implements LoopInterface | |||
|
|||
public function __construct() | |||
{ | |||
if (version_compare(PHP_VERSION, '7.0.0') >= 0) { | |||
trigger_error('The libevent extension has not yet been updated for PHP 7, it is recommended you use a different loop', E_USER_WARNING); | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of this tbqh 👎
With the above check in place we do not automatically create the LibEventLoop
from our Factory
. Afaict this is what most people use, so this should resolve this for the most part?
This means that if this constructor is invoked, it's explicitly been called. IMHO this is already advanced usage and we should not trigger a warning in this case.
Otherwise, how could a user possibly ignore this warning? Using @
-suppression would result in zero output if the extension can not be loaded all.
Also, what happens when the extension will be updated to support PHP 7 again? We can't really detect this until we provide an update, in which case the above warning would be superfluous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user has upgraded to PHP7 and somehow kept the extension installed, from the reports I've received, it's going to segfault. The trigger_error only issues a warning, the object will still be instantiated an be able to be used.
Also, what happens when the extension will be updated to support PHP 7 again?
It looks like that extension isn't going to be...but if it does we'll have to quickly update this to support it. Even if this happens the compare only issues a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the consensus is still a 👎 on this I'm good to remove this check in order to get the updated Factory order into the next release.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we had a consensus here, it was basically just my point of view :-) But if this error is removed, I'm all for getting this in! 👍
Updated. some > none 😀 We can discuss the warning in IRC or another issue. |
src/Factory.php
Outdated
return new LibEvLoop; | ||
} elseif (class_exists('EventBase', false)) { | ||
return new ExtEventLoop; | ||
} elseif (function_exists('event_base_new') && version_compare(PHP_VERSION, '7.0.0', '<')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update this to use PHP_VERSION_ID
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update, I've rebased this to fix the failing unit tests and LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The libevent extension has not been updated for PHP 7 and I have seen reports of segfaults as a result.