Skip to content
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

Merged
merged 2 commits into from
Oct 13, 2017
Merged

Discourage libevent on PHP 7 #62

merged 2 commits into from
Oct 13, 2017

Conversation

cboden
Copy link
Member

@cboden cboden commented Nov 17, 2016

The libevent extension has not been updated for PHP 7 and I have seen reports of segfaults as a result.

@clue
Copy link
Member

clue commented Nov 17, 2016

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 Factory, as this still leaves users the choice 👍

@cboden
Copy link
Member Author

cboden commented Nov 21, 2016

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.

@smalot
Copy link

smalot commented Dec 7, 2016

Any other feedback ? I'm looking for using PHP 7, so I'm too interested about this issue

@clue
Copy link
Member

clue commented Jan 10, 2017

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.

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):

The libevent extension does not currently support PHP7. There's ongoing effort to update libevent to support PHP7 in php/pecl-event-libevent#2. However, the current version occasionally segfaults. This could not be observed in earlier version, so it is believed that this is a bug in libevent, rather than React.
As such, there's little we can do here. Discussion about this is probably best directed at #40.

And in the same vein then actively encourage users to check out recommended extensions for PHP 7 like so:

In the meantime, you may want to check out the "event" extension. We've seen reports of people successfully using this on PHP7.

@cboden
Copy link
Member Author

cboden commented Jan 10, 2017

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();
Copy link
Member

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 👍

@@ -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);
}
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Member

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! 👍

@cboden cboden added this to the v0.5.0 milestone Oct 11, 2017
@cboden
Copy link
Member Author

cboden commented Oct 11, 2017

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', '<')) {
Copy link
Member

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 :shipit:

Copy link
Member

@clue clue left a 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! :shipit:

Copy link
Member

@WyriHaximus WyriHaximus left a comment

Choose a reason for hiding this comment

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

LGTM :shipit:

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.

5 participants