Page MenuHomePhabricator
Paste P16729

Wikibase Entity Source Lagacy Configuration Migration Script v0.1
ActivePublic

Authored by Michael on Jun 25 2021, 8:55 AM.
<?php
declare( strict_types=1 );
use Wikibase\Client\WikibaseClient;
use Wikibase\DataAccess\EntitySource;
use Wikibase\Lib\WikibaseSettings;
use Wikibase\Repo\WikibaseRepo;
/**
* @param EntitySource[] $entitySources
*/
function createSettingsFromEntitySources( array $entitySources ): array {
$entitySourceConfig = [];
foreach ( $entitySources as $source ) {
$entitySourceConfig[$source->getSourceName()] = [
'entityNamespaces' => $source->getEntityNamespaceIds(),
'repoDatabase' => $source->getDatabaseName(),
'baseUri' => $source->getConceptBaseUri(),
'rdfNodeNamespacePrefix' => $source->getRdfNodeNamespacePrefix(),
'rdfPredicateNamespacePrefix' => $source->getRdfPredicateNamespacePrefix(),
'interwikiPrefix' => $source->getInterwikiPrefix(),
];
}
return $entitySourceConfig;
}
// FIXME: assert that we're running on the Wikibase REL1_36 release!
print_r( 'You will want something to the effect of the following in your LocalSettings.php:' . "\n" );
if ( WikibaseSettings::isRepoEnabled() ) {
$repoEntitySourceConfig = createSettingsFromEntitySources(
WikibaseRepo::getEntitySourceDefinitions()->getSources()
);
print_r('$wgWBRepoSettings[\'entitySources\'] = ');
var_export( $repoEntitySourceConfig );
print_r(";\n");
}
if ( WikibaseSettings::isClientEnabled() ) {
$clientEntitySourceConfig = createSettingsFromEntitySources(
WikibaseClient::getEntitySourceDefinitions()->getSources()
);
print_r( '$wgWBClientSettings[\'entitySources\'] = ' );
var_export( $clientEntitySourceConfig );
print_r( ";\n" );
}
// if both repo and client are enabled and their config is the same, then output it only once