User:Tobias Andersson (WMDE)/clientRepoSetup

LocalSettings.phpEdit
<?php
require_once __DIR__ . '/.docker/LocalSettings.php';

if(isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == 'enwiki.web.mw.localhost') {
	require_once __DIR__ . '/LocalSettings.enwiki.php';
} else if(isset($_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME'] == 'fedpropwiki.web.mw.localhost') {
	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'] = '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-devEdit
mw-docker-dev addsite enwiki


Add sitesEdit
#default
php maintenance/addSite.php --conf 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 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 linksEdit
-- 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 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

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

{{#statements:P1}}
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