Merge "Work around annoying Revision::newFromArchiveRow exception."
authorBrion VIBBER <brion@wikimedia.org>
Thu, 24 May 2012 18:48:38 +0000 (18:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 24 May 2012 18:48:38 +0000 (18:48 +0000)
19 files changed:
includes/Action.php
includes/AjaxDispatcher.php
includes/AjaxResponse.php
includes/Article.php
includes/AuthPlugin.php
includes/AutoLoader.php
includes/CategoryPage.php
includes/CategoryViewer.php
includes/ImageGallery.php
includes/OutputPage.php
includes/Skin.php
includes/SkinLegacy.php
includes/SkinTemplate.php
includes/api/ApiUpload.php
includes/job/JobQueue.php
includes/json/FormatJson.php
includes/resourceloader/ResourceLoaderWikiModule.php
includes/specials/SpecialTags.php
maintenance/populateRevisionSha1.php

index a8c0436..a9891ec 100644 (file)
  *
  * To add an action in an extension, create a subclass of Action, and add the key to
  * $wgActions.  There is also the deprecated UnknownAction hook
+ *
+ * Actions generally fall into two groups: the show-a-form-then-do-something-with-the-input
+ * format (protect, delete, move, etc), and the just-do-something format (watch, rollback,
+ * patrol, etc). The FormAction and FormlessAction classes respresent these two groups.
  */
 abstract class Action {
 
        /**
         * Page on which we're performing the action
-        * @var Page
+        * @var Page $page
         */
        protected $page;
 
        /**
         * IContextSource if specified; otherwise we'll use the Context from the Page
-        * @var IContextSource
+        * @var IContextSource $context
         */
        protected $context;
 
        /**
         * The fields used to create the HTMLForm
-        * @var Array
+        * @var Array $fields
         */
        protected $fields;
 
@@ -355,6 +359,9 @@ abstract class Action {
        public abstract function execute();
 }
 
+/**
+ * An action which shows a form and does something based on the input from the form
+ */
 abstract class FormAction extends Action {
 
        /**
@@ -449,8 +456,8 @@ abstract class FormAction extends Action {
        /**
         * @see Action::execute()
         * @throws ErrorPageError
-        * @param array|null $data
-        * @param bool $captureErrors
+        * @param $data array|null
+        * @param $captureErrors bool
         * @return bool
         */
        public function execute( array $data = null, $captureErrors = true ) {
@@ -491,9 +498,7 @@ abstract class FormAction extends Action {
 }
 
 /**
- * Actions generally fall into two groups: the show-a-form-then-do-something-with-the-input
- * format (protect, delete, move, etc), and the just-do-something format (watch, rollback,
- * patrol, etc).
+ * An action which just does something, without showing a form first.
  */
 abstract class FormlessAction extends Action {
 
@@ -512,10 +517,17 @@ abstract class FormlessAction extends Action {
                return false;
        }
 
+       /**
+        * @param $data Array
+        * @return bool
+        */
        public function onSubmit( $data ) {
                return false;
        }
 
+       /**
+        * @return bool
+        */
        public function onSuccess() {
                return false;
        }
index cafe4db..e3df520 100644 (file)
  * @ingroup Ajax
  */
 class AjaxDispatcher {
-       /** The way the request was made, either a 'get' or a 'post' */
+       /**
+        * The way the request was made, either a 'get' or a 'post'
+        * @var string $mode
+        */
        private $mode;
 
-       /** Name of the requested handler */
+       /**
+        * Name of the requested handler
+        * @var string $func_name
+        */
        private $func_name;
 
-       /** Arguments passed */
+       /** Arguments passed
+        * @var array $args
+        */
        private $args;
 
-       /** Load up our object with user supplied data */
+       /**
+        * Load up our object with user supplied data
+        */
        function __construct() {
                wfProfileIn( __METHOD__ );
 
@@ -80,7 +90,8 @@ class AjaxDispatcher {
                wfProfileOut( __METHOD__ );
        }
 
-       /** Pass the request to our internal function.
+       /**
+        * Pass the request to our internal function.
         * BEWARE! Data are passed as they have been supplied by the user,
         * they should be carefully handled in the function processing the
         * request.
index 52f3e2b..6bf94cc 100644 (file)
  * @ingroup Ajax
  */
 class AjaxResponse {
-       /** Number of seconds to get the response cached by a proxy */
+
+       /**
+        * Number of seconds to get the response cached by a proxy
+        * @var int $mCacheDuration
+        */
        private $mCacheDuration;
 
-       /** HTTP header Content-Type */
+       /**
+        * HTTP header Content-Type
+        * @var string $mContentType
+        */
        private $mContentType;
 
-       /** Disables output. Can be set by calling $AjaxResponse->disable() */
+       /**
+        * Disables output. Can be set by calling $AjaxResponse->disable()
+        * @var bool $mDisabled
+        */
        private $mDisabled;
 
-       /** Date for the HTTP header Last-modified */
+       /**
+        * Date for the HTTP header Last-modified
+        * @var string|false $mLastModified
+        */
        private $mLastModified;
 
-       /** HTTP response code */
+       /**
+        * HTTP response code
+        * @var string $mResponseCode
+        */
        private $mResponseCode;
 
-       /** HTTP Vary header */
+       /**
+        * HTTP Vary header
+        * @var string $mVary
+        */
        private $mVary;
 
-       /** Content of our HTTP response */
+       /**
+        * Content of our HTTP response
+        * @var string $mText
+        */
        private $mText;
 
        /**
@@ -67,22 +89,41 @@ class AjaxResponse {
                }
        }
 
+       /**
+        * Set the number of seconds to get the response cached by a proxy
+        * @param $duration int
+        */
        function setCacheDuration( $duration ) {
                $this->mCacheDuration = $duration;
        }
 
+       /**
+        * Set the HTTP Vary header
+        * @param $vary string
+        */
        function setVary( $vary ) {
                $this->mVary = $vary;
        }
 
+       /**
+        * Set the HTTP response code
+        * @param $code string
+        */
        function setResponseCode( $code ) {
                $this->mResponseCode = $code;
        }
 
+       /**
+        * Set the HTTP header Content-Type
+        * @param $type string
+        */
        function setContentType( $type ) {
                $this->mContentType = $type;
        }
 
+       /**
+        * Disable output.
+        */
        function disable() {
                $this->mDisabled = true;
        }
@@ -222,8 +263,8 @@ class AjaxResponse {
        }
 
        /**
-        * @param $mckey
-        * @param $touched
+        * @param $mckey string
+        * @param $touched int
         * @return bool
         */
        function loadFromMemcached( $mckey, $touched ) {
@@ -250,7 +291,7 @@ class AjaxResponse {
        }
 
        /**
-        * @param $mckey
+        * @param $mckey string
         * @param $expiry int
         * @return bool
         */
index a8df6c9..ded8c49 100644 (file)
@@ -25,7 +25,7 @@
  *
  * This maintains WikiPage functions for backwards compatibility.
  *
- * @TODO: move and rewrite code to an Action class
+ * @todo move and rewrite code to an Action class
  *
  * See design.txt for an overview.
  * Note: edit user interface and cache support functions have been
@@ -39,42 +39,69 @@ class Article extends Page {
         */
 
        /**
-        * @var IContextSource
+        * The context this Article is executed in
+        * @var IContextSource $mContext
         */
        protected $mContext;
 
        /**
-        * @var WikiPage
+        * The WikiPage object of this instance
+        * @var WikiPage $mPage
         */
        protected $mPage;
 
        /**
-        * @var ParserOptions: ParserOptions object for $wgUser articles
+        * ParserOptions object for $wgUser articles
+        * @var ParserOptions $mParserOptions
         */
        public $mParserOptions;
 
+       /**
+        * Content of the revision we are working on
+        * @var string $mContent
+        */
        var $mContent;                    // !<
+
+       /**
+        * Is the content ($mContent) already loaded?
+        * @var bool $mContentLoaded
+        */
        var $mContentLoaded = false;      // !<
+
+       /**
+        * The oldid of the article that is to be shown, 0 for the
+        * current revision
+        * @var int|null $mOldId
+        */
        var $mOldId;                      // !<
 
        /**
-        * @var Title
+        * Title from which we were redirected here
+        * @var Title $mRedirectedFrom
         */
        var $mRedirectedFrom = null;
 
        /**
-        * @var mixed: boolean false or URL string
+        * URL to redirect to or false if none
+        * @var string|false $mRedirectUrl
         */
        var $mRedirectUrl = false;        // !<
+
+       /**
+        * Revision ID of revision we are working on
+        * @var int $mRevIdFetched
+        */
        var $mRevIdFetched = 0;           // !<
 
        /**
-        * @var Revision
+        * Revision we are working on
+        * @var Revision $mRevision
         */
        var $mRevision = null;
 
        /**
-        * @var ParserOutput
+        * ParserOutput object
+        * @var ParserOutput $mParserOutput
         */
        var $mParserOutput;
 
@@ -809,7 +836,7 @@ class Article extends Page {
         * merging of several policies using array_merge().
         * @param $policy Mixed, returns empty array on null/false/'', transparent
         *            to already-converted arrays, converts String.
-        * @return Array: 'index' => <indexpolicy>, 'follow' => <followpolicy>
+        * @return Array: 'index' => \<indexpolicy\>, 'follow' => \<followpolicy\>
         */
        public static function formatRobotPolicy( $policy ) {
                if ( is_array( $policy ) ) {
@@ -1656,6 +1683,7 @@ class Article extends Page {
        /**
         * Handle action=purge
         * @deprecated since 1.19
+        * @return Action|bool|null false if the action is disabled, null if it is not recognised
         */
        public function purge() {
                return Action::factory( 'purge', $this )->show();
index 07a614a..e550473 100644 (file)
@@ -248,6 +248,8 @@ class AuthPlugin {
        /**
         * If you want to munge the case of an account name before the final
         * check, now is your chance.
+        * @param $username string
+        * @return string
         */
        public function getCanonicalName( $username ) {
                return $username;
index 0e891d7..11f44a8 100644 (file)
@@ -1066,6 +1066,7 @@ class AutoLoader {
         * Sanitizer that have define()s outside of their class definition. Of course
         * this wouldn't be necessary if everything in MediaWiki was class-based. Sigh.
         *
+        * @param $class string
         * @return Boolean Return the results of class_exists() so we know if we were successful
         */
        static function loadClass( $class ) {
index d7f78ec..32e270e 100644 (file)
@@ -21,9 +21,6 @@
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) )
-       die( 1 );
-
 /**
  * Special handling for category description pages, showing pages,
  * subcategories and file that belong to the category
index 553d64f..d83e0e0 100644 (file)
@@ -20,9 +20,6 @@
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) )
-       die( 1 );
-
 class CategoryViewer extends ContextSource {
        var $limit, $from, $until,
                $articles, $articles_start_char,
index 247acff..d391ead 100644 (file)
@@ -20,9 +20,6 @@
  * @file
  */
 
-if ( ! defined( 'MEDIAWIKI' ) )
-       die( 1 );
-
 /**
  * Image gallery
  *
index ad4e4ef..560588f 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 1 );
-}
-
 /**
  * This class should be covered by a general architecture document which does
  * not exist as of January 2011.  This is one of the Core classes and should
index 677664a..64cf569 100644 (file)
  * @defgroup Skins Skins
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 1 );
-}
-
 /**
  * The main skin class that provide methods and properties for all other skins.
  * This base class is also the "Standard" skin.
index 1deaf89..e1ec897 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 1 );
-}
-
 class SkinLegacy extends SkinTemplate {
        var $useHeadElement = true;
        protected $mWatchLinkNum = 0; // Appended to end of watch link id's
index 9807237..114a55c 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 1 );
-}
-
 /**
  * Wrapper object for MediaWiki's localization functions,
  * to be passed to the template engine.
index 9f5c5e3..e58a1ca 100644 (file)
@@ -117,25 +117,25 @@ class ApiUpload extends ApiBase {
         */
        private function getContextResult(){
                $warnings = $this->getApiWarnings();
-               if ( $warnings && !$this->mParams['ignorewarnings'] ) {
+               if ( $warnings ) {
                        // Get warnings formated in result array format
                        return $this->getWarningsResult( $warnings );
                } elseif ( $this->mParams['chunk'] ) {
                        // Add chunk, and get result
-                       return $this->getChunkResult( $warnings );
+                       return $this->getChunkResult();
                } elseif ( $this->mParams['stash'] ) {
                        // Stash the file and get stash result
-                       return $this->getStashResult( $warnings );
+                       return $this->getStashResult();
                }
                // This is the most common case -- a normal upload with no warnings
                // performUpload will return a formatted properly for the API with status
-               return $this->performUpload( $warnings );
+               return $this->performUpload();
        }
        /**
         * Get Stash Result, throws an expetion if the file could not be stashed.
         * @return array
         */
-       private function getStashResult( $warnings ){
+       private function getStashResult(){
                $result = array ();
                // Some uploads can request they be stashed, so as not to publish them immediately.
                // In this case, a failure to stash ought to be fatal
@@ -143,7 +143,6 @@ class ApiUpload extends ApiBase {
                        $result['result'] = 'Success';
                        $result['filekey'] = $this->performStash();
                        $result['sessionkey'] = $result['filekey']; // backwards compatibility
-                       $result['warnings'] = $warnings;
                } catch ( MWException $e ) {
                        $this->dieUsage( $e->getMessage(), 'stashfailed' );
                }
@@ -172,11 +171,10 @@ class ApiUpload extends ApiBase {
         * Get the result of a chunk upload.
         * @return array
         */
-       private function getChunkResult( $warnings ){
+       private function getChunkResult(){
                $result = array();
 
                $result['result'] = 'Continue';
-               $result['warnings'] = $warnings;
                $request = $this->getMain()->getRequest();
                $chunkPath = $request->getFileTempname( 'chunk' );
                $chunkSize = $request->getUpload( 'chunk' )->getSize();
@@ -455,8 +453,9 @@ class ApiUpload extends ApiBase {
        protected function getApiWarnings() {
                $warnings = array();
 
-               $warnings = $this->mUpload->checkWarnings();
-
+               if ( !$this->mParams['ignorewarnings'] ) {
+                       $warnings = $this->mUpload->checkWarnings();
+               }
                return $this->transformWarnings( $warnings );
        }
 
@@ -491,7 +490,7 @@ class ApiUpload extends ApiBase {
         *
         * @return array
         */
-       protected function performUpload( $warnings ) {
+       protected function performUpload() {
                // Use comment as initial page text by default
                if ( is_null( $this->mParams['text'] ) ) {
                        $this->mParams['text'] = $this->mParams['comment'];
@@ -530,7 +529,6 @@ class ApiUpload extends ApiBase {
 
                $result['result'] = 'Success';
                $result['filename'] = $file->getName();
-               $result['warnings'] = $warnings;
 
                return $result;
        }
index a53905f..0065247 100644 (file)
  * @defgroup JobQueue JobQueue
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( "This file is part of MediaWiki, it is not a valid entry point\n" );
-}
-
 /**
  * Class to both describe a background job and handle jobs.
  *
index 4ef59ed..cae3f12 100644 (file)
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 1 );
-}
-
 require_once dirname( __FILE__ ) . '/Services_JSON.php';
 
 /**
index a69676d..f35e774 100644 (file)
@@ -22,8 +22,6 @@
  * @author Roan Kattouw
  */
 
-defined( 'MEDIAWIKI' ) || die( 1 );
-
 /**
  * Abstraction for resource loader modules which pull from wiki pages
  *
index 1fc8ea5..df720a1 100644 (file)
@@ -21,9 +21,6 @@
  * @ingroup SpecialPage
  */
 
-if (!defined('MEDIAWIKI'))
-       die;
-
 /**
  * A special page that lists tags for edits
  *
index 2266a3f..d8ff749 100644 (file)
@@ -102,7 +102,8 @@ class PopulateRevisionSha1 extends LoggedUpdateMaintenance {
        protected function doSha1LegacyUpdates() {
                $count = 0;
                $db = $this->getDB( DB_MASTER );
-               $res = $db->select( 'archive', '*', array( 'ar_rev_id IS NULL' ), __METHOD__ );
+               $res = $db->select( 'archive', '*',
+                       array( 'ar_rev_id IS NULL', 'ar_sha1' => '' ), __METHOD__ );
 
                $updateSize = 0;
                $db->begin( __METHOD__ );