User:Tobias Andersson (WMDE)/clientRepoSetup

require_once __DIR__ . '/.docker/LocalSettings.php';

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

Repo LocalSettings.default.phpEdit
$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.phpEdit
$wgEnableWikibaseRepo = false;
$wgEnableWikibaseClient = true;
require_once "$IP/extensions/Wikibase/client/WikibaseClient.php";
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";
$wgWBClientSettings['repoUrl'] = '';
$wgWBClientSettings['repoScriptPath'] = '/w';
$wgWBClientSettings['repoArticlePath'] = '/wiki/$1';
$wgWBClientSettings['repositories']['']['repoDatabase'] = 'default';
$wgWBClientSettings['repositories']['']['changesDatabase'] = 'default';
$wgWBClientSettings['repositories']['']['baseUri'] = '';
$wgWBClientSettings['repositories']['']['entityNamespaces'] = [
			'item' => 120,
			'property' => 122,
$wgWBClientSettings['siteLinkGroups'] = [ 'mywikigroup' ];
$wgWBClientSettings['siteGlobalID'] = 'enwiki';
Add the secondary wiki using mediawiki-docker-devEdit
mw-docker-dev addsite enwiki

Add sitesEdit
php maintenance/addSite.php --conf LocalSettings.default.php --wiki default  --pagepath=\$1  --filepath=\$1 --language en --interwiki-id enwiki enwiki mywikigroup

# enwiki
php maintenance/addSite.php --conf LocalSettings.enwiki.php --wiki enwiki  --pagepath=\$1  --filepath=\$1 --language en --interwiki-id default default mywikigroup
Insert interwiki linksEdit
-- run in default db
INSERT INTO `interwiki` (`iw_prefix`, `iw_url`, `iw_api`, `iw_wikiid`, `iw_local`, `iw_trans`) VALUES ('enwiki', '$1', '', '', '1', '0') 

-- run in enwiki db
INSERT INTO `interwiki` (`iw_prefix`, `iw_url`, `iw_api`, `iw_wikiid`, `iw_local`, `iw_trans`) VALUES ('default', '$1', '', '', '1', '0')
Create some dummy contentEdit

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


Create sitelink on repo -> clientEdit

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 repoEdit
php extensions/Wikibase/repo/maintenance/dispatchChanges.php --wiki default --conf 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 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 jobsEdit

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 clientEdit
php maintenance/runJobs.php --wiki enwiki --conf LocalSettings.enwiki.php --wait
Run jobs on repoEdit
php maintenance/runJobs.php --wiki default --conf LocalSettings.default.php --wait