Merge "Fix "Incorrect watchlist token provided" unit test errors"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 28 Sep 2016 04:46:54 +0000 (04:46 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 28 Sep 2016 04:46:54 +0000 (04:46 +0000)
includes/Defines.php
includes/resourceloader/ResourceLoaderWikiModule.php
tests/parser/ParserTestRunner.php

index 529dfb3..02930ea 100644 (file)
@@ -77,8 +77,13 @@ define( 'NS_CATEGORY_TALK', 15 );
  * When writing code that should be compatible with older MediaWiki
  * versions, either stick to the old names or define the new constants
  * yourself, if they're not defined already.
+ *
+ * @deprecated since 1.14
  */
 define( 'NS_IMAGE', NS_FILE );
+/**
+ * @deprecated since 1.14
+ */
 define( 'NS_IMAGE_TALK', NS_FILE_TALK );
 /**@}*/
 
index 4fdd86e..7cbec70 100644 (file)
@@ -305,7 +305,11 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                $titleInfo = [];
                $batch = new LinkBatch;
                foreach ( $pages as $titleText ) {
-                       $batch->addObj( Title::newFromText( $titleText ) );
+                       $title = Title::newFromText( $titleText );
+                       if ( $title ) {
+                               // Page name may be invalid if user-provided (e.g. gadgets)
+                               $batch->addObj( $title );
+                       }
                }
                if ( !$batch->isEmpty() ) {
                        $res = $db->select( 'page',
@@ -359,8 +363,16 @@ class ResourceLoaderWikiModule extends ResourceLoaderModule {
                        // Before we intersect, map the names to canonical form (T145673).
                        $intersect = [];
                        foreach ( $pages as $page => $unused ) {
-                               $title = Title::newFromText( $page )->getPrefixedText();
-                               $intersect[$title] = 1;
+                               $title = Title::newFromText( $page );
+                               if ( $title ) {
+                                       $intersect[ $title->getPrefixedText() ] = 1;
+                               } else {
+                                       // Page name may be invalid if user-provided (e.g. gadgets)
+                                       $rl->getLogger()->info(
+                                               'Invalid wiki page title "{title}" in ' . __METHOD__,
+                                               [ 'title' => $page ]
+                                       );
+                               }
                        }
                        $info = array_intersect_key( $allInfo, $intersect );
 
index 369cd0e..6ca851e 100644 (file)
@@ -1524,7 +1524,7 @@ class ParserTestRunner {
                }
 
                // The RepoGroup cache is invalidated by the creation of file redirects
-               if ( $title->getNamespace() === NS_IMAGE ) {
+               if ( $title->inNamespace( NS_FILE ) ) {
                        RepoGroup::singleton()->clearCache( $title );
                }
        }