User:Tobias Andersson (WMDE)/clientRepoSetup

From Meta, a Wikimedia project coordination wiki
LocalSettings.php[edit]
<?php

if(isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == 'enwiki.web.mw.localhost') {
	require_once __DIR__ . '/extensions/LocalSettings.enwiki.php';
} else if(isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == 'fedpropwiki.web.mw.localhost') {
	require_once __DIR__ . '/extensions/LocalSettings.fedpropwiki.php';
} else {
	require_once __DIR__ . '/extensions/LocalSettings.default.php';
}


Repo LocalSettings.default.php[edit]
require_once __DIR__ . '/../.docker/LocalSettings.php';

$wgEnableWikibaseRepo = true;
require_once "$IP/extensions/Wikibase/repo/Wikibase.php";
require_once "$IP/extensions/Wikibase/repo/ExampleSettings.php";
$wgWBRepoSettings['siteLinkGroups'] = [ 'mywikigroup' ];
$wgLocalDatabases = $wgWBRepoSettings['localClientDatabases'] = [ 'enwiki', ];
Repo LocalSettings.enwiki.php[edit]
require_once __DIR__ . '/../.docker/LocalSettings.php';

$wgEnableWikibaseRepo = false;
$wgEnableWikibaseClient = true;
require_once "$IP/extensions/Wikibase/client/WikibaseClient.php";
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";
$wgWBClientSettings['repoUrl'] = 'http://default.web.mw.localhost:8080';
$wgWBClientSettings['repoScriptPath'] = '/w';
$wgWBClientSettings['repoArticlePath'] = '/wiki/$1';
$wgWBClientSettings['repositories']['']['repoDatabase'] = 'default';
$wgWBClientSettings['repositories']['']['changesDatabase'] = 'default';
$wgWBClientSettings['repositories']['']['baseUri'] = 'http://default.web.mw.localhost:8080/entity/';
$wgWBClientSettings['repositories']['']['entityNamespaces'] = [
			'item' => 120,
			'property' => 122,
		];
$wgWBClientSettings['siteLinkGroups'] = [ 'mywikigroup' ];
$wgWBClientSettings['siteGlobalID'] = 'enwiki';
Add the secondary wiki using mediawiki-docker-dev[edit]
mw-docker-dev addsite enwiki


Add sites[edit]
#default
php maintenance/addSite.php --conf extensions/LocalSettings.default.php --wiki default  --pagepath=http://enwiki.web.mw.localhost:8080/wiki/\$1  --filepath=http://enwiki.web.mw.localhost:8080/w/\$1 --language en --interwiki-id enwiki enwiki mywikigroup

# enwiki
php maintenance/addSite.php --conf extensions/LocalSettings.enwiki.php --wiki enwiki  --pagepath=http://default.web.mw.localhost:8080/wiki/\$1  --filepath=http://default.web.mw.localhost:8080/w/\$1 --language en --interwiki-id default default mywikigroup
Insert interwiki links[edit]
-- run in default db
INSERT INTO `interwiki` (`iw_prefix`, `iw_url`, `iw_api`, `iw_wikiid`, `iw_local`, `iw_trans`) VALUES ('enwiki', 'http://enwiki.web.mw.localhost:8080/wiki/$1', 'http://enwiki.web.mw.localhost:8080/w/api.php', '', '1', '0') 

-- run in enwiki db
INSERT INTO `interwiki` (`iw_prefix`, `iw_url`, `iw_api`, `iw_wikiid`, `iw_local`, `iw_trans`) VALUES ('default', 'http://default.web.mw.localhost:8080/wiki/$1', 'http://default.web.mw.localhost:8080/w/api.php', '', '1', '0')
Create some dummy content[edit]

On repo create an item (Q4) and a property(P1) (string type), add a statement using that property to the item and write something for its value.

On client create a page with something like this

{{#statements:P1|from=Q4}}

{{#statements:P1}}
Create sitelink on repo -> client[edit]

on repo create a site link on the item page by using the sitelink ui on the right. the client name should show up in the first field and the page name should show up in the second field if you start typing. Any errors will show in the network logs of the browser(I had WikibaseCirrusSearch enabled which made this break but without any real explanation).

run dispatchChanges.php on repo[edit]
php extensions/Wikibase/repo/maintenance/dispatchChanges.php --wiki default --conf extensions/LocalSettings.default.php

if the setup is working you should get something similar to this output. Where the last line will be repeated as long as the loop did not find any changes to dispatch. If that is all you see something is wrong.

root@mediawiki:/var/www/mediawiki# php extensions/Wikibase/repo/maintenance/dispatchChanges.php --wiki default --conf extensions/LocalSettings.default.php
08:15:07 Starting loop for unlimited passes or 3600 seconds
08:15:07 Posted 1 changes to enwiki, up to ID 18, timestamp 20200918081421. Lag is 46 seconds. Next ID is 18.
08:15:07 Wikibase\Repo\Store\Sql\SqlChangeDispatchCoordinator::selectClient: Could not lock any of the candidate client wikis for dispatching

To view these dispatched changes on client go to Special:RecentChanges and select the filter and search for Wikidata edits and tick that checkbox.

Running jobs[edit]

for good measure and more overview running the jobs in the terminal for both client / repo gives a bit more insight into whats happening behind the scenes.

Run jobs on client[edit]
php maintenance/runJobs.php --wiki enwiki --conf extensions/LocalSettings.enwiki.php --wait
Run jobs on repo[edit]
php maintenance/runJobs.php --wiki default --conf extensions/LocalSettings.default.php --wait