Page MenuHomePhabricator

updateCollation.php throws an error
Closed, ResolvedPublicBUG REPORT

Description

The updateCollation.php maintenance script fails to load, showing a PHP error even before displaying help. The error occurs in the constructor.
This was tested under current master branch and REL1_34.

Steps to Reproduce:
Run the updateCollation.php maintenance script with any arguments (no arguments will suffice).

Actual Results:
The following result may differ a bit depending on how exactly you run the script. The following was produced on a Vagrant dev installation, the script was ran using mwscript.

PHP Fatal error:  Uncaught Error: Class 'MediaWiki\MediaWikiServices' not found in /vagrant/mediawiki/maintenance/Maintenance.php:621
Stack trace:
#0 /vagrant/mediawiki/maintenance/updateCollation.php(47): Maintenance->getConfig()
#1 /vagrant/mediawiki/maintenance/doMaintenance.php(48): UpdateCollation->__construct()
#2 /vagrant/mediawiki/maintenance/updateCollation.php(336): require_once('/vagrant/mediaw...')
#3 /var/www/w/MWScript.php(99): require_once('/vagrant/mediaw...')
#4 {main}
  thrown in /vagrant/mediawiki/maintenance/Maintenance.php on line 621

Expected Results:
Anything but an error :)

Cause:
This script uses the MediaWikiServices class in its constructor before the class is initialized, which causes everything to collapse. To be more precise: the script tries to retrieve the current config setting for
category collation to use it in the help text.

I don't think there is a sensible way around this and it's probably not worth the effort, retrieving the config setting in the constructor is not critical for the execution of the script, so I'd opt for removing it entirely.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 25 2020, 5:04 PM

Change 574805 had a related patch set uploaded (by Ostrzyciel; owner: Ostrzyciel):
[mediawiki/core@master] updateCollation.php: fix PHP error

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

Reedy added a subscriber: Reedy.Feb 25 2020, 5:22 PM

Did you mean REL1_33? I looked and it seems like 8f666cabcdcda75fa9cfe2409444861cccb36877 only came in in REL1_34

Ostrzyciel updated the task description. (Show Details)Feb 25 2020, 5:27 PM

Did you mean REL1_33? I looked and it seems like 8f666cabcdcda75fa9cfe2409444861cccb36877 only came in in REL1_34

Oh, right, my bad, I meant REL1_34. Sorry!

Reedy added a comment.Feb 25 2020, 5:29 PM

That's fine :). Just wanted to make sure it wasn't also/differently broken in REL1_33 due to some other issue

Change 574807 had a related patch set uploaded (by Reedy; owner: Ostrzyciel):
[mediawiki/core@REL1_34] updateCollation.php: fix PHP error

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

Change 574807 merged by jenkins-bot:
[mediawiki/core@REL1_34] updateCollation.php: fix PHP error

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

Change 574805 merged by jenkins-bot:
[mediawiki/core@master] updateCollation.php: fix PHP error

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

Reedy closed this task as Resolved.Feb 25 2020, 5:50 PM
alex-mashin added a comment.EditedMar 14 2020, 10:01 AM

I applied the last patch manually, and the maintenance script started to work.

P.S. Although you need to add global $wgCategoryCollation; to the constructor.