Merge "Duplicate table indexes in DatabaseSqlite::duplicateTableStructure"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 6 Aug 2015 12:37:23 +0000 (12:37 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 6 Aug 2015 12:37:23 +0000 (12:37 +0000)
includes/DefaultSettings.php
includes/OutputPage.php
includes/parser/Parser.php
includes/parser/ParserOutput.php
includes/resourceloader/ResourceLoaderModule.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/skins/Skin.php
maintenance/refreshLinks.php
resources/src/mediawiki.legacy/wikibits.js
resources/src/mediawiki/mediawiki.js

index 53137a6..19d4b89 100644 (file)
@@ -3524,28 +3524,27 @@ $wgResourceLoaderMinifierStatementsOnOwnLine = false;
 $wgResourceLoaderMinifierMaxLineLength = 1000;
 
 /**
- * Whether to include the mediawiki.legacy JS library (old wikibits.js), and its
- * dependencies.
+ * Whether to ensure the mediawiki.legacy library is loaded before other modules.
+ *
+ * @deprecated since 1.26: Always declare dependencies.
  */
 $wgIncludeLegacyJavaScript = true;
 
 /**
- * Whether to preload the mediawiki.util module as blocking module in the top
- * queue.
+ * Whether to ensure the mediawiki.util is loaded before other modules.
  *
- * Before MediaWiki 1.19, modules used to load slower/less asynchronous which
- * allowed modules to lack dependencies on 'popular' modules that were likely
- * loaded already.
+ * Before MediaWiki 1.19, modules used to load less asynchronous which allowed
+ * modules to lack dependencies on 'popular' modules that were likely loaded already.
  *
  * This setting is to aid scripts during migration by providing mediawiki.util
- * unconditionally (which was the most commonly missed dependency).
- * It doesn't cover all missing dependencies obviously but should fix most of
- * them.
+ * unconditionally (which was the most commonly missed dependency). It doesn't
+ * cover all missing dependencies obviously but should fix most of them.
  *
  * This should be removed at some point after site/user scripts have been fixed.
  * Enable this if your wiki has a large amount of user/site scripts that are
  * lacking dependencies.
- * @todo Deprecate
+ *
+ * @deprecated since 1.26: Always declare dependencies.
  */
 $wgPreloadJavaScriptMwUtil = false;
 
index 0f0b2f5..dd7b90a 100644 (file)
@@ -1818,6 +1818,11 @@ class OutputPage extends ContextSource {
                        }
                }
 
+               // enable OOUI if requested via ParserOutput
+               if ( $parserOutput->getEnableOOUI() ) {
+                       $this->enableOOUI();
+               }
+
                // Link flags are ignored for now, but may in the future be
                // used to mark individual language links.
                $linkFlags = array();
@@ -3942,21 +3947,34 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
-        * MediaWiki and this OutputPage instance.
+        * Helper function to setup the PHP implementation of OOUI to use in this request.
         *
-        * @since 1.25
+        * @since 1.26
+        * @param String $skinName The Skin name to determine the correct OOUI theme
+        * @param String $dir Language direction
         */
-       public function enableOOUI() {
+       public static function setupOOUI( $skinName = '', $dir = 'ltr' ) {
                $themes = ExtensionRegistry::getInstance()->getAttribute( 'SkinOOUIThemes' );
                // Make keys (skin names) lowercase for case-insensitive matching.
                $themes = array_change_key_case( $themes, CASE_LOWER );
-               $skinName = strtolower( $this->getSkin()->getSkinName() );
                $theme = isset( $themes[ $skinName ] ) ? $themes[ $skinName ] : 'MediaWiki';
                // For example, 'OOUI\MediaWikiTheme'.
                $themeClass = "OOUI\\{$theme}Theme";
                OOUI\Theme::setSingleton( new $themeClass() );
-               OOUI\Element::setDefaultDir( $this->getLanguage()->getDir() );
+               OOUI\Element::setDefaultDir( $dir );
+       }
+
+       /**
+        * Add ResourceLoader module styles for OOUI and set up the PHP implementation of it for use with
+        * MediaWiki and this OutputPage instance.
+        *
+        * @since 1.25
+        */
+       public function enableOOUI() {
+               self::setupOOUI(
+                       strtolower( $this->getSkin()->getSkinName() ),
+                       $this->getLanguage()->getDir()
+               );
                $this->addModuleStyles( array(
                        'oojs-ui.styles',
                        'oojs-ui.styles.icons',
index 7dab564..6189997 100644 (file)
@@ -6444,4 +6444,15 @@ class Parser {
                        return $this;
                }
        }
+
+       /**
+        * Set's up the PHP implementation of OOUI for use in this request
+        * and instructs OutputPage to enable OOUI for itself.
+        *
+        * @since 1.26
+        */
+       public function enableOOUI() {
+               OutputPage::setupOOUI();
+               $this->mOutput->setEnableOOUI( true );
+       }
 }
index 7068bd7..15321c2 100644 (file)
@@ -49,7 +49,8 @@ class ParserOutput extends CacheTime {
                $mProperties = array(),       # Name/value pairs to be cached in the DB
                $mTOCHTML = '',               # HTML of the TOC
                $mTimestamp,                  # Timestamp of the revision
-               $mTOCEnabled = true;          # Whether TOC should be shown, can't override __NOTOC__
+               $mTOCEnabled = true,          # Whether TOC should be shown, can't override __NOTOC__
+               $mEnableOOUI = false;         # Whether OOUI should be enabled
        private $mIndexPolicy = '';       # 'index' or 'noindex'?  Any other value will result in no change.
        private $mAccessedOptions = array(); # List of ParserOptions (stored in the keys)
        private $mExtensionData = array(); # extra data used by extensions
@@ -232,6 +233,10 @@ class ParserOutput extends CacheTime {
                return $this->mTOCEnabled;
        }
 
+       public function getEnableOOUI() {
+               return $this->mEnableOOUI;
+       }
+
        public function setText( $text ) {
                return wfSetVar( $this->mText, $text );
        }
@@ -283,6 +288,17 @@ class ParserOutput extends CacheTime {
                $this->mIndicators[$id] = $content;
        }
 
+       /**
+        * Enables OOUI, if true, in any OutputPage instance this ParserOutput
+        * object is added to.
+        *
+        * @since 1.26
+        * @param bool $enable If OOUI should be enabled or not
+        */
+       public function setEnableOOUI( $enable = false ) {
+               $this->mEnableOOUI = $enable;
+       }
+
        public function addLanguageLink( $t ) {
                $this->mLanguageLinks[] = $t;
        }
index 8e53c3e..ade99e2 100644 (file)
@@ -857,7 +857,7 @@ abstract class ResourceLoaderModule {
         */
        protected static function safeFileHash( $filePath ) {
                MediaWiki\suppressWarnings();
-               $hash = sha1_file( $filename ) ?: '';
+               $hash = sha1_file( $filePath ) ?: '';
                MediaWiki\restoreWarnings();
                return $hash;
        }
index 144107c..64678f4 100644 (file)
@@ -101,6 +101,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                        'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass( Title::legalChars() ),
                        'wgResourceLoaderStorageVersion' => $conf->get( 'ResourceLoaderStorageVersion' ),
                        'wgResourceLoaderStorageEnabled' => $conf->get( 'ResourceLoaderStorageEnabled' ),
+                       'wgResourceLoaderLegacyModules' => self::getLegacyModules(),
                );
 
                Hooks::run( 'ResourceLoaderGetConfigVars', array( &$vars ) );
@@ -293,6 +294,20 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
                return array( 'jquery', 'mediawiki' );
        }
 
+       public static function getLegacyModules() {
+               global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil;
+
+               $legacyModules = array();
+               if ( $wgIncludeLegacyJavaScript ) {
+                       $legacyModules[] = 'mediawiki.legacy.wikibits';
+               }
+               if ( $wgPreloadJavaScriptMwUtil ) {
+                       $legacyModules[] = 'mediawiki.util';
+               }
+
+               return $legacyModules;
+       }
+
        /**
         * Get the load URL of the startup modules.
         *
index 2a1b0a3..53af3e7 100644 (file)
@@ -180,8 +180,7 @@ abstract class Skin extends ContextSource {
         * @return array Array of modules with helper keys for easy overriding
         */
        public function getDefaultModules() {
-               global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
-                       $wgAjaxWatch, $wgEnableAPI, $wgEnableWriteAPI;
+               global $wgUseAjax, $wgAjaxWatch, $wgEnableAPI, $wgEnableWriteAPI;
 
                $out = $this->getOutput();
                $user = $out->getUser();
@@ -191,7 +190,7 @@ abstract class Skin extends ContextSource {
                                'mediawiki.page.ready',
                        ),
                        // modules that exist for legacy reasons
-                       'legacy' => array(),
+                       'legacy' => ResourceLoaderStartUpModule::getLegacyModules(),
                        // modules relating to search functionality
                        'search' => array(),
                        // modules relating to functionality relating to watching an article
@@ -199,13 +198,6 @@ abstract class Skin extends ContextSource {
                        // modules which relate to the current users preferences
                        'user' => array(),
                );
-               if ( $wgIncludeLegacyJavaScript ) {
-                       $modules['legacy'][] = 'mediawiki.legacy.wikibits';
-               }
-
-               if ( $wgPreloadJavaScriptMwUtil ) {
-                       $modules['legacy'][] = 'mediawiki.util';
-               }
 
                // Add various resources if required
                if ( $wgUseAjax ) {
index 5d311ad..f6c721f 100644 (file)
@@ -327,13 +327,14 @@ class RefreshLinks extends Maintenance {
 
                foreach ( $linksTables as $table => $field ) {
                        $this->output( "    $table: 0" );
+                       $tableStart = $start;
                        $counter = 0;
                        do {
                                $ids = $dbr->selectFieldValues(
                                        $table,
                                        $field,
                                        array(
-                                               self::intervalCond( $dbr, $field, $start, $end ),
+                                               self::intervalCond( $dbr, $field, $tableStart, $end ),
                                                "$field NOT IN ({$dbr->selectSQLText( 'page', 'page_id' )})",
                                        ),
                                        __METHOD__,
@@ -346,10 +347,10 @@ class RefreshLinks extends Maintenance {
                                        wfWaitForSlaves();
                                        $dbw->delete( $table, array( $field => $ids ), __METHOD__ );
                                        $this->output( ", $counter" );
-                                       $start = $ids[$numIds - 1] + 1;
+                                       $tableStart = $ids[$numIds - 1] + 1;
                                }
 
-                       } while ( $numIds >= $batchSize && ( $end === null || $start <= $end ) );
+                       } while ( $numIds >= $batchSize && ( $end === null || $tableStart <= $end ) );
 
                        $this->output( " deleted.\n" );
 
index 32cd79a..1f01110 100644 (file)
        win.importScript = importScript;
        win.importStylesheet = importStylesheet;
 
+       // Replace document.write with basic html parsing that appends
+       // to the <body> to avoid blanking pages. Added JavaScript will not run.
+       mw.log.deprecate( document, 'write', function ( html ) {
+               $( 'body' ).append( $.parseHTML( html ) );
+       }, 'Use jQuery or mw.loader.load instead.' );
+
 }( mediaWiki, jQuery ) );
index 3c5a5f5..6548896 100644 (file)
                                }
 
                                function runScript() {
-                                       var script, markModuleReady, nestedAddScript;
+                                       var script, markModuleReady, nestedAddScript, legacyWait,
+                                               // Expand to include dependencies since we have to exclude both legacy modules
+                                               // and their dependencies from the legacyWait (to prevent a circular dependency).
+                                               legacyModules = resolve( mw.config.get( 'wgResourceLoaderLegacyModules', [] ) );
                                        try {
                                                script = registry[module].script;
                                                markModuleReady = function () {
                                                        } );
                                                };
 
-                                               if ( $.isArray( script ) ) {
-                                                       nestedAddScript( script, markModuleReady, 0 );
-                                               } else if ( $.isFunction( script ) ) {
-                                                       // Pass jQuery twice so that the signature of the closure which wraps
-                                                       // the script can bind both '$' and 'jQuery'.
-                                                       registry[module].state = 'ready';
-                                                       script( $, $ );
-                                                       handlePending( module );
-                                               } else if ( typeof script === 'string' ) {
-                                                       // Site and user modules are a legacy scripts that run in the global scope.
-                                                       // This is transported as a string instead of a function to avoid needing
-                                                       // to use string manipulation to undo the function wrapper.
-                                                       if ( module === 'user' ) {
-                                                               // Implicit dependency on the site module. Not real dependency because
-                                                               // it should run after 'site' regardless of whether it succeeds or fails.
-                                                               mw.loader.using( 'site' ).always( function () {
+                                               legacyWait = ( $.inArray( module, legacyModules ) !== -1 )
+                                                       ? $.Deferred().resolve()
+                                                       : mw.loader.using( legacyModules );
+
+                                               legacyWait.always( function () {
+                                                       if ( $.isArray( script ) ) {
+                                                               nestedAddScript( script, markModuleReady, 0 );
+                                                       } else if ( $.isFunction( script ) ) {
+                                                               // Pass jQuery twice so that the signature of the closure which wraps
+                                                               // the script can bind both '$' and 'jQuery'.
+                                                               registry[module].state = 'ready';
+                                                               script( $, $ );
+                                                               handlePending( module );
+                                                       } else if ( typeof script === 'string' ) {
+                                                               // Site and user modules are a legacy scripts that run in the global scope.
+                                                               // This is transported as a string instead of a function to avoid needing
+                                                               // to use string manipulation to undo the function wrapper.
+                                                               if ( module === 'user' ) {
+                                                                       // Implicit dependency on the site module. Not real dependency because
+                                                                       // it should run after 'site' regardless of whether it succeeds or fails.
+                                                                       mw.loader.using( 'site' ).always( function () {
+                                                                               registry[module].state = 'ready';
+                                                                               $.globalEval( script );
+                                                                               handlePending( module );
+                                                                       } );
+                                                               } else {
                                                                        registry[module].state = 'ready';
                                                                        $.globalEval( script );
                                                                        handlePending( module );
-                                                               } );
-                                                       } else {
-                                                               registry[module].state = 'ready';
-                                                               $.globalEval( script );
-                                                               handlePending( module );
+                                                               }
                                                        }
-                                               }
+                                               } );
                                        } catch ( e ) {
                                                // This needs to NOT use mw.log because these errors are common in production mode
                                                // and not in debug mode, such as when a symbol that should be global isn't exported