From: daniel Date: Mon, 6 Aug 2018 12:31:04 +0000 (+0200) Subject: Add safeguard against loading content across wikis. X-Git-Tag: 1.34.0-rc.0~4545^2 X-Git-Url: http://git.cyclocoop.org/?a=commitdiff_plain;h=25e9a28fd035bb5dccc72d2ebb9413f2d0fb5a39;p=lhc%2Fweb%2Fwiklou.git Add safeguard against loading content across wikis. The new MCR schema enables cross-wiki loading of page content, but this mechanism doesn't work as long as the new code is reading from the old schema. This is what caused T201194. Bug: T201194 Change-Id: I58af7a9e02780c55cd8fab20f19be36a0fa804da --- diff --git a/includes/Storage/RevisionStore.php b/includes/Storage/RevisionStore.php index 65c0361b63..5769527796 100644 --- a/includes/Storage/RevisionStore.php +++ b/includes/Storage/RevisionStore.php @@ -207,6 +207,20 @@ class RevisionStore return ( $this->mcrMigrationStage & $flags ) === $flags; } + /** + * Throws a RevisionAccessException if this RevisionStore is configured for cross-wiki loading + * and still reading from the old DB schema. + * + * @throws RevisionAccessException + */ + private function assertCrossWikiContentLoadingIsSafe() { + if ( $this->wikiId !== false && $this->hasMcrSchemaFlags( SCHEMA_COMPAT_READ_OLD ) ) { + throw new RevisionAccessException( + "Cross-wiki content loading is not supported by the pre-MCR schema" + ); + } + } + public function setLogger( LoggerInterface $logger ) { $this->logger = $logger; } @@ -780,6 +794,8 @@ class RevisionStore // MCR migration note: rev_content_model and rev_content_format will go away if ( $this->contentHandlerUseDB ) { + $this->assertCrossWikiContentLoadingIsSafe(); + $defaultModel = ContentHandler::getDefaultModelFor( $title ); $defaultFormat = ContentHandler::getForModelID( $defaultModel )->getDefaultFormat(); @@ -888,6 +904,8 @@ class RevisionStore // if $wgContentHandlerUseDB is not set, // all revisions must use the default content model and format. + $this->assertCrossWikiContentLoadingIsSafe(); + $defaultModel = ContentHandler::getDefaultModelFor( $title ); $defaultHandler = ContentHandler::getForModelID( $defaultModel ); $defaultFormat = $defaultHandler->getDefaultFormat(); @@ -1207,6 +1225,8 @@ class RevisionStore if ( $mainSlotRow->model_name === null ) { $mainSlotRow->model_name = function ( SlotRecord $slot ) use ( $title ) { + $this->assertCrossWikiContentLoadingIsSafe(); + // TODO: MCR: consider slot role in getDefaultModelFor()! Use LinkTarget! // TODO: MCR: deprecate $title->getModel(). return ContentHandler::getDefaultModelFor( $title ); diff --git a/includes/Storage/RevisionStoreFactory.php b/includes/Storage/RevisionStoreFactory.php index cfc544451a..9419b40939 100644 --- a/includes/Storage/RevisionStoreFactory.php +++ b/includes/Storage/RevisionStoreFactory.php @@ -75,7 +75,8 @@ class RevisionStoreFactory { * @param ActorMigration $actorMigration * @param int $migrationStage * @param LoggerSpi $loggerProvider - * @param bool $contentHandlerUseDB see {@link $wgContentHandlerUseDB} + * @param bool $contentHandlerUseDB see {@link $wgContentHandlerUseDB}. Must be the same + * for all wikis in the cluster. Will go away after MCR migration. */ public function __construct( ILBFactory $dbLoadBalancerFactory,