Page MenuHomePhabricator

--wiki works only for wizards and Wikipedia
Open, LowestPublicFeature

Description

Author: svippy

Description:
It seems the --wiki switch on maintenance scripts, which is supposed to be intended for wiki farms with the use of $wgConf->wikis to update individual wikis doesn't work at all.

After several tests of this with my own farm, I have reached the conclusion that whatever you try, the maintenance will always default to your default wiki for some reason. And it is hardly obvious how it even gets to that, even when forcing it through several localsettings modified specifically to only include *one* $wgDBname.

I realise that it was originally written for Wikipedia, but apparently, I guess, Wikipedia got all the cheat codes and holds all the cards, because it surely works in their end and not here. Even when looking closely at their InitialiseSettings.php script and copying their format, no results.


Version: unspecified
Severity: enhancement

Details

Reference
bz23348

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 11:03 PM
bzimport set Reference to bz23348.
bzimport added a subscriber: Unknown Object (MLST).

As I said on IRC, the value is stored in MW_DB and MW_PREFIX constants; settings are not automatically extracted from $wgConf. Also Wikimedia case is handled differently; just copying InitialiseSettings.php will not work as expected.

REOPENING. The actual listed issue: "--wiki does not work" does indeed not work, regardless of your setup. It's only checked when it 'wikimedia-mode,' when in fact it should be checked regardless so third parties can use it too.

The issue was that the --wiki option originally only existed for WMF wikis and was never advertised as a possible option. When I did the maintenance rewrite, it exposed the option to all users via --help, without the actual code in place to make it work for non-WMF sites.

It is used (see lines 726 to 733 of Maintenance.php) and it just works fine, but you need to handle it manually in LocalSettings.php, as Tim said we he introduced the feature in r35839.

svippy wrote:

(In reply to comment #3)

It is used (see lines 726 to 733 of Maintenance.php) and it just works fine,
but you need to handle it manually in LocalSettings.php, as Tim said we he
introduced the feature in r35839.

Then riddle me this. If I have a wiki farm, and one of these wikis (say the pool wiki) has the table 'info_pool' and the prefix ''. What should I grant to the --wiki switch?

All I hear is that 'it works', but I'd prefer it if there was actually, I dunno, some usage cases of it, because it seems not to work in my end:

$ php maintenance/update.php --wiki=info_pool-
MediaWiki 1.17alpha Updater

Going to run database updates for info_en
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds (skip this countdown with --quick) ... 3

$ php maintenance/update.php --wiki=info_pool
MediaWiki 1.17alpha Updater

Going to run database updates for info_en
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds (skip this countdown with --quick) ... 4

Eh?

Why does it default to info_en each time? I don't get it!

In LocalSettings.php copy MW_DB to $wgDBName and MW_PREFIX to $wgDBPrefix (only if MW_DB is defined, of course) and extract the other settings based on these two ones. As I already said two times, this is *not* done automatically.

Which is not intuitive at all, nor is it documented anywhere.

This is part of the MediaWiki multiversion system deployed on the Wikimedia cluster. It contains a lot of useless code for third parties, but the main part that you will need in your own wikifarm:

if ( $wgCommandLineMode ) {
if ( isset( $argv[1] ) && $argv[1] === '--wiki' ) {

		$dbname = isset( $argv[2] ) ? $argv[2] : ''; // "script.php --wiki dbname"

} elseif ( isset( $argv[1] ) && substr( $argv[1], 0, 7 ) === '--wiki=' ) {

		$dbname = substr( $argv[1], 7 ); // "script.php --wiki=dbname"

} elseif ( isset( $argv[1] ) && substr( $argv[1], 0, 2 ) !== '--' ) {

		$dbname = $argv[1]; // "script.php dbname"

}
}
$wgDBname = $dbname; // Set it to the DB given

There is also another hack to find what domain the user is coming from, but it is not needed here. (Note: I added the first and last line myself)

The funny thing is that all maintenance scripts makes --wiki as a possible parameter, even though the above code might not yet have been set. That requirement should be removed totally, but that deserves another bug to be filed and is not part of this.

Somebody should put this on MediaWiki.org.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:02 AM
Aklapper removed a subscriber: wikibugs-l-list.