Hi MusikAnimal!

I looked into this issue. Running FixGlobalBlockWhitelist by class name doesn't work for two reasons:

1) FixGlobalBlockWhitelist isn't namespaced. fixGlobalBlockWhitelist.php doesn't contain a namespace declaration. If you try it with PopulateCentralId, it works.

2) The file name doesn't match the class name ("fix" vs "Fix"). So even if the namespace declaration is added, the autoloader won't find the file to load.

Pro tip: there is a shorthand notation for running maintenance scripts in extensions, if the conventions for path and namespace are followed:

* GlobalBlocking:fixGlobalBlockWhitelist will work (it will find the file in the maintenance directory)

* GlobalBlocking:FixGlobalBlockWhitelist would work once the namespace and file name is fixed

If you want an auto-loadable file and a nice script name, make a file with a nice name as a stub. E.g. maintance/fixWhitelist.php, which contains nothing but this:

  require_once __DIR__ . '/FixGlobalBlockWhitelist .php';

The you can run the script using GlobalBlocking:fixWhitelist as well.

HTH,
Daniel

Am 03.03.2023 um 01:49 schrieb MusikAnimal:
Ah... we need relative paths!

   maintenance run ./extensions/MyExt/maintenance/someScript.php

That works great, but the class variants still don't work for me. Examples:

 > maintenance/run MediaWiki.Extension.GlobalBlocking.FixGlobalBlockWhitelist
Script 'MediaWiki.Extension.GlobalBlocking.FixGlobalBlockWhitelist' not found (tried path '/var/www/html/w/maintenance/MediaWiki.Extension.GlobalBlocking.FixGlobalBlockWhitelist.php' and class 'MediaWiki\Extension\GlobalBlocking\FixGlobalBlockWhitelist').

> maintenance/run GlobalBlocking:FixGlobalBlockWhitelist
Script 'GlobalBlocking:FixGlobalBlockWhitelist' not found (tried path '/var/www/html/w/extensions/GlobalBlocking/maintenance/FixGlobalBlockWhitelist.php' and class 'MediaWiki\Extension\GlobalBlocking\Maintenance\FixGlobalBlockWhitelist').

~ MA


On Thu, Mar 2, 2023 at 7:26 PM MusikAnimal <musikanimal@gmail.com> wrote:
Thanks! This works great for Core maintenance scripts, but it's not working for extensions on my end. I'm probably doing something stupid:

   maintenance/run extensions/MyExt/maintenance/someScript.php
   php maintenance/run.php extensions/MyExt/maintenance/someScript.php
   ...(and the other variants using the class name)

for all, I get the error:

  Script 'extensions/MyExt/maintenance/someScript.php' not found (tried path '/var/www/html/w/maintenance/extensions/MyExt/maintenance/someScript.php' and class 'extensions/MyExt/maintenance/someScript\php').

I tried several extensions. I of course am pointing to actual scripts and not the example MyExt::SomeScript :) MW and the extensions I tried on my machine are up-to-date with master. Any ideas? This error is what led me to believe that perhaps the scripts weren't built to support the new maintenance runner, but from what you're saying it sounds like no changes should be needed.

As far as docs go, is it too soon to start adding MW >=1.40 info at Manual:Writing maintenance scripts and Manual:Maintenance scripts/Running the scripts, etc.?

~ MA

On Wed, Mar 1, 2023 at 3:40 AM Antoine Musso <hashar@free.fr> wrote:
Le 28/02/2023 à 21:42, MusikAnimal a écrit :
Hello! Where might I find documentation on the new maintenance runner system? I can't find any examples in the Phabricator task or the linked RFC, and searching for "MaintenanceRunner" or "run.php" yields no results on mediawiki.org. Specifically, I was expecting Manual:run.php to exist with some info on how it works.

If given a good example patch, I'm happy to help write the docs :)

Hello,

run.php is more or less a wrapper so that instead of invoking:

 php maintenance/parse.php

One should use:

 maintenance/run parse

That will be released in MediaWiki 1.40 and all maintenance scripts will emit a warning to the console when invoked directly.

Here are some references to assist in writing the documentation:

And as an extra, I have implemented a back compat layer in Quibble (which is written in Python): https://gerrit.wikimedia.org/r/c/integration/quibble/+/875981/6/quibble/mediawiki/maintenance.py


Antoine "hashar" Musso
Wikimedia Release Engineering

_______________________________________________
Wikitech-l mailing list -- wikitech-l@lists.wikimedia.org
To unsubscribe send an email to wikitech-l-leave@lists.wikimedia.org
https://lists.wikimedia.org/postorius/lists/wikitech-l.lists.wikimedia.org/
-- 
Daniel Kinzler
Principal Software Engineer, Platform Engineering
Wikimedia Foundation