Page MenuHomePhabricator

MWScript.php doesn't allow wikiless scripts without the .php suffix
Open, LowPublic

Description

purgeList and a handful of other maintenance scripts are supposed to work without a wiki argument; this was certainly supported a few months ago (T368966#9947478) and is also documented on Wikitech (permalink). However, it doesn’t currently work:

lucaswerkmeister-wmde@deploy2002 ~ $ printf 'https://en.wikipedia.org/static/images/%s\n' 'mobile/copyright/wikimaniawiki-wordmark.svg' 'project-logos/wikimaniawiki-1.5x.png' 'project-logos/wikimaniawiki-2x.png' 'project-logos/wikimaniawiki.png' 'icons/wikimaniawiki.svg' | mwscript-k8s --attach -- purgeList 
⏳ Starting purgeList on Kubernetes as job mw-script.codfw.0vww27bg ...
⏳ Waiting for the container to start...
🚀 Job is running.
📜 Attached to stdin/stdout:
error: unable to upgrade connection: container mediawiki-0vww27bg-app not found in pod mw-script.codfw.0vww27bg-7jzmf_mw-script
☠️  Command failed with status 1: /usr/bin/kubectl attach --quiet job/mw-script.codfw.0vww27bg --container mediawiki-0vww27bg-app -i
For logs (may not work) run:
K8S_CLUSTER=codfw KUBECONFIG=/etc/kubernetes/mw-script-deploy-codfw.config kubectl logs -f job/mw-script.codfw.0vww27bg mediawiki-0vww27bg-app
lucaswerkmeister-wmde@deploy2002 ~ $ K8S_CLUSTER=codfw KUBECONFIG=/etc/kubernetes/mw-script-deploy-codfw.config kubectl logs -f job/mw-script.codfw.0vww27bg mediawiki-0vww27bg-app
Usage: mwscript scriptName.php --wiki=dbname
lucaswerkmeister-wmde@deploy2002 ~ $ printf 'https://en.wikipedia.org/static/images/%s\n' 'mobile/copyright/wikimaniawiki-wordmark.svg' 'project-logos/wikimaniawiki-1.5x.png' 'project-logos/wikimaniawiki-2x.png' 'project-logos/wikimaniawiki.png' 'icons/wikimaniawiki.svg' | mwscript-k8s --attach -- purgeList enwiki
⏳ Starting purgeList on Kubernetes as job mw-script.codfw.gfsw4n1u ...
⏳ Waiting for the container to start...
🚀 Job is running.
📜 Attached to stdin/stdout:
Purging 5 urls
Done!

For purgeList, this is merely an inconvenience, but it might be a bigger problem for addWiki where the target wiki doesn’t exist yet.

Event Timeline

(For all I know, this might not actually be an issue in mwscript-k8s – perhaps it’s somewhere in MWScript.php or elsewhere in the multiversion machinery? No idea.)

If this changed in mwscript-k8s, it's unintended (but definitely not impossible) -- I'll dig into it today and get back to you.

This is MWScript.php behavior, and it's actually unchanged:

rzl@deploy2002:~$ echo 'https://wikitech.wikimedia.org/wiki/User:RLazarus_(WMF)' | mwscript-k8s --attach -- purgeList
⏳ Starting purgeList on Kubernetes as job mw-script.codfw.1jed96zi ...
⏳ Waiting for the container to start...
🚀 Job is running.
📜 Attached to stdin/stdout:
error: unable to upgrade connection: container mediawiki-1jed96zi-app not found in pod mw-script.codfw.1jed96zi-96z2h_mw-script
☠️ Command failed with status 1: /usr/bin/kubectl attach --quiet job/mw-script.codfw.1jed96zi --container mediawiki-1jed96zi-app -i
For logs (may not work) run:
K8S_CLUSTER=codfw KUBECONFIG=/etc/kubernetes/mw-script-deploy-codfw.config kubectl logs -f job/mw-script.codfw.1jed96zi mediawiki-1jed96zi-app

rzl@deploy2002:~$ echo 'https://wikitech.wikimedia.org/wiki/User:RLazarus_(WMF)' | mwscript-k8s --attach -- purgeList.php
⏳ Starting purgeList.php on Kubernetes as job mw-script.codfw.fa9ho6jy ...
⏳ Waiting for the container to start...
🚀 Job is running.
📜 Attached to stdin/stdout:
Purging 1 urls
Done!

The difference is that 'maintenance/purgeList' isn't in $wikilessScripts in MWScript.php, but 'maintenance/purgeList.php' is. The "maintenance/" prefix is added before that check, but I guess the ".php" suffix is added after.

This is a legit bug, but it's a bug against MWScript.php. In the meantime, the workaround is to continue including ".php" when not mentioning a wiki.

In the meantime, the workaround is to continue including ".php" when not mentioning a wiki.

Hm, I could swear I tried that earlier today and still got the error o_O but now it seems to work 🤷

The "maintenance/" prefix is added before that check

I’m tempted to say MWScript should actually stop doing this – AFAIK it’s no longer necessary for run.php maintenance scripts, and it’s run.php which potentially adds the .php too. (I guess adding maintenance/ might still be needed for the $oldScripts, which don’t use run.php.) Having two different places “fix up” the listed maintenance script seems like it could lead to more confusion down the road. (Instead, $wikilessScripts could just list purgeList, purgeList.php and maintenance/purgeList.php explicitly, and likewise for purgeMessageBlobStore, mctest and mcc.)

RLazarus renamed this task from mwscript-k8s no longer supports wikiless scripts to MWScript.php doesn't allow wikiless scripts without the .php suffix.Oct 10 2024, 8:04 PM