Merge "Prevents sidebar links from jumping on page load"
authorKaldari <rkaldari@wikimedia.org>
Wed, 2 May 2012 01:24:30 +0000 (01:24 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 2 May 2012 01:24:30 +0000 (01:24 +0000)
13 files changed:
RELEASE-NOTES-1.20
includes/Title.php
includes/WikiPage.php
includes/api/ApiBase.php
includes/api/ApiDelete.php
includes/api/ApiEditPage.php
includes/api/ApiImport.php
includes/api/ApiProtect.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryCategoryMembers.php
includes/api/ApiUndelete.php
includes/specials/SpecialWatchlist.php
tests/phpunit/includes/PreferencesTest.php

index bd8f775..1b35ad5 100644 (file)
@@ -46,6 +46,7 @@ production.
   Special:Version
 * Edit notices can now be translated.
 * (bug 22887) Add warning and tracking category for preprocessor errors
+* (bug 31704) Allow selection of associated namespace on the watchlist
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
@@ -101,6 +102,8 @@ production.
 * (bug 32492) API now allows editing using pageid
 * (bug 32497) API now allows changing of protection level using pageid
 * (bug 32498) API now allows comparing pages using pageids
+* (bug 30975) API import of pages with invalid characters in this wiki leads to Fatal Error
+* (bug 30488) API now allows listing of backlinks/embeddedin/imageusage per pageid
 
 === Languages updated in 1.20 ===
 
index 6764f8f..d26f71c 100644 (file)
@@ -83,6 +83,7 @@ class Title {
        var $mRedirect = null;            // /< Is the article at this title a redirect?
        var $mNotificationTimestamp = array(); // /< Associative array of user ID -> timestamp/false
        var $mBacklinkCache = null;       // /< Cache of links to this title
+       var $mHasSubpage;                 // /< Whether a page has any subpages
        // @}
 
 
@@ -119,7 +120,8 @@ class Title {
         *   fied by a prefix.  If you want to force a specific namespace even if
         *   $text might begin with a namespace prefix, use makeTitle() or
         *   makeTitleSafe().
-        * @return Title, or null on an error.
+        * @throws MWException
+        * @return Title|null - Title or null on an error.
         */
        public static function newFromText( $text, $defaultNamespace = NS_MAIN ) {
                if ( is_object( $text ) ) {
@@ -858,6 +860,7 @@ class Title {
         * This is MUCH simpler than individually testing for equivilance
         * against both NS_USER and NS_USER_TALK, and is also forward compatible.
         * @since 1.19
+        * @param $ns int
         * @return bool
         */
        public function hasSubjectNamespace( $ns ) {
@@ -1222,6 +1225,8 @@ class Title {
         * andthe wfArrayToCGI moved to getLocalURL();
         *
         * @since 1.19 (r105919)
+        * @param $query
+        * @param $query2 bool
         * @return String
         */
        private static function fixUrlQueryArgs( $query, $query2 = false ) {
@@ -1404,6 +1409,8 @@ class Title {
         * See getLocalURL for the arguments.
         *
         * @see self::getLocalURL
+        * @param $query string
+        * @param $query2 bool|string
         * @return String the URL
         */
        public function escapeLocalURL( $query = '', $query2 = false ) {
@@ -2468,8 +2475,9 @@ class Title {
        /**
         * Get the expiry time for the restriction against a given action
         *
+        * @param $action
         * @return String|Bool 14-char timestamp, or 'infinity' if the page is protected forever
-        *      or not protected at all, or false if the action is not recognised.
+        *     or not protected at all, or false if the action is not recognised.
         */
        public function getRestrictionExpiry( $action ) {
                if ( !$this->mRestrictionsLoaded ) {
@@ -4467,7 +4475,7 @@ class Title {
         * $wgLang (such as special pages, which are in the user language).
         *
         * @since 1.18
-        * @return object Language
+        * @return Language
         */
        public function getPageLanguage() {
                global $wgLang;
index 2678f54..42ba690 100644 (file)
@@ -1718,7 +1718,7 @@ class WikiPage extends Page {
         * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
         * @param $expiry Array: per restriction type expiration
         * @param $user User The user updating the restrictions
-        * @return bool true on success
+        * @return Status
         */
        public function doUpdateRestrictions( array $limit, array $expiry, &$cascade, $reason, User $user ) {
                global $wgContLang;
index 1103814..fc2ef77 100644 (file)
@@ -723,8 +723,14 @@ abstract class ApiBase extends ContextSource {
        /**
         * @return array
         */
-       public function getTitleOrPageIdErrorMessage( ) {
-               return $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) );
+       public function getTitleOrPageIdErrorMessage() {
+               return array_merge(
+                       $this->getRequireOnlyOneParameterErrorMessages( array( 'title', 'pageid' ) ),
+                       array(
+                               array( 'invalidtitle', 'title' ),
+                               array( 'nosuchpageid', 'pageid' ),
+                       )
+               );
        }
 
        /**
index 15c1f82..21e7b80 100644 (file)
@@ -230,8 +230,6 @@ class ApiDelete extends ApiBase {
                return array_merge( parent::getPossibleErrors(),
                        $this->getTitleOrPageIdErrorMessage(),
                        array(
-                               array( 'invalidtitle', 'title' ),
-                               array( 'nosuchpageid', 'pageid' ),
                                array( 'notanarticle' ),
                                array( 'hookaborted', 'error' ),
                                array( 'delete-toobig', 'limit' ),
index b45f351..11f4757 100644 (file)
@@ -371,9 +371,7 @@ class ApiEditPage extends ApiBase {
                return array_merge( parent::getPossibleErrors(),
                        $this->getTitleOrPageIdErrorMessage(),
                        array(
-                               array( 'nosuchpageid', 'pageid' ),
                                array( 'missingtext' ),
-                               array( 'invalidtitle', 'title' ),
                                array( 'createonly-exists' ),
                                array( 'nocreate-missing' ),
                                array( 'nosuchrevid', 'undo' ),
index ade9f1f..5093b6b 100644 (file)
@@ -186,8 +186,16 @@ class ApiImportReporter extends ImportReporter {
        function reportPage( $title, $origTitle, $revisionCount, $successCount, $pageInfo ) {
                // Add a result entry
                $r = array();
-               ApiQueryBase::addTitleInfo( $r, $title );
-               $r['revisions'] = intval( $successCount );
+
+               if ( $title === null ) {\r
+                       # Invalid or non-importable title
+                       $r['title'] = $pageInfo['title'];
+                       $r['invalid'] = '';\r
+               } else {\r
+                       ApiQueryBase::addTitleInfo( $r, $title );
+                       $r['revisions'] = intval( $successCount );
+               }
+
                $this->mResultArr[] = $r;
 
                // Piggyback on the parent to do the logging
index 57bf111..97e79ff 100644 (file)
@@ -192,8 +192,6 @@ class ApiProtect extends ApiBase {
                return array_merge( parent::getPossibleErrors(),
                        $this->getTitleOrPageIdErrorMessage(),
                        array(
-                               array( 'invalidtitle', 'title' ),
-                               array( 'nosuchpageid', 'pageid' ),
                                array( 'toofewexpiries', 'noofexpiries', 'noofprotections' ),
                                array( 'create-titleexists' ),
                                array( 'missingtitle-createonly' ),
index 381ef55..bf9aa3d 100644 (file)
@@ -369,14 +369,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                if ( !is_null( $this->params['continue'] ) ) {
                        $this->parseContinueParam();
                } else {
-                       if ( $this->params['title'] !== '' ) {
-                               $title = Title::newFromText( $this->params['title'] );
-                               if ( !$title ) {
-                                       $this->dieUsageMsg( array( 'invalidtitle', $this->params['title'] ) );
-                               } else {
-                                       $this->rootTitle = $title;
-                               }
-                       }
+                       $this->rootTitle = $this->getTitleOrPageId( $this->params );
                }
 
                // only image titles are allowed for the root in imageinfo mode
@@ -436,7 +429,9 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                $retval = array(
                        'title' => array(
                                ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
+                       ),
+                       'pageid' => array(
+                               ApiBase::PARAM_TYPE => 'integer',
                        ),
                        'continue' => null,
                        'namespace' => array(
@@ -468,7 +463,8 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
 
        public function getParamDescription() {
                $retval = array(
-                       'title' => 'Title to search',
+                       'title' => "Title to search. Cannot be used together with {$this->bl_code}pageid",
+                       'pageid' => "Pageid to search. Cannot be used together with {$this->bl_code}title",
                        'continue' => 'When more results are available, use this to continue',
                        'namespace' => 'The namespace to enumerate',
                );
@@ -499,11 +495,13 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
        }
 
        public function getPossibleErrors() {
-               return array_merge( parent::getPossibleErrors(), array(
-                       array( 'invalidtitle', 'title' ),
-                       array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ),
-                       array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
-               ) );
+               return array_merge( parent::getPossibleErrors(),
+                       $this->getTitleOrPageIdErrorMessage(),
+                       array(
+                               array( 'code' => 'bad_image_title', 'info' => "The title for {$this->getModuleName()} query must be an image" ),
+                               array( 'code' => '_badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
+                       )
+               );
        }
 
        public function getExamples() {
index 7f0b827..8fff94d 100644 (file)
@@ -374,7 +374,6 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                        array(
                                array( 'code' => 'invalidcategory', 'info' => 'The category name you entered is not valid' ),
                                array( 'code' => 'badcontinue', 'info' => 'Invalid continue param. You should pass the original value returned by the previous query' ),
-                               array( 'nosuchpageid', 'pageid' ),
                        )
                );
        }
index d342997..856e2ac 100644 (file)
@@ -76,7 +76,7 @@ class ApiUndelete extends ApiBase {
                $info['title'] = $titleObj->getPrefixedText();
                $info['revisions'] = intval( $retval[0] );
                $info['fileversions'] = intval( $retval[1] );
-               $info['reason'] = intval( $retval[2] );
+               $info['reason'] = $retval[2];
                $this->getResult()->addValue( null, $this->getModuleName(), $info );
        }
 
index e0f2ff2..eafdde4 100644 (file)
@@ -116,6 +116,7 @@ class SpecialWatchlist extends SpecialPage {
                /* bool  */ 'hideOwn'   => (int)$user->getBoolOption( 'watchlisthideown' ),
                /* ?     */ 'namespace' => 'all',
                /* ?     */ 'invert'    => false,
+               /* bool  */ 'associated' => false,
                );
                $this->customFilters = array();
                wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
@@ -148,13 +149,20 @@ class SpecialWatchlist extends SpecialPage {
 
                # Get namespace value, if supplied, and prepare a WHERE fragment
                $nameSpace = $request->getIntOrNull( 'namespace' );
-               $invert = $request->getIntOrNull( 'invert' );
+               $invert = $request->getBool( 'invert' );
+               $associated = $request->getBool( 'associated' );
                if ( !is_null( $nameSpace ) ) {
+                       $eq_op = $invert ? '!=' : '=';\r
+                       $bool_op = $invert ? 'AND' : 'OR';
                        $nameSpace = intval( $nameSpace ); // paranioa
-                       if ( $invert ) {
-                               $nameSpaceClause = "rc_namespace != $nameSpace";
+                       if ( !$associated ) {
+                               $nameSpaceClause = "rc_namespace $eq_op $nameSpace";
                        } else {
-                               $nameSpaceClause = "rc_namespace = $nameSpace";
+                               $associatedNS = MWNamespace::getAssociated( $nameSpace );\r
+                               $nameSpaceClause =
+                                       "rc_namespace $eq_op $nameSpace " .\r
+                                       $bool_op .\r
+                                       " rc_namespace $eq_op $associatedNS";
                        }
                } else {
                        $nameSpace = '';
@@ -162,6 +170,7 @@ class SpecialWatchlist extends SpecialPage {
                }
                $values['namespace'] = $nameSpace;
                $values['invert'] = $invert;
+               $values['associated'] = $associated;
 
                if( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
                        $big = 1000; /* The magical big */
@@ -345,7 +354,20 @@ class SpecialWatchlist extends SpecialPage {
                                'class' => 'namespaceselector',
                        )
                ) . '&#160;';
-               $form .= Xml::checkLabel( $this->msg( 'invert' )->text(), 'invert', 'nsinvert', $invert ) . '&#160;';
+               $form .= Xml::checkLabel(
+                       $this->msg( 'invert' )->text(),
+                       'invert',
+                       'nsinvert',
+                       $invert,
+                       array( 'title' => $this->msg( 'tooltip-invert' )->text() )
+               ) . '&#160;';
+               $form .= Xml::checkLabel(
+                       $this->msg( 'namespace_association' )->text(),
+                       'associated',
+                       'associated',
+                       $associated,
+                       array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
+               ) . '&#160;';
                $form .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . '</p>';
                $form .= Html::hidden( 'days', $values['days'] );
                foreach ( $filters as $key => $msg ) {
index 89d9e0c..664f04a 100644 (file)
@@ -8,6 +8,7 @@ class PreferencesTest extends MediaWikiTestCase {
 
        function __construct() {
                parent::__construct();
+               global $wgEnableEmail;
 
                $this->users['noemail'] = new User;
 
@@ -23,6 +24,9 @@ class PreferencesTest extends MediaWikiTestCase {
 
                $this->context = new RequestContext;
                $this->context->setTitle( Title::newFromText('PreferencesTest') );
+
+               //some tests depends on email setting
+               $wgEnableEmail = true;
        }
 
        /**