Anomie added a comment.

The tricky bit is to figure out how to best run a script against a "non-standard" db.

That turned out to be not too bad after all. Create a local file with content like:

LS.php
<?php

require $IP . '/LocalSettings.php';

// Change DB login info
$wgDBuser = 'test_wikiuser';
$wgDBpassword = file_get_contents( __DIR__ . '/pw' );
$wgDBadminuser = 'test_wikiadmin';
$wgDBadminpassword = file_get_contents( __DIR__ . '/pw2' );
$wgLBFactoryConf['serverTemplate']['user'] = $wgDBuser;
$wgLBFactoryConf['serverTemplate']['password'] = $wgDBpassword;

// Point all the things to the test DBs
$wgLBFactoryConf['sectionsByDB'] = [];
$wgLBFactoryConf['sectionLoads'] = [
	'DEFAULT' => [
		'db1111' => 0,
		'db1112' => 100,
	],
];
$wgLBFactoryConf['hostsByName'] = [
	'db1111' => 'db1111',
	'db1112' => 'db1112',
];

// Probably better to just break CentralAuth, ExternalStore, and so on.
$wgLBFactoryConf['externalLoads'] = [];

Then also create files 'pw' and 'pw2' containing the passwords. The slightly tricky part is that they have to be readable by www-data rather than your user, so the easiest way I could think of to make it happen turned out to be using mwrepl:

$ chmod o+w .; mwrepl enwiki; chmod o-w .
hphpd> umask( 0027 ); 
umask( 0027 );
hphpd> file_put_contents( "/home/.../pw", "..." );
file_put_contents( "/home/.../pw", "..." );
hphpd> file_put_contents( "/home/.../pw2", "..." );
file_put_contents( "/home/.../pw2", "..." );

After that, anything run via mwscript can use --conf=`pwd`/LS.php and it should be pointing to the testing DBs instead of the real ones.


TASK DETAIL
https://phabricator.wikimedia.org/T196172

EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Anomie
Cc: Aklapper, aude, Addshore, Anomie, Jdforrester-WMF, gerritbot, Abit, daniel, Lahi, PDrouin-WMF, Gq86, E1presidente, Ramsey-WMF, Cparle, SandraF_WMF, GoranSMilovanovic, QZanden, Tramullas, Acer, LawExplorer, JJMC89, Agabi10, Susannaanas, Aschroet, Jane023, Wikidata-bugs, PKM, Base, matthiasmullie, Ricordisamoa, Lydia_Pintscher, Fabrice_Florin, Raymond, Steinsplitter, Mbch331
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to