Daniel Kinzler has uploaded a new change for review. https://gerrit.wikimedia.org/r/133227
Change subject: Prevent import of entities to avoid ID conflicts ...................................................................... Prevent import of entities to avoid ID conflicts Bug: 63228 Change-Id: Ie03b10dcb37feb5d038de1730e58daf00d2b49ea --- M repo/Wikibase.hooks.php M repo/Wikibase.php 2 files changed, 22 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/27/133227/1 diff --git a/repo/Wikibase.hooks.php b/repo/Wikibase.hooks.php index 6082c32..e5e5afa 100644 --- a/repo/Wikibase.hooks.php +++ b/repo/Wikibase.hooks.php @@ -1328,4 +1328,25 @@ return true; } + /** + * Called by Import.php. Implemented to prevent the import of entities. + * + * @param object $reader unclear, see Bug 64657 + * @param array $pageInfo + * @param array $revisionInfo + * + * @throws MWException + * @return bool + */ + public static function onImportHandleRevisionXMLTag( $reader, $pageInfo, $revisionInfo ) { + $entityContentFactory = WikibaseRepo::getDefaultInstance()->getEntityContentFactory(); +y + if ( isset( $revisionInfo['model'] ) && $entityContentFactory->isEntityContentModel( $revisionInfo['model'] ) ) { + // Skip entities. + // XXX: This is rather rough. + throw new MWException( 'To avoid ID conflicts, import of Wikibase entities is not allowed.' ); + } + + return true; + } } diff --git a/repo/Wikibase.php b/repo/Wikibase.php index ff02489..a91cdb4 100644 --- a/repo/Wikibase.php +++ b/repo/Wikibase.php @@ -182,6 +182,7 @@ $wgHooks['MakeGlobalVariablesScript'][] = 'Wikibase\RepoHooks::onMakeGlobalVariablesScript'; $wgHooks['ContentHandlerForModelID'][] = 'Wikibase\RepoHooks::onContentHandlerForModelID'; $wgHooks['APIQuerySiteInfoStatisticsInfo'][] = 'Wikibase\RepoHooks::onAPIQuerySiteInfoStatisticsInfo'; + $wgHooks['ImportHandleRevisionXMLTag'][] = 'Wikibase\RepoHooks::onImportHandleRevisionXMLTag'; // Resource Loader Modules: $wgResourceModules = array_merge( $wgResourceModules, include( __DIR__ . "/resources/Resources.php" ) ); -- To view, visit https://gerrit.wikimedia.org/r/133227 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie03b10dcb37feb5d038de1730e58daf00d2b49ea Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits