Page MenuHomePhabricator

Detect when CirrusSearch is used without curl and fail gracefully
Closed, ResolvedPublic

Description

If you install Cirrus extension on PHP install without curl, it produces fatal error on curl_init:

Fatal error: Call to undefined function Elastica\Transport\curl_init() in /var/www/html/extensions/Elastica/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php on line 216

We probably need some mechanism to handle it more gracefully and produce more friendly error message.

Details

Related Gerrit Patches:
mediawiki/extensions/Elastica : masterFail gracefully if curl is not installed
mediawiki/extensions/Elastica : masterAdd cURL PHP extension to the list of composer requirements
mediawiki/extensions/CirrusSearch : masterAdd cURL PHP extension to the list of composer requirements
mediawiki/extensions/CirrusSearch : masterFail gracefully if curl is not installed

Event Timeline

Restricted Application added a project: Discovery. · View Herald TranscriptMay 26 2017, 12:42 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Smalyshev updated the task description. (Show Details)May 26 2017, 12:42 AM
debt triaged this task as Low priority.Jun 1 2017, 5:10 PM
debt moved this task from needs triage to later on... on the Discovery-Search board.
debt added a subscriber: debt.

We'll need to figure out where this could go (for the fix in MediaWiki), but should be easy enough.

Restricted Application added a subscriber: TerraCodes. · View Herald TranscriptJun 1 2017, 5:10 PM

What MediaWiki itself does, when a library is missing, it outputs a nice error message with the MediaWiki logo and a message what is missing and what the visitor (hopefully the system administrator) can do to fix that. It can be accessed by the PHPVersionCheck class with the triggerError() method. That could be a good option.

As this would be easy to do, I'll add this task to Google-Code-in-2017 and mentor it :)

nikitavbv added a subscriber: nikitavbv.

I will fix this!

@Phantom42 Great! If you've any questions or if you run into problems, feel free to ask :)

Change 398773 had a related patch set uploaded (by Phantom42; owner: Phantom42):
[mediawiki/extensions/CirrusSearch@master] Fail gracefully if curl is not installed

https://gerrit.wikimedia.org/r/398773

Well, I managed to create "testing environment" for this. Indeed, if curl is not installed then when visiting Special:Version you will get message like this:

I am not sure if PHPVersionCheck is the best choice here, but I managed to implement this and now when you visit Special:Version and error occurs you see this:

Are there any other pages where this message should be displayed?

I have just submitted a patch. Please tell if anything needs to be fixed / improved / changed / added.

By the way, during review on Gerrit @Reedy adviced to add ext-curl to composer.json. @Florian what do you think about that? That might prevent user from forgetting to install cURL too.

@Phantom42 That sounds good, too. That's a simple change, too, would you like to do that in your change in gerrit, too? :)

@Florian yes, of course, I will add it now. I am also wondering if we should add ext-curl to Elastica composer.json too. What do you think?

And one more thing: looks like after adding ext-curl to composer.json CI mwext-php70-phan-docker starts to fail because curl extension is not available there. Is there any way we could fix that? I am afraid I don't have enough rights to fix that problem.

Change 399241 had a related patch set uploaded (by Phantom42; owner: Phantom42):
[mediawiki/extensions/CirrusSearch@master] Add cURL PHP extension to the list of composer requirements

https://gerrit.wikimedia.org/r/399241

And that is another change, because we decided to modify composer.json in a separate one because of CI issues.

In T166355#3848240, @Phantom42 wrote:

And one more thing: looks like after adding ext-curl to composer.json CI mwext-php70-phan-docker starts to fail because curl extension is not available there. Is there any way we could fix that? I am afraid I don't have enough rights to fix that problem.

You've got as many rights as most other people. You can submit a gerrit changeset to the relevant repo... Now, as for which that repo is... Haha

You can just file a task in phabricator under Continuous-Integration-Infrastructure and say what you need, why you need it, and link back here. That's an acceptable resolution too :)

Change 398773 merged by jenkins-bot:
[mediawiki/extensions/CirrusSearch@master] Fail gracefully if curl is not installed

https://gerrit.wikimedia.org/r/398773

I'm a bit confused, the exception message points to the Elastica extension needing curl...shouldn't the exception message be in Elastica, not CirrusSearch?

Now that I think about that: You're right. Even if Elastica is currently only required by the CirrusSearch extension (I think), the requirement comes from Elastica, so it should life there. I'll propose changes to change the place, sorry :(

Change 399319 had a related patch set uploaded (by Florianschmidtwelzow; owner: Florianschmidtwelzow):
[mediawiki/extensions/Elastica@master] Fail gracefully if curl is not installed

https://gerrit.wikimedia.org/r/399319

Change 399241 abandoned by Phantom42:
Add cURL PHP extension to the list of composer requirements

https://gerrit.wikimedia.org/r/399241

Change 399339 had a related patch set uploaded (by Phantom42; owner: Phantom42):
[mediawiki/extensions/Elastica@master] Add cURL PHP extension to the list of composer requirements

https://gerrit.wikimedia.org/r/399339

Florian closed this task as Resolved.Dec 23 2017, 7:03 PM

Change 399339 merged by jenkins-bot:
[mediawiki/extensions/Elastica@master] Add cURL PHP extension to the list of composer requirements

https://gerrit.wikimedia.org/r/399339

Change 399319 merged by jenkins-bot:
[mediawiki/extensions/Elastica@master] Fail gracefully if curl is not installed

https://gerrit.wikimedia.org/r/399319