Merge "specials: Remove invalid return from RedirectSpecialPage::execute"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 15 Apr 2019 19:19:40 +0000 (19:19 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 15 Apr 2019 19:19:40 +0000 (19:19 +0000)
includes/content/JsonContent.php
includes/parser/Parser.php
includes/resourceloader/ResourceLoaderContext.php
includes/resourceloader/ResourceLoaderWikiModule.php
includes/specials/SpecialImport.php
includes/specials/pagers/ContribsPager.php
resources/src/mediawiki.content.json.less
resources/src/startup/mediawiki.js
tests/phpunit/includes/content/JsonContentTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderContextTest.php
tests/selenium/specs/page.js

index 2cd1fb3..a1f199d 100644 (file)
@@ -220,7 +220,7 @@ class JsonContent extends TextContent {
                        return Html::rawElement( 'td', [], $this->arrayTable( $val ) );
                }
 
-               return Html::element( 'td', [ 'class' => 'value' ], $this->primitiveValue( $val ) );
+               return Html::element( 'td', [ 'class' => 'mw-json-value' ], $this->primitiveValue( $val ) );
        }
 
        /**
index 91de550..c28d842 100644 (file)
@@ -2607,7 +2607,7 @@ class Parser {
                        // @TODO: disallow this word on all namespaces
                        $this->nsInfo->isContent( $this->mTitle->getNamespace() )
                ) {
-                       if ( $this->mRevisionId ) {
+                       if ( $this->mRevisionId || $this->mOptions->getSpeculativeRevId() ) {
                                return '-';
                        } else {
                                $this->mOutput->setFlag( 'vary-revision-exists' );
index 7afbfb2..58152ea 100644 (file)
@@ -84,9 +84,11 @@ class ResourceLoaderContext implements MessageLocalizer {
 
                $this->skin = $request->getRawVal( 'skin' );
                $skinnames = Skin::getSkinNames();
-               // If no skin is specified, or we don't recognize the skin, use the default skin
                if ( !$this->skin || !isset( $skinnames[$this->skin] ) ) {
-                       $this->skin = $this->getConfig()->get( 'DefaultSkin' );
+                       // The 'skin' parameter is required. (Not yet enforced.)
+                       // For requests without a known skin specified,
+                       // use MediaWiki's 'fallback' skin for skin-specific decisions.
+                       $this->skin = 'fallback';
                }
        }
 
@@ -170,7 +172,9 @@ class ResourceLoaderContext implements MessageLocalizer {
                        $lang = $this->getRequest()->getRawVal( 'lang', '' );
                        // Stricter version of RequestContext::sanitizeLangCode()
                        if ( !Language::isValidBuiltInCode( $lang ) ) {
-                               $lang = $this->getConfig()->get( 'LanguageCode' );
+                               // The 'lang' parameter is required. (Not yet enforced.)
+                               // If omitted, localise with the dummy language code.
+                               $lang = 'qqx';
                        }
                        $this->language = $lang;
                }
index 9fad348..276d9a1 100644 (file)
@@ -82,7 +82,7 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
         *  getPages.
         */
        public function __construct( array $options = null ) {
-               if ( is_null( $options ) ) {
+               if ( $options === null ) {
                        return;
                }
 
index aaa405a..302a55f 100644 (file)
@@ -24,6 +24,8 @@
  * @ingroup SpecialPage
  */
 
+use MediaWiki\Permissions\PermissionManager;
+
 /**
  * MediaWiki page data importer
  *
@@ -83,11 +85,11 @@ class SpecialImport extends SpecialPage {
                # getUserPermissionsErrors() might actually be used for, hence the 'ns-specialprotected'
                $errors = wfMergeErrorArrays(
                        $this->getPageTitle()->getUserPermissionsErrors(
-                               'import', $user, true,
+                               'import', $user, PermissionManager::RIGOR_FULL,
                                [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ]
                        ),
                        $this->getPageTitle()->getUserPermissionsErrors(
-                               'importupload', $user, true,
+                               'importupload', $user, PermissionManager::RIGOR_FULL,
                                [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ]
                        )
                );
index 10fcfc6..44ecb6f 100644 (file)
@@ -301,11 +301,12 @@ class ContribsPager extends RangeChronologicalPager {
                                if ( isset( $conds['orconds']['actor'] ) ) {
                                        // @todo: This will need changing when revision_comment_temp goes away
                                        $queryInfo['options']['USE INDEX']['temp_rev_user'] = 'actor_timestamp';
-                                       // Alias 'rev_timestamp' => 'revactor_timestamp' so "ORDER BY rev_timestamp" is interpreted to
-                                       // use revactor_timestamp instead.
+                                       // Alias 'rev_timestamp' => 'revactor_timestamp' and 'rev_id' => 'revactor_rev' so
+                                       // "ORDER BY rev_timestamp, rev_id" is interpreted to use denormalized revision_actor_temp
+                                       // fields instead.
                                        $queryInfo['fields'] = array_merge(
-                                               array_diff( $queryInfo['fields'], [ 'rev_timestamp' ] ),
-                                               [ 'rev_timestamp' => 'revactor_timestamp' ]
+                                               array_diff( $queryInfo['fields'], [ 'rev_timestamp', 'rev_id' ] ),
+                                               [ 'rev_timestamp' => 'revactor_timestamp', 'rev_id' => 'revactor_rev' ]
                                        );
                                } else {
                                        $queryInfo['options']['USE INDEX']['revision'] =
index ca950d5..4fa9ee2 100644 (file)
        padding: 0.5em 1em;
 }
 
+/* TODO: Remove this old class once the content caches have cleared */
 /* stylelint-disable-next-line selector-class-pattern */
 .mw-json .value,
+.mw-json-value,
 .mw-json-single-value {
        background-color: #dcfae3;
        font-family: monospace, monospace;
index 676a139..4b65ed5 100644 (file)
                                 *  "text/javascript"; if no type is provided, text/javascript is assumed.
                                 */
                                load: function ( modules, type ) {
-                                       var l;
-
-                                       // Allow calling with a url or single dependency as a string
-                                       if ( typeof modules === 'string' ) {
-                                               // "https://example.org/x.js", "http://example.org/x.js", "//example.org/x.js", "/x.js"
-                                               if ( /^(https?:)?\/?\//.test( modules ) ) {
-                                                       if ( type === 'text/css' ) {
-                                                               l = document.createElement( 'link' );
-                                                               l.rel = 'stylesheet';
-                                                               l.href = modules;
-                                                               document.head.appendChild( l );
-                                                               return;
-                                                       }
-                                                       if ( type === 'text/javascript' || type === undefined ) {
-                                                               addScript( modules );
-                                                               return;
-                                                       }
+                                       if ( typeof modules === 'string' && /^(https?:)?\/?\//.test( modules ) ) {
+                                               // Called with a url like so:
+                                               // - "https://example.org/x.js"
+                                               // - "http://example.org/x.js"
+                                               // - "//example.org/x.js"
+                                               // - "/x.js"
+                                               if ( type === 'text/css' ) {
+                                                       addLink( modules );
+                                               } else if ( type === 'text/javascript' || type === undefined ) {
+                                                       addScript( modules );
+                                               } else {
                                                        // Unknown type
                                                        throw new Error( 'type must be text/css or text/javascript, found ' + type );
                                                }
-                                               // Called with single module
-                                               modules = [ modules ];
+                                       } else {
+                                               // One or more modules
+                                               modules = typeof modules === 'string' ? [ modules ] : modules;
+                                               // Resolve modules into flat list for internal queuing.
+                                               // This also filters out unknown modules and modules with
+                                               // unknown dependencies, allowing the rest to continue. (T36853)
+                                               enqueue( resolveStubbornly( modules ), undefined, undefined );
                                        }
-
-                                       // Resolve modules into flat list for internal queuing.
-                                       // This also filters out unknown modules and modules with
-                                       // unknown dependencies, allowing the rest to continue. (T36853)
-                                       enqueue( resolveStubbornly( modules ), undefined, undefined );
                                },
 
                                /**
index 7cddbad..8546d96 100644 (file)
@@ -113,27 +113,27 @@ class JsonContentTest extends MediaWikiLangTestCase {
                        ],
                        [
                                (object)[ 'foo' ],
-                               '<table class="mw-json"><tbody><tr><th>0</th><td class="value">"foo"</td></tr>' .
+                               '<table class="mw-json"><tbody><tr><th>0</th><td class="mw-json-value">"foo"</td></tr>' .
                                '</tbody></table>'
                        ],
                        [
                                (object)[ 'foo', 'bar' ],
-                               '<table class="mw-json"><tbody><tr><th>0</th><td class="value">"foo"</td></tr>' .
-                               '<tr><th>1</th><td class="value">"bar"</td></tr></tbody></table>'
+                               '<table class="mw-json"><tbody><tr><th>0</th><td class="mw-json-value">"foo"</td></tr>' .
+                               '<tr><th>1</th><td class="mw-json-value">"bar"</td></tr></tbody></table>'
                        ],
                        [
                                (object)[ 'baz' => 'foo', 'bar' ],
-                               '<table class="mw-json"><tbody><tr><th>baz</th><td class="value">"foo"</td></tr>' .
-                               '<tr><th>0</th><td class="value">"bar"</td></tr></tbody></table>'
+                               '<table class="mw-json"><tbody><tr><th>baz</th><td class="mw-json-value">"foo"</td></tr>' .
+                               '<tr><th>0</th><td class="mw-json-value">"bar"</td></tr></tbody></table>'
                        ],
                        [
                                (object)[ 'baz' => 1000, 'bar' ],
-                               '<table class="mw-json"><tbody><tr><th>baz</th><td class="value">1000</td></tr>' .
-                               '<tr><th>0</th><td class="value">"bar"</td></tr></tbody></table>'
+                               '<table class="mw-json"><tbody><tr><th>baz</th><td class="mw-json-value">1000</td></tr>' .
+                               '<tr><th>0</th><td class="mw-json-value">"bar"</td></tr></tbody></table>'
                        ],
                        [
                                (object)[ '<script>alert("evil!")</script>' ],
-                               '<table class="mw-json"><tbody><tr><th>0</th><td class="value">"' .
+                               '<table class="mw-json"><tbody><tr><th>0</th><td class="mw-json-value">"' .
                                '&lt;script>alert("evil!")&lt;/script>"' .
                                '</td></tr></tbody></table>',
                        ],
index 5c53040..60cd4a8 100644 (file)
@@ -14,8 +14,6 @@ class ResourceLoaderContextTest extends PHPUnit\Framework\TestCase {
        protected static function getResourceLoader() {
                return new EmptyResourceLoader( new HashConfig( [
                        'ResourceLoaderDebug' => false,
-                       'DefaultSkin' => 'fallback',
-                       'LanguageCode' => 'nl',
                        'LoadScript' => '/w/load.php',
                ] ) );
        }
@@ -25,7 +23,7 @@ class ResourceLoaderContextTest extends PHPUnit\Framework\TestCase {
 
                // Request parameters
                $this->assertEquals( [], $ctx->getModules() );
-               $this->assertEquals( 'nl', $ctx->getLanguage() );
+               $this->assertEquals( 'qqx', $ctx->getLanguage() );
                $this->assertEquals( false, $ctx->getDebug() );
                $this->assertEquals( null, $ctx->getOnly() );
                $this->assertEquals( 'fallback', $ctx->getSkin() );
@@ -34,7 +32,7 @@ class ResourceLoaderContextTest extends PHPUnit\Framework\TestCase {
 
                // Misc
                $this->assertEquals( 'ltr', $ctx->getDirection() );
-               $this->assertEquals( 'nl|fallback||||||||', $ctx->getHash() );
+               $this->assertEquals( 'qqx|fallback||||||||', $ctx->getHash() );
                $this->assertInstanceOf( User::class, $ctx->getUserObj() );
        }
 
index 4604ca3..93e0b87 100644 (file)
@@ -80,7 +80,8 @@ describe( 'Page', function () {
 
                // check
                assert.strictEqual( EditPage.heading.getText(), name );
-               assert( EditPage.displayedContent.getText().match( new RegExp( editContent ) ) );
+               // eslint-disable-next-line no-restricted-syntax
+               assert( EditPage.displayedContent.getText().includes( editContent ) );
        } );
 
        it( 'should have history @daily', function () {