Merge "Whitelist phpcs Squiz.Scope.MemberVarScope in PHPVersionCheck"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 7 Aug 2018 17:31:09 +0000 (17:31 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 7 Aug 2018 17:31:09 +0000 (17:31 +0000)
includes/Storage/RevisionStore.php
includes/Storage/RevisionStoreFactory.php
includes/logging/LogEventsList.php
tests/phpunit/includes/libs/XhprofDataTest.php

index 65c0361..5769527 100644 (file)
@@ -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 );
index cfc5444..9419b40 100644 (file)
@@ -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,
index f032efc..a5aa687 100644 (file)
@@ -130,10 +130,13 @@ class LogEventsList extends ContextSource {
                        !empty( $extraInputsDescriptor )
                ) {
                        $formDescriptor[ 'extra' ] = $extraInputsDescriptor;
-               } elseif ( is_string( $extraInputsDescriptor ) ) {
+               } elseif (
+                       is_string( $extraInputsDescriptor ) &&
+                       $extraInputsDescriptor !== ''
+               ) {
                        // We'll add this to the footer of the form later
                        $extraInputsString = $extraInputsDescriptor;
-                       wfDeprecated( 'Using $input in LogEventsListGetExtraInputs hook', '1.32' );
+                       wfDeprecated( '$input in LogEventsListGetExtraInputs hook', '1.32' );
                }
 
                // Title pattern, if allowed
index 1cbd86f..3e93794 100644 (file)
@@ -19,8 +19,6 @@
  */
 
 /**
- * @uses XhprofData
- * @uses AutoLoader
  * @copyright © 2014 Wikimedia Foundation and contributors
  * @since 1.25
  */
@@ -154,7 +152,6 @@ class XhprofDataTest extends PHPUnit\Framework\TestCase {
        /**
         * @covers XhprofData::getCallers
         * @covers XhprofData::getCallees
-        * @uses XhprofData
         */
        public function testEdges() {
                $xhprofData = $this->getXhprofDataFixture();
@@ -170,7 +167,6 @@ class XhprofDataTest extends PHPUnit\Framework\TestCase {
 
        /**
         * @covers XhprofData::getCriticalPath
-        * @uses XhprofData
         */
        public function testCriticalPath() {
                $xhprofData = $this->getXhprofDataFixture();