Merge "Improve links in several specialmute-*"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 19 Jul 2019 14:00:28 +0000 (14:00 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 19 Jul 2019 14:00:28 +0000 (14:00 +0000)
includes/deferred/DeferredUpdates.php
includes/htmlform/fields/HTMLNamespacesMultiselectField.php
includes/import/ImportableUploadRevisionImporter.php
includes/import/WikiRevision.php
includes/resourceloader/ResourceLoaderFileModule.php
resources/Resources.php

index c754cff..d43ffbc 100644 (file)
@@ -28,6 +28,7 @@ use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\LBFactory;
 use Wikimedia\Rdbms\ILBFactory;
 use Wikimedia\Rdbms\LoadBalancer;
+use Wikimedia\Rdbms\DBTransactionError;
 
 /**
  * Class for managing the deferred updates
@@ -352,28 +353,30 @@ class DeferredUpdates {
         * @since 1.34
         */
        public static function attemptUpdate( DeferrableUpdate $update, ILBFactory $lbFactory ) {
+               $ticket = $lbFactory->getEmptyTransactionTicket( __METHOD__ );
+               if ( !$ticket || $lbFactory->hasTransactionRound() ) {
+                       throw new DBTransactionError( null, "A database transaction round is pending." );
+               }
+
                if ( $update instanceof DataUpdate ) {
-                       $update->setTransactionTicket( $lbFactory->getEmptyTransactionTicket( __METHOD__ ) );
+                       $update->setTransactionTicket( $ticket );
                }
 
-               if (
+               $fnameTrxOwner = get_class( $update ) . '::doUpdate';
+               $useExplicitTrxRound = !(
                        $update instanceof TransactionRoundAwareUpdate &&
                        $update->getTransactionRoundRequirement() == $update::TRX_ROUND_ABSENT
-               ) {
-                       $fnameTrxOwner = null;
+               );
+               // Flush any pending changes left over from an implicit transaction round
+               if ( $useExplicitTrxRound ) {
+                       $lbFactory->beginMasterChanges( $fnameTrxOwner ); // new explicit round
                } else {
-                       $fnameTrxOwner = get_class( $update ) . '::doUpdate';
+                       $lbFactory->commitMasterChanges( $fnameTrxOwner ); // new implicit round
                }
-
-               if ( $fnameTrxOwner !== null ) {
-                       $lbFactory->beginMasterChanges( $fnameTrxOwner );
-               }
-
+               // Run the update after any stale master view snapshots have been flushed
                $update->doUpdate();
-
-               if ( $fnameTrxOwner !== null ) {
-                       $lbFactory->commitMasterChanges( $fnameTrxOwner );
-               }
+               // Commit any pending changes from the explicit or implicit transaction round
+               $lbFactory->commitMasterChanges( $fnameTrxOwner );
        }
 
        /**
index cbcd3ba..860a351 100644 (file)
@@ -28,7 +28,7 @@ class HTMLNamespacesMultiselectField extends HTMLSelectNamespace {
        }
 
        public function validate( $value, $alldata ) {
-               if ( !$this->mParams['exists'] ) {
+               if ( !$this->mParams['exists'] || $value === '' ) {
                        return true;
                }
 
index 40c9417..4be13b0 100644 (file)
@@ -139,9 +139,9 @@ class ImportableUploadRevisionImporter implements UploadRevisionImporter {
 
        /**
         * @deprecated DO NOT CALL ME.
-        * This method was introduced when factoring UploadImporter out of WikiRevision.
-        * It only has 1 use by the deprecated downloadSource method in WikiRevision.
-        * Do not use this in new code.
+        * This method was introduced when factoring (Importable)UploadRevisionImporter out of
+        * WikiRevision. It only has 1 use by the deprecated downloadSource method in WikiRevision.
+        * Do not use this in new code, it will be made private soon.
         *
         * @param ImportableUploadRevision $wikiRevision
         *
index c006874..cae9542 100644 (file)
@@ -636,7 +636,7 @@ class WikiRevision implements ImportableUploadRevision, ImportableOldRevision {
 
        /**
         * @since 1.12.2
-        * @deprecated in 1.31. Use UploadImporter::import
+        * @deprecated in 1.31. Use UploadRevisionImporter::import
         * @return bool
         */
        public function importUpload() {
@@ -647,7 +647,7 @@ class WikiRevision implements ImportableUploadRevision, ImportableOldRevision {
 
        /**
         * @since 1.12.2
-        * @deprecated in 1.31. Use UploadImporter::downloadSource
+        * @deprecated in 1.31. No replacement
         * @return bool|string
         */
        public function downloadSource() {
index fbc59fe..af30313 100644 (file)
@@ -1159,11 +1159,12 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                                throw new MWException( __METHOD__ . ": invalid versionCallback for file" .
                                                        " \"{$fileInfo['name']}\" in module \"{$this->getName()}\"" );
                                        }
-                                       $expanded['definitionSummary'] = ( $fileInfo['versionCallback'] )( $context );
+                                       $expanded['definitionSummary'] =
+                                               ( $fileInfo['versionCallback'] )( $context, $this->getConfig() );
                                        // Don't invoke 'callback' here as it may be expensive (T223260).
                                        $expanded['callback'] = $fileInfo['callback'];
                                } else {
-                                       $expanded['content'] = ( $fileInfo['callback'] )( $context );
+                                       $expanded['content'] = ( $fileInfo['callback'] )( $context, $this->getConfig() );
                                }
                        } elseif ( isset( $fileInfo['config'] ) ) {
                                if ( $type !== 'data' ) {
@@ -1240,7 +1241,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                $fileInfo['content'] = $content;
                                unset( $fileInfo['filePath'] );
                        } elseif ( isset( $fileInfo['callback'] ) ) {
-                               $fileInfo['content'] = ( $fileInfo['callback'] )( $context );
+                               $fileInfo['content'] = ( $fileInfo['callback'] )( $context, $this->getConfig() );
                                unset( $fileInfo['callback'] );
                        }
 
index 6298086..9455994 100644 (file)
@@ -1526,7 +1526,9 @@ return [
                'remoteBasePath' => "$wgResourceBasePath/resources/src/mediawiki.jqueryMsg",
                'packageFiles' => [
                        'mediawiki.jqueryMsg.js',
-                       [ 'name' => 'parserDefaults.json', 'callback' => function ( ResourceLoaderContext $context ) {
+                       [ 'name' => 'parserDefaults.json', 'callback' => function (
+                               ResourceLoaderContext $context, Config $config
+                       ) {
                                $tagData = Sanitizer::getRecognizedTagData();
                                $allowedHtmlElements = array_merge(
                                        array_keys( $tagData['htmlpairs'] ),
@@ -1537,7 +1539,7 @@ return [
                                );
 
                                $magicWords = [
-                                       'SITENAME' => $context->getConfig()->get( 'Sitename' ),
+                                       'SITENAME' => $config->get( 'Sitename' ),
                                ];
                                Hooks::run( 'ResourceLoaderJqueryMsgModuleMagicWords', [ $context, &$magicWords ] );