Merge "Add plural to message 'rcnotefrom'"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 25 Jul 2014 17:52:19 +0000 (17:52 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 25 Jul 2014 17:52:19 +0000 (17:52 +0000)
114 files changed:
includes/AutoLoader.php
includes/exception/BadTitleError.php
includes/exception/ErrorPageError.php
includes/externalstore/ExternalStore.php
includes/filebackend/FSFile.php
includes/filebackend/FSFileBackend.php
includes/filebackend/FileBackendStore.php
includes/filebackend/SwiftFileBackend.php
includes/filebackend/filejournal/FileJournal.php
includes/filebackend/lockmanager/LockManagerGroup.php
includes/filebackend/lockmanager/MemcLockManager.php
includes/filebackend/lockmanager/RedisLockManager.php
includes/filerepo/FileRepo.php
includes/filerepo/LocalRepo.php
includes/filerepo/RepoGroup.php
includes/filerepo/file/ArchivedFile.php
includes/filerepo/file/File.php
includes/filerepo/file/LocalFile.php
includes/filerepo/file/OldLocalFile.php
includes/gallery/PackedImageGallery.php
includes/htmlform/HTMLForm.php
includes/htmlform/HTMLFormField.php
includes/installer/Installer.php
includes/installer/WebInstaller.php
includes/installer/WebInstallerPage.php
includes/interwiki/Interwiki.php
includes/jobqueue/Job.php
includes/jobqueue/JobRunner.php [new file with mode: 0644]
includes/jobqueue/jobs/DuplicateJob.php
includes/jobqueue/jobs/NullJob.php
includes/jobqueue/jobs/UploadFromUrlJob.php
includes/logging/LogFormatter.php
includes/logging/LogPage.php
includes/media/BitmapMetadataHandler.php
includes/media/DjVuImage.php
includes/media/Exif.php
includes/media/FormatMetadata.php
includes/media/IPTC.php
includes/media/Jpeg.php
includes/media/JpegMetadataExtractor.php
includes/media/MediaHandler.php
includes/media/MediaTransformOutput.php
includes/media/PNG.php
includes/media/PNGMetadataExtractor.php
includes/media/SVG.php
includes/media/XCF.php
includes/media/XMP.php
includes/objectcache/BagOStuff.php
includes/objectcache/WinCacheBagOStuff.php
includes/page/Article.php
includes/page/ImagePage.php
includes/page/WikiPage.php
includes/parser/DateFormatter.php
includes/parser/LinkHolderArray.php
includes/parser/Parser.php
includes/parser/ParserCache.php
includes/parser/ParserOptions.php
includes/parser/ParserOutput.php
includes/parser/Preprocessor_Hash.php
includes/poolcounter/PoolCounter.php
includes/profiler/Profiler.php
includes/profiler/ProfilerMwprof.php
includes/profiler/ProfilerStandard.php
includes/rcfeed/RCFeedEngine.php
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderLanguageNamesModule.php
includes/resourceloader/ResourceLoaderModule.php
includes/resourceloader/ResourceLoaderStartUpModule.php
includes/revisiondelete/RevisionDeleter.php
includes/search/SearchHighlighter.php
includes/search/SearchResult.php
includes/site/SiteList.php
includes/specialpage/SpecialPage.php
includes/specials/SpecialAllPages.php
includes/specials/SpecialBlock.php
includes/specials/SpecialChangePassword.php
includes/specials/SpecialEditWatchlist.php
includes/specials/SpecialEmailuser.php
includes/specials/SpecialExpandTemplates.php
includes/specials/SpecialExport.php
includes/specials/SpecialFileDuplicateSearch.php
includes/specials/SpecialJavaScriptTest.php
includes/specials/SpecialListgrouprights.php
includes/specials/SpecialListusers.php
includes/specials/SpecialLog.php
includes/specials/SpecialMergeHistory.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialMyLanguage.php
includes/specials/SpecialPageLanguage.php
includes/specials/SpecialPagesWithProp.php
includes/specials/SpecialRandomInCategory.php
includes/specials/SpecialRedirect.php
includes/specials/SpecialRevisiondelete.php
includes/specials/SpecialRunJobs.php
includes/specials/SpecialSearch.php
includes/specials/SpecialUpload.php
includes/specials/SpecialUploadStash.php
includes/specials/SpecialUserlogin.php
includes/specials/SpecialUserrights.php
includes/specials/SpecialVersion.php
includes/specials/SpecialWatchlist.php
includes/title/MediaWikiPageLinkRenderer.php
includes/title/MediaWikiTitleCodec.php
includes/title/PageLinkRenderer.php
includes/title/TitleFormatter.php
includes/title/TitleParser.php
includes/upload/UploadBase.php
includes/upload/UploadFromChunks.php
includes/upload/UploadStash.php
includes/utils/ArrayUtils.php
languages/i18n/en.json
languages/i18n/qqq.json
maintenance/runJobs.php

index 079cbd8..f35b380 100644 (file)
@@ -639,6 +639,7 @@ $wgAutoloadLocalClasses = array(
        'JobQueueGroup' => 'includes/jobqueue/JobQueueGroup.php',
        'JobQueueFederated' => 'includes/jobqueue/JobQueueFederated.php',
        'JobQueueRedis' => 'includes/jobqueue/JobQueueRedis.php',
+       'JobRunner' => 'includes/jobqueue/JobRunner.php',
        'JobSpecification' => 'includes/jobqueue/JobSpecification.php',
 
        # includes/jobqueue/jobs
index 2da3775..e62f8bd 100644 (file)
@@ -29,7 +29,7 @@
 class BadTitleError extends ErrorPageError {
        /**
         * @param string|Message $msg A message key (default: 'badtitletext')
-        * @param array $params parameter to wfMessage()
+        * @param array $params Parameter to wfMessage()
         */
        public function __construct( $msg = 'badtitletext', $params = array() ) {
                parent::__construct( 'badtitle', $msg, $params );
index 7cd198b..3631a34 100644 (file)
@@ -32,7 +32,7 @@ class ErrorPageError extends MWException {
         *
         * @param string|Message $title Message key (string) for page title, or a Message object
         * @param string|Message $msg Message key (string) for error text, or a Message object
-        * @param array $params with parameters to wfMessage()
+        * @param array $params Array with parameters to wfMessage()
         */
        public function __construct( $title, $msg, $params = array() ) {
                $this->title = $title;
index 9e09b22..688130e 100644 (file)
@@ -178,7 +178,7 @@ class ExternalStore {
         * itself. It also fails-over to the next possible clusters
         * as provided in the first parameter.
         *
-        * @param array $tryStores refer to $wgDefaultExternalStore
+        * @param array $tryStores Refer to $wgDefaultExternalStore
         * @param string $data
         * @param array $params Associative array of ExternalStoreMedium parameters
         * @return string|bool The URL of the stored data item, or false on error
index 4575e7c..29fa875 100644 (file)
@@ -237,7 +237,7 @@ class FSFile {
        /**
         * Get an associative array containing information about a file in the local filesystem.
         *
-        * @param string $path absolute local filesystem path
+        * @param string $path Absolute local filesystem path
         * @param mixed $ext The file extension, or true to extract it from the filename.
         *   Set it to false to ignore the extension.
         * @return array
index 2b0c3c2..b99ffb6 100644 (file)
@@ -828,7 +828,7 @@ abstract class FSFileBackendList implements Iterator {
        protected $params = array();
 
        /**
-        * @param string $dir file system directory
+        * @param string $dir File system directory
         * @param array $params
         */
        public function __construct( $dir, array $params ) {
@@ -849,7 +849,7 @@ abstract class FSFileBackendList implements Iterator {
        /**
         * Return an appropriate iterator object to wrap
         *
-        * @param string $dir file system directory
+        * @param string $dir File system directory
         * @return Iterator
         */
        protected function initIterator( $dir ) {
index 631d949..495ac3c 100644 (file)
@@ -1819,7 +1819,7 @@ abstract class FileBackendStore extends FileBackend {
         * @param string $storagePath
         * @param string|null $content File data
         * @param string|null $fsPath File system path
-        * @return MIME type
+        * @return string MIME type
         */
        protected function getContentType( $storagePath, $content, $fsPath ) {
                return call_user_func_array( $this->mimeCallback, func_get_args() );
index 9af53c3..e9c8883 100644 (file)
@@ -1791,7 +1791,7 @@ abstract class SwiftFileBackendList implements Iterator {
         *
         * @param string $container Resolved container name
         * @param string $dir Resolved path relative to container
-        * @param string $after null
+        * @param string $after
         * @param int $limit
         * @param array $params
         * @return Traversable|array
index 20c7c35..c065148 100644 (file)
@@ -132,7 +132,7 @@ abstract class FileJournal {
        /**
         * Get the position ID of the latest journal entry at some point in time
         *
-        * @param int|string $time timestamp
+        * @param int|string $time Timestamp
         * @return int|bool
         */
        final public function getPositionAtTime( $time ) {
@@ -224,7 +224,7 @@ class NullFileJournal extends FileJournal {
 
        /**
         * @see FileJournal::doGetPositionAtTime()
-        * @param int|string $time timestamp
+        * @param int|string $time Timestamp
         * @return int|bool
         */
        protected function doGetPositionAtTime( $time ) {
index ecf396a..19fc4fe 100644 (file)
@@ -34,7 +34,7 @@ class LockManagerGroup {
 
        protected $domain; // string; domain (usually wiki ID)
 
-       /** @var array of (name => ('class' => ..., 'config' => ..., 'instance' => ...)) */
+       /** @var array Array of (name => ('class' => ..., 'config' => ..., 'instance' => ...)) */
        protected $managers = array();
 
        /**
index f7ffb2d..9bb01c2 100644 (file)
@@ -49,7 +49,7 @@ class MemcLockManager extends QuorumLockManager {
        /** @var array (server name => bool) */
        protected $serversUp = array();
 
-       /** @var string random UUID */
+       /** @var string Random UUID */
        protected $session = '';
 
        /**
index ff4cba5..90e0581 100644 (file)
@@ -51,7 +51,7 @@ class RedisLockManager extends QuorumLockManager {
        /** @var array Map server names to hostname/IP and port numbers */
        protected $lockServers = array();
 
-       /** @var string random UUID */
+       /** @var string Random UUID */
        protected $session = '';
 
        /**
index 8598005..a45fb7a 100644 (file)
@@ -1055,7 +1055,7 @@ class FileRepo {
         * Returns a FileRepoStatus object with the file Virtual URL in the value,
         * file can later be disposed using FileRepo::freeTemp().
         *
-        * @param string $originalName the base name of the file as specified
+        * @param string $originalName The base name of the file as specified
         *   by the user. The file extension will be maintained.
         * @param string $srcPath The current location of the file.
         * @return FileRepoStatus Object with the URL in the value.
index 3f7adb0..96c8803 100644 (file)
@@ -369,7 +369,7 @@ class LocalRepo extends FileRepo {
         * Get an array or iterator of file objects for files that have a given
         * SHA-1 content hash.
         *
-        * @param string $hash a sha1 hash to look for
+        * @param string $hash A sha1 hash to look for
         * @return array
         */
        function findBySha1( $hash ) {
index 65637df..fce3f78 100644 (file)
@@ -272,7 +272,7 @@ class RepoGroup {
        /**
         * Find all instances of files with this key
         *
-        * @param string $hash base 36 SHA-1 hash
+        * @param string $hash Base 36 SHA-1 hash
         * @return array Array of File objects
         */
        function findBySha1( $hash ) {
@@ -292,7 +292,7 @@ class RepoGroup {
        /**
         * Find all instances of files with this keys
         *
-        * @param array $hashes base 36 SHA-1 hashes
+        * @param array $hashes Base 36 SHA-1 hashes
         * @return array Array of array of File objects
         */
        function findBySha1s( array $hashes ) {
@@ -420,7 +420,7 @@ class RepoGroup {
         * Split a virtual URL into repo, zone and rel parts
         * @param string $url
         * @throws MWException
-        * @return array containing repo, zone and rel
+        * @return array Containing repo, zone and rel
         */
        function splitVirtualUrl( $url ) {
                if ( substr( $url, 0, 9 ) != 'mwrepo://' ) {
index 1eee6a2..735bf8a 100644 (file)
@@ -27,7 +27,7 @@
  * @ingroup FileAbstraction
  */
 class ArchivedFile {
-       /** @var int filearchive row ID */
+       /** @var int Filearchive row ID */
        private $id;
 
        /** @var string File name */
@@ -42,7 +42,7 @@ class ArchivedFile {
        /** @var int File size in bytes */
        private $size;
 
-       /** @var int size in bytes */
+       /** @var int Size in bytes */
        private $bits;
 
        /** @var int Width */
index 260fde1..32374cd 100644 (file)
@@ -127,7 +127,7 @@ abstract class File {
        /** @var string Relative path including trailing slash */
        protected $hashPath;
 
-       /** @var string number of pages of a multipage document, or false for
+       /** @var string Number of pages of a multipage document, or false for
         *    documents which aren't multipage documents
         */
        protected $pageCount;
@@ -583,7 +583,7 @@ abstract class File {
         *
         * Currently used to add a warning to the image description page
         *
-        * @return bool false if the main image is both animated
+        * @return bool False if the main image is both animated
         *   and the thumbnail is not. In all other cases must return
         *   true. If image is not renderable whatsoever, should
         *   return true.
@@ -1189,7 +1189,7 @@ abstract class File {
        /**
         * Returns the most appropriate source image for the thumbnail, given a target thumbnail size
         * @param array $params
-        * @return array source path and width/height of the source
+        * @return array Source path and width/height of the source
         */
        public function getThumbnailSource( $params ) {
                if ( $this->repo
@@ -1606,7 +1606,7 @@ abstract class File {
         *
         * @param string $zone Name of requested zone
         * @param bool|string $suffix If not false, the name of a file in zone
-        * @return string path
+        * @return string Path
         */
        function getZoneUrl( $zone, $suffix = false ) {
                $this->assertRepoDefined();
@@ -1623,7 +1623,7 @@ abstract class File {
         * Get the URL of the thumbnail directory, or a particular file if $suffix is specified
         *
         * @param bool|string $suffix If not false, the name of a thumbnail file
-        * @return string path
+        * @return string Path
         */
        function getThumbUrl( $suffix = false ) {
                return $this->getZoneUrl( 'thumb', $suffix );
@@ -1633,7 +1633,7 @@ abstract class File {
         * Get the URL of the transcoded directory, or a particular file if $suffix is specified
         *
         * @param bool|string $suffix If not false, the name of a media file
-        * @return string path
+        * @return string Path
         */
        function getTranscodedUrl( $suffix = false ) {
                return $this->getZoneUrl( 'transcoded', $suffix );
@@ -1741,7 +1741,7 @@ abstract class File {
         * @param int $flags A bitwise combination of:
         *   File::DELETE_SOURCE    Delete the source file, i.e. move rather than copy
         * @param array $options Optional additional parameters
-        * @return FileRepoStatus object. On success, the value member contains the
+        * @return FileRepoStatus On success, the value member contains the
         *   archive name, or an empty string if it was a new file.
         *
         * STUB
index 1f2defe..1eff1df 100644 (file)
@@ -49,10 +49,10 @@ class LocalFile extends File {
        /** @var bool Does the file exist on disk? (loadFromXxx) */
        protected $fileExists;
 
-       /** @var int image width */
+       /** @var int Image width */
        protected $width;
 
-       /** @var int image height */
+       /** @var int Image height */
        protected $height;
 
        /** @var int Returned by getimagesize (loadFromXxx) */
@@ -166,7 +166,7 @@ class LocalFile extends File {
         * Create a LocalFile from a SHA-1 key
         * Do not call this except from inside a repo class.
         *
-        * @param string $sha1 base-36 SHA-1
+        * @param string $sha1 Base-36 SHA-1
         * @param LocalRepo $repo
         * @param string|bool $timestamp MW_timestamp (optional)
         * @return bool|LocalFile
@@ -437,7 +437,7 @@ class LocalFile extends File {
        /**
         * @param DatabaseBase $dbr
         * @param string $fname
-        * @return array|false
+        * @return array|bool
         */
        private function loadFieldsWithTimestamp( $dbr, $fname ) {
                $fieldMap = false;
@@ -833,7 +833,7 @@ class LocalFile extends File {
        /**
         * Get all thumbnail names previously generated for this file
         * @param string|bool $archiveName Name of an archive file, default false
-        * @return array first element is the base dir, then files in that base dir.
+        * @return array First element is the base dir, then files in that base dir.
         */
        function getThumbnails( $archiveName = false ) {
                if ( $archiveName ) {
@@ -1848,7 +1848,7 @@ class LocalFile extends File {
         * Start a transaction and lock the image for update
         * Increments a reference counter if the lock is already held
         * @throws MWException Throws an error if the lock was not acquired
-        * @return bool success
+        * @return bool Success
         */
        function lock() {
                $dbw = $this->repo->getMasterDB();
index ca92496..0adcc73 100644 (file)
@@ -79,7 +79,7 @@ class OldLocalFile extends LocalFile {
         * Create a OldLocalFile from a SHA-1 key
         * Do not call this except from inside a repo class.
         *
-        * @param string $sha1 base-36 SHA-1
+        * @param string $sha1 Base-36 SHA-1
         * @param LocalRepo $repo
         * @param string|bool $timestamp MW_timestamp (optional)
         *
@@ -130,7 +130,7 @@ class OldLocalFile extends LocalFile {
         * @param Title $title
         * @param FileRepo $repo
         * @param string $time Timestamp or null to load by archive name
-        * @param string $archiveName archive name or null to load by timestamp
+        * @param string $archiveName Archive name or null to load by timestamp
         * @throws MWException
         */
        function __construct( $title, $repo, $time, $archiveName ) {
index bb55c89..b004a95 100644 (file)
@@ -76,7 +76,7 @@ class PackedImageGallery extends TraditionalImageGallery {
        }
 
        /**
-        * @param MediaTransformOutput|bool $thumb the thumbnail, or false if no
+        * @param MediaTransformOutput|bool $thumb The thumbnail, or false if no
         *   thumb (which can happen)
         * @return float
         */
index df6582c..d7c5d7f 100644 (file)
@@ -352,7 +352,7 @@ class HTMLForm extends ContextSource {
         * @param array $descriptor Input Descriptor, as described above
         *
         * @throws MWException
-        * @return HTMLFormField subclass
+        * @return HTMLFormField Instance of a subclass of HTMLFormField
         */
        public static function loadInputFromParameters( $fieldname, $descriptor ) {
                $class = self::getClassFromDescriptor( $fieldname, $descriptor );
@@ -622,7 +622,7 @@ class HTMLForm extends ContextSource {
        /**
         * Add footer text, inside the form.
         *
-        * @param string $msg complete text of message to display
+        * @param string $msg Complete text of message to display
         * @param string|null $section The section to add the footer text to
         *
         * @return HTMLForm $this for chaining calls (since 1.20)
@@ -741,8 +741,8 @@ class HTMLForm extends ContextSource {
         * Only useful when the method is "post".
         *
         * @since 1.24
-        * @param string|array Salt to use
-        * @return HTMLForm $this for chaining calls
+        * @param string|array $salt Salt to use
+        * @return HTMLForm $this For chaining calls
         */
        public function setTokenSalt( $salt ) {
                $this->mTokenSalt = $salt;
@@ -760,7 +760,7 @@ class HTMLForm extends ContextSource {
         *
         * @param bool|string|array|Status $submitResult Output from HTMLForm::trySubmit()
         *
-        * @return Nothing, should be last call
+        * @return void Nothing, should be last call
         */
        function displayForm( $submitResult ) {
                $this->getOutput()->addHTML( $this->getHTML( $submitResult ) );
@@ -980,7 +980,7 @@ class HTMLForm extends ContextSource {
        /**
         * Format a stack of error messages into a single HTML string
         *
-        * @param array $errors of message keys/values
+        * @param array $errors Array of message keys/values
         *
         * @return string HTML, a "<ul>" list of errors
         */
@@ -1010,7 +1010,7 @@ class HTMLForm extends ContextSource {
        /**
         * Set the text for the submit button
         *
-        * @param string $t plaintext.
+        * @param string $t Plaintext
         *
         * @return HTMLForm $this for chaining calls (since 1.20)
         */
@@ -1370,7 +1370,7 @@ class HTMLForm extends ContextSource {
         *
         * @param array $data
         *
-        * @return
+        * @return array
         */
        function filterDataForSubmit( $data ) {
                return $data;
index 1fcc866..7e4b15b 100644 (file)
@@ -35,7 +35,7 @@ abstract class HTMLFormField {
         * the input object itself.  It should not implement the surrounding
         * table cells/rows, or labels/help messages.
         *
-        * @param string $value the value to set the input to; eg a default
+        * @param string $value The value to set the input to; eg a default
         *     text for a text input.
         *
         * @return string Valid HTML.
@@ -125,7 +125,7 @@ abstract class HTMLFormField {
         *
         * @param array $alldata
         * @param array $params
-        * @return boolean
+        * @return bool
         */
        protected function isHiddenRecurse( array $alldata, array $params ) {
                $origParams = $params;
@@ -250,7 +250,7 @@ abstract class HTMLFormField {
         * @param string|array $value The value the field was submitted with
         * @param array $alldata The data collected from the form
         *
-        * @return bool true to cancel the submission
+        * @return bool True to cancel the submission
         */
        function cancelSubmit( $value, $alldata ) {
                return false;
@@ -264,7 +264,7 @@ abstract class HTMLFormField {
         * @param string|array $value The value the field was submitted with
         * @param array $alldata The data collected from the form
         *
-        * @return bool|string true on success, or String error to display, or
+        * @return bool|string True on success, or String error to display, or
         *   false to fail validation without displaying an error.
         */
        function validate( $value, $alldata ) {
index 3372119..28304c2 100644 (file)
@@ -1274,8 +1274,8 @@ abstract class Installer {
         *
         * Used only by environment checks.
         *
-        * @param string $path path to search
-        * @param array $names of executable names
+        * @param string $path Path to search
+        * @param array $names Array of executable names
         * @param array|bool $versionInfo False or array with two members:
         *   0 => Command to run for version check, with $1 for the full executable name
         *   1 => String to compare the output with
index a6e9e33..68c2ebe 100644 (file)
@@ -148,7 +148,7 @@ class WebInstaller extends Installer {
        /**
         * Main entry point.
         *
-        * @param array[] $session initial session array
+        * @param array[] $session Initial session array
         *
         * @return array[] New session array
         */
index 1c3be75..9fdee76 100644 (file)
@@ -164,7 +164,7 @@ abstract class WebInstallerPage {
        /**
         * Get the starting tags of a fieldset.
         *
-        * @param string $legend message name
+        * @param string $legend Message name
         *
         * @return string
         */
index 09283f2..55b2506 100644 (file)
@@ -45,7 +45,7 @@ class Interwiki {
         */
        protected $mWikiID;
 
-       /** @var bool whether the wiki is in this project */
+       /** @var bool Whether the wiki is in this project */
        protected $mLocal;
 
        /** @var bool Whether interwiki transclusions are allowed */
@@ -118,7 +118,7 @@ class Interwiki {
         * @note More logic is explained in DefaultSettings.
         *
         * @param string $prefix Interwiki prefix
-        * @return Interwiki object
+        * @return Interwiki
         */
        protected static function getInterwikiCached( $prefix ) {
                $value = self::getInterwikiCacheEntry( $prefix );
index c11df93..ee3f2c2 100644 (file)
@@ -279,7 +279,7 @@ abstract class Job implements IJobSpecification {
 
        /**
         * Insert a single job into the queue.
-        * @return bool true on success
+        * @return bool True on success
         * @deprecated since 1.21
         */
        public function insert() {
diff --git a/includes/jobqueue/JobRunner.php b/includes/jobqueue/JobRunner.php
new file mode 100644 (file)
index 0000000..0f585c7
--- /dev/null
@@ -0,0 +1,293 @@
+<?php
+/**
+ * Job queue runner utility methods
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup JobQueue
+ */
+
+/**
+ * Job queue runner utility methods
+ *
+ * @ingroup JobQueue
+ * @since 1.24
+ */
+class JobRunner {
+       /** @var callable|null Debug output handler */
+       protected $debug;
+
+       /**
+        * @param callable $debug Optional debug output handler
+        */
+       public function setDebugHandler( $debug ) {
+               $this->debug = $debug;
+       }
+
+       /**
+        * Run jobs of the specified number/type for the specified time
+        *
+        * The response map has a 'job' field that lists status of each job, including:
+        *   - type   : the job type
+        *   - status : ok/failed
+        *   - error  : any error message string
+        *   - time   : the job run time in ms
+        * The response map also has:
+        *   - backoffs : the (job type => seconds) map of backoff times
+        *   - elapsed  : the total time spent running tasks in ms
+        *   - reached  : the reason the script finished, one of (none-ready, job-limit, time-limit)
+        *
+        * @param array $options
+        * @return array Summary response that can easily be JSON serialized
+        */
+       public function run( array $options ) {
+               $response = array( 'jobs' => array(), 'reached' => 'none-ready' );
+
+               $type = isset( $options['type'] ) ? $options['type'] : false;
+               $maxJobs = isset( $options['maxJobs'] ) ? $options['maxJobs'] : false;
+               $maxTime = isset( $options['maxTime'] ) ? $options['maxTime'] : false;
+               $noThrottle = isset( $options['throttle'] ) && !$options['throttle'];
+
+               $group = JobQueueGroup::singleton();
+               // Handle any required periodic queue maintenance
+               $count = $group->executeReadyPeriodicTasks();
+               if ( $count > 0 ) {
+                       $this->runJobsLog( "Executed $count periodic queue task(s)." );
+               }
+
+               // Flush any pending DB writes for sanity
+               wfGetLBFactory()->commitMasterChanges();
+
+               $backoffs = $this->loadBackoffs(); // map of (type => UNIX expiry)
+               $startingBackoffs = $backoffs; // avoid unnecessary writes
+               $backoffExpireFunc = function ( $t ) {
+                       return $t > time();
+               };
+
+               $jobsRun = 0; // counter
+               $timeMsTotal = 0;
+               $flags = JobQueueGroup::USE_CACHE;
+               $startTime = microtime( true ); // time since jobs started running
+               $lastTime = microtime( true ); // time since last slave check
+               do {
+                       $backoffs = array_filter( $backoffs, $backoffExpireFunc );
+                       $blacklist = $noThrottle ? array() : array_keys( $backoffs );
+                       if ( $type === false ) {
+                               $job = $group->pop( JobQueueGroup::TYPE_DEFAULT, $flags, $blacklist );
+                       } elseif ( in_array( $type, $blacklist ) ) {
+                               $job = false; // requested queue in backoff state
+                       } else {
+                               $job = $group->pop( $type ); // job from a single queue
+                       }
+                       if ( $job ) { // found a job
+                               $jType = $job->getType();
+
+                               $this->runJobsLog( $job->toString() . " STARTING" );
+
+                               // Run the job...
+                               wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
+                               $t = microtime( true );
+                               try {
+                                       ++$jobsRun;
+                                       $status = $job->run();
+                                       $error = $job->getLastError();
+                                       wfGetLBFactory()->commitMasterChanges();
+                               } catch ( MWException $e ) {
+                                       MWExceptionHandler::rollbackMasterChangesAndLog( $e );
+                                       $status = false;
+                                       $error = get_class( $e ) . ': ' . $e->getMessage();
+                                       $e->report(); // write error to STDERR and the log
+                               }
+                               $timeMs = intval( ( microtime( true ) - $t ) * 1000 );
+                               wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
+                               $timeMsTotal += $timeMs;
+
+                               // Mark the job as done on success or when the job cannot be retried
+                               if ( $status !== false || !$job->allowRetries() ) {
+                                       $group->ack( $job ); // done
+                               }
+
+                               if ( $status === false ) {
+                                       $this->runJobsLog( $job->toString() . " t=$timeMs error={$error}" );
+                               } else {
+                                       $this->runJobsLog( $job->toString() . " t=$timeMs good" );
+                               }
+
+                               $response['jobs'][] = array(
+                                       'type'   => $jType,
+                                       'status' => ( $status === false ) ? 'failed' : 'ok',
+                                       'error'  => $error,
+                                       'time'   => $timeMs
+                               );
+
+                               // Back off of certain jobs for a while (for throttling and for errors)
+                               $ttw = $this->getBackoffTimeToWait( $job );
+                               if ( $status === false && mt_rand( 0, 49 ) == 0 ) {
+                                       $ttw = max( $ttw, 30 );
+                               }
+                               if ( $ttw > 0 ) {
+                                       $backoffs[$jType] = isset( $backoffs[$jType] ) ? $backoffs[$jType] : 0;
+                                       $backoffs[$jType] = max( $backoffs[$jType], time() + $ttw );
+                               }
+
+                               // Break out if we hit the job count or wall time limits...
+                               if ( $maxJobs && $jobsRun >= $maxJobs ) {
+                                       $response['reached'] = 'job-limit';
+                                       break;
+                               } elseif ( $maxTime && ( microtime( true ) - $startTime ) > $maxTime ) {
+                                       $response['reached'] = 'time-limit';
+                                       break;
+                               }
+
+                               // Don't let any of the main DB slaves get backed up
+                               $timePassed = microtime( true ) - $lastTime;
+                               if ( $timePassed >= 5 || $timePassed < 0 ) {
+                                       wfWaitForSlaves( $lastTime );
+                                       $lastTime = microtime( true );
+                               }
+                               // Don't let any queue slaves/backups fall behind
+                               if ( $jobsRun > 0 && ( $jobsRun % 100 ) == 0 ) {
+                                       $group->waitForBackups();
+                               }
+
+                               // Bail if near-OOM instead of in a job
+                               $this->assertMemoryOK();
+                       }
+               } while ( $job ); // stop when there are no jobs
+
+               // Sync the persistent backoffs for the next runJobs.php pass
+               $backoffs = array_filter( $backoffs, $backoffExpireFunc );
+               if ( $backoffs !== $startingBackoffs ) {
+                       $this->syncBackoffs( $backoffs );
+               }
+
+               $response['backoffs'] = $backoffs;
+               $response['elapsed'] = $timeMsTotal;
+
+               return $response;
+       }
+
+       /**
+        * @param Job $job
+        * @return int Seconds for this runner to avoid doing more jobs of this type
+        * @see $wgJobBackoffThrottling
+        */
+       private function getBackoffTimeToWait( Job $job ) {
+               global $wgJobBackoffThrottling;
+
+               if ( !isset( $wgJobBackoffThrottling[$job->getType()] ) ||
+                       $job instanceof DuplicateJob // no work was done
+               ) {
+                       return 0; // not throttled
+               }
+
+               $itemsPerSecond = $wgJobBackoffThrottling[$job->getType()];
+               if ( $itemsPerSecond <= 0 ) {
+                       return 0; // not throttled
+               }
+
+               $seconds = 0;
+               if ( $job->workItemCount() > 0 ) {
+                       $exactSeconds = $job->workItemCount() / $itemsPerSecond;
+                       // use randomized rounding
+                       $seconds = floor( $exactSeconds );
+                       $remainder = $exactSeconds - $seconds;
+                       $seconds += ( mt_rand() / mt_getrandmax() < $remainder ) ? 1 : 0;
+               }
+
+               return (int)$seconds;
+       }
+
+       /**
+        * Get the previous backoff expiries from persistent storage
+        *
+        * @return array Map of (job type => backoff expiry timestamp)
+        */
+       private function loadBackoffs() {
+               $section = new ProfileSection( __METHOD__ );
+
+               $backoffs = array();
+               $file = wfTempDir() . '/mw-runJobs-backoffs.json';
+               if ( is_file( $file ) ) {
+                       $handle = fopen( $file, 'rb' );
+                       flock( $handle, LOCK_SH );
+                       $content = stream_get_contents( $handle );
+                       flock( $handle, LOCK_UN );
+                       fclose( $handle );
+                       $backoffs = json_decode( $content, true ) ? : array();
+               }
+
+               return $backoffs;
+       }
+
+       /**
+        * Merge the current backoff expiries from persistent storage
+        *
+        * @param array $backoffs Map of (job type => backoff expiry timestamp)
+        */
+       private function syncBackoffs( array $backoffs ) {
+               $section = new ProfileSection( __METHOD__ );
+
+               $file = wfTempDir() . '/mw-runJobs-backoffs.json';
+               $handle = fopen( $file, 'wb+' );
+               flock( $handle, LOCK_EX );
+               $content = stream_get_contents( $handle );
+               $cBackoffs = json_decode( $content, true ) ? : array();
+               foreach ( $backoffs as $type => $timestamp ) {
+                       $cBackoffs[$type] = isset( $cBackoffs[$type] ) ? $cBackoffs[$type] : 0;
+                       $cBackoffs[$type] = max( $cBackoffs[$type], $backoffs[$type] );
+               }
+               ftruncate( $handle, 0 );
+               fwrite( $handle, json_encode( $backoffs ) );
+               flock( $handle, LOCK_UN );
+               fclose( $handle );
+       }
+
+       /**
+        * Make sure that this script is not too close to the memory usage limit.
+        * It is better to die in between jobs than OOM right in the middle of one.
+        * @throws MWException
+        */
+       private function assertMemoryOK() {
+               static $maxBytes = null;
+               if ( $maxBytes === null ) {
+                       $m = array();
+                       if ( preg_match( '!^(\d+)(k|m|g|)$!i', ini_get( 'memory_limit' ), $m ) ) {
+                               list( , $num, $unit ) = $m;
+                               $conv = array( 'g' => 1073741824, 'm' => 1048576, 'k' => 1024, '' => 1 );
+                               $maxBytes = $num * $conv[strtolower( $unit )];
+                       } else {
+                               $maxBytes = 0;
+                       }
+               }
+               $usedBytes = memory_get_usage();
+               if ( $maxBytes && $usedBytes >= 0.95 * $maxBytes ) {
+                       throw new MWException( "Detected excessive memory usage ($usedBytes/$maxBytes)." );
+               }
+       }
+
+       /**
+        * Log the job message
+        * @param string $msg The message to log
+        */
+       private function runJobsLog( $msg ) {
+               if ( $this->debug ) {
+                       call_user_func_array( $this->debug, array( wfTimestamp( TS_DB ) . " $msg\n" ) );
+               }
+               wfDebugLog( 'runJobs', $msg );
+       }
+}
index b0a6ef7..1fa6cef 100644 (file)
@@ -31,7 +31,7 @@ final class DuplicateJob extends Job {
         * Callers should use DuplicateJob::newFromJob() instead
         *
         * @param Title $title
-        * @param array $params job parameters
+        * @param array $params Job parameters
         */
        function __construct( $title, $params ) {
                parent::__construct( 'duplicate', $title, $params );
index b2d6a9a..66291e9 100644 (file)
@@ -47,7 +47,7 @@
 class NullJob extends Job {
        /**
         * @param Title $title
-        * @param array $params job parameters (lives, usleep)
+        * @param array $params Job parameters (lives, usleep)
         */
        function __construct( $title, $params ) {
                parent::__construct( 'null', $title, $params );
index 480246b..a09db15 100644 (file)
@@ -155,8 +155,8 @@ class UploadFromUrlJob extends Job {
         * Store a result in the session data. Note that the caller is responsible
         * for appropriate session_start and session_write_close calls.
         *
-        * @param string $result the result (Success|Warning|Failure)
-        * @param string $dataKey the key of the extra data
+        * @param string $result The result (Success|Warning|Failure)
+        * @param string $dataKey The key of the extra data
         * @param mixed $dataValue The extra data itself
         */
        protected function storeResultInSession( $result, $dataKey, $dataValue ) {
index 0139c4a..92985f3 100644 (file)
@@ -112,7 +112,7 @@ class LogFormatter {
         * Set the visibility restrictions for displaying content.
         * If set to public, and an item is deleted, then it will be replaced
         * with a placeholder even if the context user is allowed to view it.
-        * @param int $audience self::FOR_THIS_USER or self::FOR_PUBLIC
+        * @param int $audience Const self::FOR_THIS_USER or self::FOR_PUBLIC
         */
        public function setAudience( $audience ) {
                $this->audience = ( $audience == self::FOR_THIS_USER )
@@ -163,7 +163,7 @@ class LogFormatter {
         * Even uglier hack to maintain backwards compatibilty with IRC bots
         * (bug 34508).
         * @see getActionText()
-        * @return string text
+        * @return string Text
         */
        public function getIRCActionComment() {
                $actionComment = $this->getIRCActionText();
@@ -184,7 +184,7 @@ class LogFormatter {
         * Even uglier hack to maintain backwards compatibilty with IRC bots
         * (bug 34508).
         * @see getActionText()
-        * @return string text
+        * @return string Text
         */
        public function getIRCActionText() {
                $this->plaintext = true;
@@ -482,8 +482,7 @@ class LogFormatter {
         *     * number: Format value as number
         * @param string $value The parameter value that should
         *                      be formated
-        * @return string|Message::numParam|Message::rawParam
-        *         Formated value
+        * @return string|array Formated value
         * @since 1.21
         */
        protected function formatParameterValue( $type, $value ) {
@@ -652,7 +651,7 @@ class LogFormatter {
        }
 
        /**
-        * @return array of titles that should be preloaded with LinkBatch.
+        * @return array Array of titles that should be preloaded with LinkBatch
         */
        public function getPreloadTitles() {
                return array();
index 1b7e677..be7931d 100644 (file)
@@ -87,7 +87,7 @@ class LogPage {
        }
 
        /**
-        * @return int log_id of the inserted log entry
+        * @return int The log_id of the inserted log entry
         */
        protected function saveContent() {
                global $wgLogRestrictions;
@@ -192,7 +192,7 @@ class LogPage {
        /**
         * Get the list of valid log types
         *
-        * @return array of strings
+        * @return array Array of strings
         */
        public static function validTypes() {
                global $wgLogTypes;
@@ -234,7 +234,7 @@ class LogPage {
         * Get the log header for the given log type
         *
         * @todo handle missing log types
-        * @param string $type logtype
+        * @param string $type Logtype
         * @return string Header text of this logtype
         * @deprecated since 1.19, warnings in 1.21. Use getDescription()
         */
@@ -250,12 +250,12 @@ class LogPage {
         * Generate text for a log entry.
         * Only LogFormatter should call this function.
         *
-        * @param string $type log type
-        * @param string $action log action
+        * @param string $type Log type
+        * @param string $action Log action
         * @param Title|null $title Title object or null
         * @param Skin|null $skin Skin object or null. If null, we want to use the wiki
         *   content language, since that will go to the IRC feed.
-        * @param array $params parameters
+        * @param array $params Parameters
         * @param bool $filterWikilinks Whether to filter wiki links
         * @return string HTML
         */
@@ -440,14 +440,14 @@ class LogPage {
        /**
         * Add a log entry
         *
-        * @param string $action one of '', 'block', 'protect', 'rights', 'delete',
+        * @param string $action One of '', 'block', 'protect', 'rights', 'delete',
         *   'upload', 'move', 'move_redir'
         * @param Title $target Title object
-        * @param string $comment description associated
-        * @param array $params parameters passed later to wfMessage function
+        * @param string $comment Description associated
+        * @param array $params Parameters passed later to wfMessage function
         * @param null|int|User $doer The user doing the action. null for $wgUser
         *
-        * @return int log_id of the inserted log entry
+        * @return int The log_id of the inserted log entry
         */
        public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) {
                global $wgContLang;
index 2a393db..053c586 100644 (file)
@@ -97,7 +97,7 @@ class BitmapMetadataHandler {
        /** Add misc metadata. Warning: atm if the metadata category
         * doesn't have a priority, it will be silently discarded.
         *
-        * @param array $metaArray array of metadata values
+        * @param array $meta Array of metadata values
         * @param string $type Type. defaults to other. if two things have the same type they're merged
         */
        function addMetadata( $metaArray, $type = 'other' ) {
@@ -149,9 +149,9 @@ class BitmapMetadataHandler {
 
        /** Main entry point for jpeg's.
         *
-        * @param string $filename filename (with full path)
+        * @param string $filename Filename (with full path)
         * @return array Metadata result array.
-        * @throws MWException on invalid file.
+        * @throws MWException On invalid file.
         */
        static function Jpeg( $filename ) {
                $showXMP = function_exists( 'xml_parser_create_ns' );
@@ -224,7 +224,7 @@ class BitmapMetadataHandler {
         * They don't really have native metadata, so just merges together
         * XMP and image comment.
         *
-        * @param string $filename full path to file
+        * @param string $filename Full path to file
         * @return array Metadata array
         */
        public static function GIF( $filename ) {
index 099375b..6ff19c9 100644 (file)
@@ -88,7 +88,7 @@ class DjVuImage {
                // something that explicitly initializes local variables.
                extract( unpack( 'a4magic/a4chunk/NchunkLength', $header ) );
                /** @var string $chunk
-                *  @var string $chunkLength */
+                * @var string $chunkLength */
                echo "$chunk $chunkLength\n";
                $this->dumpForm( $file, $chunkLength, 1 );
                fclose( $file );
@@ -107,7 +107,7 @@ class DjVuImage {
                        // something that explicitly initializes local variables.
                        extract( unpack( 'a4chunk/NchunkLength', $chunkHeader ) );
                        /** @var string $chunk
-                        *  @var string $chunkLength */
+                        * @var string $chunkLength */
                        echo str_repeat( ' ', $indent * 4 ) . "$chunk $chunkLength\n";
 
                        if ( $chunk == 'FORM' ) {
@@ -143,9 +143,9 @@ class DjVuImage {
                        extract( unpack( 'a4magic/a4form/NformLength/a4subtype', $header ) );
 
                        /** @var string $magic
-                        *  @var string $subtype
-                        *  @var string $formLength
-                        *  @var string $formType */
+                        * @var string $subtype
+                        * @var string $formLength
+                        * @var string $formType */
                        if ( $magic != 'AT&T' ) {
                                wfDebug( __METHOD__ . ": not a DjVu file\n" );
                        } elseif ( $subtype == 'DJVU' ) {
@@ -173,7 +173,7 @@ class DjVuImage {
                        extract( unpack( 'a4chunk/Nlength', $header ) );
 
                        /** @var string $chunk
-                        *  @var string $length */
+                        * @var string $length */
                        return array( $chunk, $length );
                }
        }
@@ -249,12 +249,12 @@ class DjVuImage {
                # Newer files have rotation info in byte 10, but we don't use it yet.
 
                /** @var string $width
-                *  @var string $height
-                *  @var string $major
-                *  @var string $minor
-                *  @var string $resolution
-                *  @var string $length
-                *  @var string $gamma */
+                * @var string $height
+                * @var string $major
+                * @var string $minor
+                * @var string $resolution
+                * @var string $length
+                * @var string $gamma */
                return array(
                        'width' => $width,
                        'height' => $height,
index d630136..d285c0c 100644 (file)
@@ -442,7 +442,7 @@ class Exif {
         * Do userComment tags and similar. See pg. 34 of exif standard.
         * basically first 8 bytes is charset, rest is value.
         * This has not been tested on any shift-JIS strings.
-        * @param string $prop prop name.
+        * @param string $prop Prop name
         */
        private function charCodeString( $prop ) {
                if ( isset( $this->mFilteredExifData[$prop] ) ) {
@@ -729,8 +729,8 @@ class Exif {
        /**
         * Validates if a tag has a legal value according to the Exif spec
         *
-        * @param string $section section where tag is located.
-        * @param string $tag the tag to check.
+        * @param string $section Section where tag is located.
+        * @param string $tag The tag to check.
         * @param mixed $val The value of the tag.
         * @param bool $recursive True if called recursively for array types.
         * @return bool
@@ -840,7 +840,7 @@ class Exif {
        /**
         * Convenience function for debugging output
         *
-        * @param string $fname the name of the function calling this function
+        * @param string $fname The name of the function calling this function
         * @param bool $io Specify whether we're beginning or ending
         */
        private function debugFile( $fname, $io ) {
index 4200541..4356953 100644 (file)
@@ -72,7 +72,7 @@ class FormatMetadata extends ContextSource {
         *
         * This is the usual entry point for this class.
         *
-        * @param array $tags the Exif data to format ( as returned by
+        * @param array $tags The Exif data to format ( as returned by
         *   Exif::getFilteredData() or BitmapMetadataHandler )
         * @param bool|IContextSource $context Context to use (optional)
         * @return array
@@ -92,7 +92,7 @@ class FormatMetadata extends ContextSource {
         * value which most of the time are plain integers. This function
         * formats Exif (and other metadata) values into human readable form.
         *
-        * @param array $tags the Exif data to format ( as returned by
+        * @param array $tags The Exif data to format ( as returned by
         *   Exif::getFilteredData() or BitmapMetadataHandler )
         * @return array
         * @since 1.23
@@ -1006,7 +1006,7 @@ class FormatMetadata extends ContextSource {
        /**
         * Flatten an array, using the user language for any messages.
         *
-        * @param array $vals array of values
+        * @param array $vals Array of values
         * @param string $type Type of array (either lang, ul, ol).
         *   lang = language assoc array with keys being the lang code
         *   ul = unordered list, ol = ordered list
@@ -1031,7 +1031,7 @@ class FormatMetadata extends ContextSource {
         *
         * This is public on the basis it might be useful outside of this class.
         *
-        * @param array $vals array of values
+        * @param array $vals Array of values
         * @param string $type Type of array (either lang, ul, ol).
         *     lang = language assoc array with keys being the lang code
         *     ul = unordered list, ol = ordered list
@@ -1706,7 +1706,7 @@ class FormatMetadata extends ContextSource {
         *
         * @param File $file File to use
         * @param array $extendedMetadata
-        * @param int $maxCacheTime hook handlers might use this parameter to override cache time
+        * @param int $maxCacheTime Hook handlers might use this parameter to override cache time
         *
         * @return array [<property name> => ['value' => <value>]], or [] on error
         * @since 1.23
@@ -1741,7 +1741,7 @@ class FormatMetadata extends ContextSource {
         * If the value is not a multilang array, it is returned unchanged.
         * See mediawiki.org/wiki/Manual:File_metadata_handling#Multi-language_array_format
         * @param mixed $value
-        * @return mixed value in best language, null if there were no languages at all
+        * @return mixed Value in best language, null if there were no languages at all
         * @since 1.23
         */
        protected function resolveMultilangValue( $value ) {
index 503b968..478249f 100644 (file)
@@ -34,7 +34,7 @@ class IPTC {
         *
         * @see http://www.iptc.org/std/IIM/4.1/specification/IIMV4.1.pdf
         *
-        * @param string $rawData app13 block from jpeg containing iptc/iim data
+        * @param string $rawData The app13 block from jpeg containing iptc/iim data
         * @return array IPTC metadata array
         */
        static function parse( $rawData ) {
@@ -470,7 +470,7 @@ class IPTC {
        /**
         * take the value of 1:90 tag and returns a charset
         * @param string $tag 1:90 tag.
-        * @return string charset name or "?"
+        * @return string Charset name or "?"
         * Warning, this function does not (and is not intended to) detect
         * all iso 2022 escape codes. In practise, the code for utf-8 is the
         * only code that seems to have wide use. It does detect that code.
index 918d4ae..fbdbdfe 100644 (file)
@@ -51,8 +51,8 @@ class JpegHandler extends ExifBitmapHandler {
        }
 
        /** Validate and normalize quality value to be between 1 and 100 (inclusive).
-        * @param int $value quality value, will be converted to integer or 0 if invalid
-        * @return bool true if the value is valid
+        * @param int $value Quality value, will be converted to integer or 0 if invalid
+        * @return bool True if the value is valid
         */
        private static function validateQuality( $value ) {
                return $value === 'low';
index a0f8524..8c5b46b 100644 (file)
@@ -43,9 +43,9 @@ class JpegMetadataExtractor {
         * but gis doesn't support having multiple app1 segments
         * and those can't extract xmp on files containing both exif and xmp data
         *
-        * @param string $filename name of jpeg file
-        * @return array of interesting segments.
-        * @throws MWException if given invalid file.
+        * @param string $filename Name of jpeg file
+        * @return array Array of interesting segments.
+        * @throws MWException If given invalid file.
         */
        static function segmentSplitter( $filename ) {
                $showXMP = function_exists( 'xml_parser_create_ns' );
@@ -193,7 +193,7 @@ class JpegMetadataExtractor {
         *
         * This should generally be called by BitmapMetadataHandler::doApp13()
         *
-        * @param string $app13 photoshop psir app13 block from jpg.
+        * @param string $app13 Photoshop psir app13 block from jpg.
         * @throws MWException (It gets caught next level up though)
         * @return string If the iptc hash is good or not. One of 'iptc-no-hash',
         *   'iptc-good-hash', 'iptc-bad-hash'.
index 2612685..e8f8360 100644 (file)
@@ -124,7 +124,7 @@ abstract class MediaHandler {
         *  first page.
         *
         * @param File $image The image object, or false if there isn't one
-        * @param string $path the filename
+        * @param string $path The filename
         * @return array Follow the format of PHP getimagesize() internal function.
         *   See http://www.php.net/getimagesize. MediaWiki will only ever use the
         *   first two array keys (the width and height), and the 'bits' associative
@@ -308,7 +308,7 @@ abstract class MediaHandler {
         * @param string $ext Extension of original file
         * @param string $mime MIME type of original file
         * @param array $params Handler specific rendering parameters
-        * @return array thumbnail extension and MIME type
+        * @return array Thumbnail extension and MIME type
         */
        function getThumbType( $ext, $mime, $params = null ) {
                $magic = MimeMagic::singleton();
@@ -689,7 +689,7 @@ abstract class MediaHandler {
         * relevant errors.
         *
         * @param string $fileName The local path to the file.
-        * @return Status object
+        * @return Status
         */
        function verifyUpload( $fileName ) {
                return Status::newGood();
@@ -843,8 +843,8 @@ abstract class MediaHandler {
        /**
         * Returns whether or not this handler supports the chained generation of thumbnails according
         * to buckets
-        * @return boolean
-        * @since  1.24
+        * @return bool
+        * @since 1.24
         */
        public function supportsBucketing() {
                return false;
index d8d56a4..bc9e917 100644 (file)
@@ -32,7 +32,7 @@ abstract class MediaTransformOutput {
         */
        public $responsiveUrls = array();
 
-       /** @var File object */
+       /** @var File */
        protected $file;
 
        /** @var int Image width */
@@ -71,7 +71,7 @@ abstract class MediaTransformOutput {
        }
 
        /**
-        * @return File file
+        * @return File
         */
        public function getFile() {
                return $this->file;
index d879c12..7b3ddb5 100644 (file)
@@ -100,7 +100,7 @@ class PNGHandler extends BitmapHandler {
        /**
         * We do not support making APNG thumbnails, so always false
         * @param File $image
-        * @return bool false
+        * @return bool False
         */
        function canAnimateThumbnail( $image ) {
                return false;
index 30376f1..bccd36c 100644 (file)
@@ -413,7 +413,7 @@ class PNGMetadataExtractor {
         *
         * @param resource $fh The file handle
         * @param int $size Size in bytes.
-        * @throws Exception if too big.
+        * @throws Exception If too big
         * @return string The chunk.
         */
        private static function read( $fh, $size ) {
index e28b38f..e890b29 100644 (file)
@@ -446,7 +446,7 @@ class SvgHandler extends ImageHandler {
        }
 
        /**
-        * @param array $params name=>value pairs of parameters
+        * @param array $params Name=>value pairs of parameters
         * @return string Filename to use
         */
        function makeParamString( $params ) {
index 9e69137..04099c3 100644 (file)
@@ -93,7 +93,7 @@ class XCFHandler extends BitmapHandler {
         * @author Hashar
         *
         * @param string $filename Full path to a XCF file
-        * @return bool|array metadata array just like PHP getimagesize()
+        * @return bool|array Metadata Array just like PHP getimagesize()
         */
        static function getXCFMetaData( $filename ) {
                # Decode master structure
index a74b701..154c85d 100644 (file)
@@ -406,7 +406,7 @@ class XMPReader {
         *
         * @param XMLParser $parser XMLParser reference to the xml parser
         * @param string $data Character data
-        * @throws MWException on invalid data
+        * @throws MWException On invalid data
         */
        function char( $parser, $data ) {
 
@@ -726,7 +726,7 @@ class XMPReader {
         * this should always be <rdf:Bag>
         *
         * @param string $elm Namespace . ' ' . tag
-        * @throws MWException if we have an element that's not <rdf:Bag>
+        * @throws MWException If we have an element that's not <rdf:Bag>
         */
        private function startElementModeBag( $elm ) {
                if ( $elm === self::NS_RDF . ' Bag' ) {
@@ -741,7 +741,7 @@ class XMPReader {
         * this should always be <rdf:Seq>
         *
         * @param string $elm Namespace . ' ' . tag
-        * @throws MWException if we have an element that's not <rdf:Seq>
+        * @throws MWException If we have an element that's not <rdf:Seq>
         */
        private function startElementModeSeq( $elm ) {
                if ( $elm === self::NS_RDF . ' Seq' ) {
@@ -768,7 +768,7 @@ class XMPReader {
         * we don't care about.
         *
         * @param string $elm Namespace . ' ' . tag
-        * @throws MWException if we have an element that's not <rdf:Alt>
+        * @throws MWException If we have an element that's not <rdf:Alt>
         */
        private function startElementModeLang( $elm ) {
                if ( $elm === self::NS_RDF . ' Alt' ) {
@@ -963,7 +963,7 @@ class XMPReader {
         *
         * @param string $elm Namespace . ' ' . tagname
         * @param array $attribs Attributes. (needed for BAGSTRUCTS)
-        * @throws MWException if gets a tag other than <rdf:li>
+        * @throws MWException If gets a tag other than <rdf:li>
         */
        private function startElementModeLi( $elm, $attribs ) {
                if ( ( $elm ) !== self::NS_RDF . ' li' ) {
index de3efd1..6f8f9af 100644 (file)
@@ -251,7 +251,7 @@ abstract class BagOStuff {
         * Batch insertion
         * @param array $data $key => $value assoc array
         * @param int $exptime Either an interval in seconds or a unix timestamp for expiry
-        * @return bool success
+        * @return bool Success
         * @since 1.24
         */
        public function setMulti( array $data, $exptime = 0 ) {
@@ -330,9 +330,9 @@ abstract class BagOStuff {
         * This will create the key with value $init and TTL $ttl if not present
         *
         * @param string $key
-        * @param integer $ttl
-        * @param integer $value
-        * @param integer $init
+        * @param int $ttl
+        * @param int $value
+        * @param int $init
         * @return bool
         * @since 1.24
         */
index a6c7d9c..2a882ac 100644 (file)
@@ -52,7 +52,7 @@ class WinCacheBagOStuff extends BagOStuff {
         * Store a value in the WinCache object cache
         *
         * @param string $key Cache key
-        * @param mixed $valueObject to store
+        * @param mixed $valueObject Value to store
         * @param int $expire Expiration time
         * @return bool
         */
index 40a7d51..a189c2e 100644 (file)
@@ -703,7 +703,9 @@ class Article implements Page {
                                        $this->mParserOutput = $poolArticleView->getParserOutput();
                                        $outputPage->addParserOutput( $this->mParserOutput );
                                        if ( $content->getRedirectTarget() ) {
-                                               $outputPage->addSubtitle( wfMessage( 'redirectpagesub' )->parse() );
+                                               $outputPage->addSubtitle(
+                                                       "<span id=\"redirectsub\">" . wfMessage( 'redirectpagesub' )->parse() . "</span>"
+                                               );
                                        }
 
                                        # Don't cache a dirty ParserOutput object
@@ -1268,7 +1270,7 @@ class Article implements Page {
         * If the revision requested for view is deleted, check permissions.
         * Send either an error message or a warning header to the output.
         *
-        * @return bool true if the view is allowed, false if not.
+        * @return bool True if the view is allowed, false if not.
         */
        public function showDeletedRevisionHeader() {
                if ( !$this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) {
@@ -1818,7 +1820,7 @@ class Article implements Page {
         * output to the client that is necessary for this request.
         * (that is, it has sent a cached version of the page)
         *
-        * @return bool true if cached version send, false otherwise
+        * @return bool True if cached version send, false otherwise
         */
        protected function tryFileCache() {
                static $called = false;
@@ -1894,7 +1896,7 @@ class Article implements Page {
         * Override the ParserOptions used to render the primary article wikitext.
         *
         * @param ParserOptions $options
-        * @throws MWException if the parser options where already initialized.
+        * @throws MWException If the parser options where already initialized.
         */
        public function setParserOptions( ParserOptions $options ) {
                if ( $this->mParserOptions ) {
index 9aff6ef..e50592c 100644 (file)
@@ -1061,12 +1061,12 @@ EOT
         *  of the dimensions are bigger than the max, or if the
         *  image is vectorized.
         *
-        * @param $maxWidth integer Max width to display at
-        * @param $maxHeight integer Max height to display at
-        * @param $width integer Actual width of the image
-        * @param $height integer Actual height of the image
+        * @param int $maxWidth Max width to display at
+        * @param int $maxHeight Max height to display at
+        * @param int $width Actual width of the image
+        * @param int $height Actual height of the image
         * @throws MWException
-        * @return Array (width, height)
+        * @return array Array (width, height)
         */
        protected function getDisplayWidthHeight( $maxWidth, $maxHeight, $width, $height ) {
                if ( !$maxWidth || !$maxHeight ) {
@@ -1100,9 +1100,9 @@ EOT
         * Get alternative thumbnail sizes.
         *
         * @note This will only list several alternatives if thumbnails are rendered on 404
-        * @param $origWidth Actual width of image
-        * @param $origHeight Actual height of image
-        * @return Array An array of [width, height] pairs.
+        * @param int $origWidth Actual width of image
+        * @param int $origHeight Actual height of image
+        * @return array An array of [width, height] pairs.
         */
        protected function getThumbSizes( $origWidth, $origHeight ) {
                global $wgImageLimits;
index 8d0f0af..be5ce3f 100644 (file)
@@ -530,7 +530,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Loads page_touched and returns a value indicating if it should be used
-        * @return bool true if not a redirect
+        * @return bool True if not a redirect
         */
        public function checkTouched() {
                if ( !$this->mDataLoaded ) {
@@ -563,7 +563,7 @@ class WikiPage implements Page, IDBAccessObject {
 
        /**
         * Get the page_latest field
-        * @return int rev_id of current revision
+        * @return int The rev_id of current revision
         */
        public function getLatest() {
                if ( !$this->mDataLoaded ) {
@@ -663,7 +663,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Get the content of the current revision. No side-effects...
         *
-        * @param int $audience int One of:
+        * @param int $audience One of:
         *   Revision::FOR_PUBLIC       to be displayed to all users
         *   Revision::FOR_THIS_USER    to be displayed to $wgUser
         *   Revision::RAW              get the text regardless of permissions
@@ -743,7 +743,7 @@ class WikiPage implements Page, IDBAccessObject {
         *   Revision::RAW              get the text regardless of permissions
         * @param User $user User object to check for, only if FOR_THIS_USER is passed
         *   to the $audience parameter
-        * @return int user ID for the user that made the last article revision
+        * @return int User ID for the user that made the last article revision
         */
        public function getUser( $audience = Revision::FOR_PUBLIC, User $user = null ) {
                $this->loadLastEdit();
@@ -781,7 +781,7 @@ class WikiPage implements Page, IDBAccessObject {
         *   Revision::RAW              get the text regardless of permissions
         * @param User $user User object to check for, only if FOR_THIS_USER is passed
         *   to the $audience parameter
-        * @return string username of the user that made the last article revision
+        * @return string Username of the user that made the last article revision
         */
        public function getUserText( $audience = Revision::FOR_PUBLIC, User $user = null ) {
                $this->loadLastEdit();
@@ -968,7 +968,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Get the Title object or URL this page redirects to
         *
-        * @return bool|Title|string false, Title of in-wiki target, or string with URL
+        * @return bool|Title|string False, Title of in-wiki target, or string with URL
         */
        public function followRedirect() {
                return $this->getRedirectURL( $this->getRedirectTarget() );
@@ -979,7 +979,7 @@ class WikiPage implements Page, IDBAccessObject {
         * objects for same-wiki, non-special redirects and URLs for everything
         * else.
         * @param Title $rt Redirect target
-        * @return bool|Title|string false, Title object of local target, or string with URL
+        * @return bool|Title|string False, Title object of local target, or string with URL
         */
        public function getRedirectURL( $rt ) {
                if ( !$rt ) {
@@ -1295,7 +1295,7 @@ class WikiPage implements Page, IDBAccessObject {
         *   Giving 0 indicates the new page flag should be set on.
         * @param bool $lastRevIsRedirect If given, will optimize adding and
         *   removing rows in redirect table.
-        * @return bool true on success, false on failure
+        * @return bool True on success, false on failure
         */
        public function updateRevisionOn( $dbw, $revision, $lastRevision = null,
                $lastRevIsRedirect = null
@@ -1357,7 +1357,7 @@ class WikiPage implements Page, IDBAccessObject {
         *   or NULL if this is not a redirect
         * @param null|bool $lastRevIsRedirect If given, will optimize adding and
         *   removing rows in redirect table.
-        * @return bool true on success, false on failure
+        * @return bool True on success, false on failure
         * @private
         */
        public function updateRedirectOn( $dbw, $redirectTitle, $lastRevIsRedirect = null ) {
@@ -1433,7 +1433,7 @@ class WikiPage implements Page, IDBAccessObject {
         * must exist and must not be deleted
         * @param Revision $undo
         * @param Revision $undoafter Must be an earlier revision than $undo
-        * @return mixed string on success, false on failure
+        * @return mixed String on success, false on failure
         * @since 1.21
         * Before we had the Content object, this was done in getUndoText
         */
@@ -1448,7 +1448,7 @@ class WikiPage implements Page, IDBAccessObject {
         * must exist and must not be deleted
         * @param Revision $undo
         * @param Revision $undoafter Must be an earlier revision than $undo
-        * @return string|bool string on success, false on failure
+        * @return string|bool String on success, false on failure
         * @deprecated since 1.21: use ContentHandler::getUndoContent() instead.
         */
        public function getUndoText( Revision $undo, Revision $undoafter = null ) {
@@ -1563,7 +1563,7 @@ class WikiPage implements Page, IDBAccessObject {
         * or 'new' for a new section.
         * @param Content $sectionContent New content of the section.
         * @param string $sectionTitle New section's subject, only if $section is "new".
-        * @param string $baseRevId integer|null
+        * @param int|null $baseRevId
         *
         * @throws MWException
         * @return Content New complete article content, or null if error.
@@ -1666,7 +1666,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @param User $user The user doing the edit
         *
         * @throws MWException
-        * @return Status object. Possible errors:
+        * @return Status Possible errors:
         *   edit-hook-aborted: The ArticleSave hook aborted the edit but didn't
         *     set the fatal flag of $status
         *   edit-gone-missing: In update mode, but the article didn't exist.
@@ -1728,7 +1728,7 @@ class WikiPage implements Page, IDBAccessObject {
         *   database.
         *
         * @throws MWException
-        * @return Status object. Possible errors:
+        * @return Status Possible errors:
         *     edit-hook-aborted: The ArticleSave hook aborted the edit but didn't
         *       set the fatal flag of $status.
         *     edit-gone-missing: In update mode, but the article didn't exist.
@@ -2313,7 +2313,7 @@ class WikiPage implements Page, IDBAccessObject {
         *
         * @param Content $content Content submitted
         * @param User $user The relevant user
-        * @param string $comment comment submitted
+        * @param string $comment Comment submitted
         * @param string $serialisation_format Format for storing the content in the database
         * @param bool $minor Whereas it's a minor modification
         */
@@ -2739,7 +2739,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @param bool $commit Defaults to true, triggers transaction end
         * @param array &$error Array of errors to append to
         * @param User $user The deleting user
-        * @return bool true if successful
+        * @return bool True if successful
         */
        public function doDeleteArticle(
                $reason, $suppress = false, $id = 0, $commit = true, &$error = '', User $user = null
@@ -2904,7 +2904,7 @@ class WikiPage implements Page, IDBAccessObject {
        /**
         * Do some database updates after deletion
         *
-        * @param int $id page_id value of the page being deleted
+        * @param int $id The page_id value of the page being deleted
         * @param Content $content Optional page content to be used when determining
         *   the required updates. This may be needed because $this->getContent()
         *   may already return null when the page proper was deleted.
@@ -2949,7 +2949,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @param string $token Rollback token.
         * @param bool $bot If true, mark all reverted edits as bot.
         *
-        * @param array $resultDetails contains result-specific array of additional values
+        * @param array $resultDetails Array contains result-specific array of additional values
         *    'alreadyrolled' : 'current' (rev)
         *    success        : 'summary' (str), 'current' (rev), 'target' (rev)
         *
@@ -3525,7 +3525,7 @@ class WikiPage implements Page, IDBAccessObject {
         * @param int &$cascade Set to false if cascading protection isn't allowed.
         * @param array $expiry Per restriction type expiration
         * @param User $user The user updating the restrictions
-        * @return bool true on success
+        * @return bool True on success
         */
        public function updateRestrictions(
                $limit = array(), $reason = '', &$cascade = 0, $expiry = array(), User $user = null
index cfd5370..0bf2ffc 100644 (file)
@@ -122,7 +122,7 @@ class DateFormatter {
         *
         * @param Language|string|null $lang In which language to format the date
         *              Defaults to the site content language
-        * @return DateFormatter object
+        * @return DateFormatter
         */
        public static function &getInstance( $lang = null ) {
                global $wgMemc, $wgContLang;
index 648667b..30bb2cf 100644 (file)
@@ -265,7 +265,7 @@ class LinkHolderArray {
        /**
         * Replace <!--LINK--> link placeholders with actual links, in the buffer
         *
-        * @param $text
+        * @param string $text
         * @return array Array of link CSS classes, indexed by PDBK.
         */
        function replace( &$text ) {
index b37e977..bc4fcce 100644 (file)
@@ -211,7 +211,7 @@ class Parser {
        var $mLangLinkLanguages;
 
        /**
-        * @var boolean Recursive call protection.
+        * @var bool Recursive call protection.
         * This variable should be treated as if it were private.
         */
        public $mInParse = false;
@@ -349,7 +349,7 @@ class Parser {
         * Convert wikitext to HTML
         * Do not call this function recursively.
         *
-        * @param string $text text we want to parse
+        * @param string $text Text we want to parse
         * @param Title $title
         * @param ParserOptions $options
         * @param bool $linestart
@@ -798,7 +798,7 @@ class Parser {
        /**
         * Get the ParserOptions object
         *
-        * @return ParserOptions object
+        * @return ParserOptions
         */
        function getOptions() {
                return $this->mOptions;
@@ -1434,7 +1434,7 @@ class Parser {
         *
         * @param string $text
         *
-        * @return string the altered text
+        * @return string The altered text
         */
        function doAllQuotes( $text ) {
                wfProfileIn( __METHOD__ );
index 33f0f96..6102ca4 100644 (file)
@@ -26,7 +26,7 @@
  * @todo document
  */
 class ParserCache {
-       /** @var MWMemcached  */
+       /** @var MWMemcached */
        private $mMemc;
        /**
         * Get an instance of this object
index 2cd208c..411702f 100644 (file)
@@ -22,7 +22,7 @@
  */
 
 /**
- * \brief Set options of the Parser
+ * @brief Set options of the Parser
  *
  * All member variables are supposed to be private in theory, although in
  * practise this is not the case.
index 1903fc4..f6ad931 100644 (file)
@@ -396,7 +396,7 @@ class ParserOutput extends CacheTime {
 
        /**
         * @param Title $title Title object, must be an interwiki link
-        * @throws MWException if given invalid input
+        * @throws MWException If given invalid input
         */
        function addInterwikiLink( $title ) {
                if ( !$title->isExternal() ) {
@@ -478,7 +478,7 @@ class ParserOutput extends CacheTime {
         * -- this is assumed to have been validated
         * (check equal normalisation, etc.)
         *
-        * @param string $text desired title text
+        * @param string $text Desired title text
         */
        public function setDisplayTitle( $text ) {
                $this->setTitleText( $text );
@@ -576,7 +576,7 @@ class ParserOutput extends CacheTime {
        /**
         * @param string $name The property name to look up.
         *
-        * @return mixed|false The value previously set using setProperty(). False if null or no value
+        * @return mixed|bool The value previously set using setProperty(). False if null or no value
         * was set for the given property name.
         *
         * @note You need to use getProperties() to check for boolean and null properties.
index bf2bf61..26daca1 100644 (file)
@@ -995,7 +995,7 @@ class PPFrame_Hash implements PPFrame {
 
        /**
         * @throws MWException
-        * @param string|PPNode$root
+        * @param string|PPNode $root
         * @param int $flags
         * @return string
         */
index f8d48cc..e77ffd7 100644 (file)
@@ -132,7 +132,7 @@ abstract class PoolCounter {
         * Lets another one grab the lock, and returns the workers
         * waiting on acquireForAnyone()
         *
-        * @return Status value is one of Released/NotLocked/Error
+        * @return Status Value is one of Released/NotLocked/Error
         */
        abstract public function release();
 
@@ -143,7 +143,7 @@ abstract class PoolCounter {
         * the same key can acquire a lock.
         *
         * @param string $key PoolCounter instance key (any string)
-        * @param int $slots the number of slots (max allowed value is 65536)
+        * @param int $slots The number of slots (max allowed value is 65536)
         * @return int
         */
        protected function hashKeyIntoSlots( $key, $slots ) {
index cd1e859..7b8f340 100644 (file)
@@ -25,7 +25,7 @@
 
 /**
  * Begin profiling of a function
- * @param string $functionname name of the function we will profile
+ * @param string $functionname Name of the function we will profile
  */
 function wfProfileIn( $functionname ) {
        if ( Profiler::$__instance === null ) { // use this directly to reduce overhead
@@ -38,7 +38,7 @@ function wfProfileIn( $functionname ) {
 
 /**
  * Stop profiling of a function
- * @param string $functionname name of the function we have profiled
+ * @param string $functionname Name of the function we have profiled
  */
 function wfProfileOut( $functionname = 'missing' ) {
        if ( Profiler::$__instance === null ) { // use this directly to reduce overhead
@@ -196,7 +196,7 @@ abstract class Profiler {
        /**
         * Called by wfProfieOut()
         *
-        * @param  string $functionname
+        * @param string $functionname
         */
        abstract public function profileOut( $functionname );
 
@@ -326,7 +326,7 @@ abstract class Profiler {
        /**
         * Add an entry in the debug log file
         *
-        * @param string $s to output
+        * @param string $s String to output
         */
        protected function debug( $s ) {
                if ( function_exists( 'wfDebug' ) ) {
@@ -338,7 +338,7 @@ abstract class Profiler {
         * Add an entry in the debug log group
         *
         * @param string $group Group to send the message to
-        * @param string $s to output
+        * @param string $s String to output
         */
        protected function debugGroup( $group, $s ) {
                if ( function_exists( 'wfDebugLog' ) ) {
@@ -356,7 +356,7 @@ abstract class Profiler {
  * @since 1.24
  */
 class TransactionProfiler {
-       /** @var float seconds */
+       /** @var float Seconds */
        protected $mDBLockThreshold = 3.0;
        /** @var array DB/server name => (active trx count, time, DBs involved) */
        protected $mDBTrxHoldingLocks = array();
index abcd23c..af3c774 100644 (file)
@@ -94,8 +94,8 @@ class ProfilerMwprof extends Profiler {
         * Update an entry with timing data.
         *
         * @param string $name Section name
-        * @param float $elapsedCpu elapsed CPU time
-        * @param float $elapsedWall elapsed wall-clock time
+        * @param float $elapsedCpu Elapsed CPU time
+        * @param float $elapsedWall Elapsed wall-clock time
         */
        public function updateRunningEntry( $name, $elapsedCpu, $elapsedWall ) {
                // If this is the first measurement for this entry, store plain values.
index 5de9982..7fd86eb 100644 (file)
@@ -299,7 +299,7 @@ class ProfilerStandard extends Profiler {
        /**
         * Recursive function the format the current profiling array into a tree
         *
-        * @param array $stack profiling array
+        * @param array $stack Profiling array
         * @return array
         */
        protected function remapCallTree( array $stack ) {
index 066ecbe..768dd7f 100644 (file)
@@ -31,7 +31,7 @@ interface RCFeedEngine {
         * @see RecentChange::cleanupForIRC
         * @param array $feed The feed, as configured in an associative array
         * @param string $line The text to send
-        * @return bool success
+        * @return bool Success
         */
        public function send( array $feed, $line );
 }
index 36e3a1b..a89b45f 100644 (file)
@@ -50,7 +50,7 @@ class ResourceLoader {
         */
        protected $testModuleNames = array();
 
-       /** @var array e.g. array( 'source-id' => array( 'loadScript' => 'http://.../load.php' ) ) */
+       /** @var array E.g. array( 'source-id' => array( 'loadScript' => 'http://.../load.php' ) ) */
        protected $sources = array();
 
        /** @var bool */
@@ -463,7 +463,7 @@ class ResourceLoader {
         *
         * @since 1.24
         * @param string $source
-        * @throws MWException on an invalid $source name
+        * @throws MWException On an invalid $source name
         * @return string
         */
        public function getLoadScript( $source ) {
@@ -1250,7 +1250,7 @@ class ResourceLoader {
         * Build a load.php URL
         *
         * @since 1.24
-        * @param string $source name of the ResourceLoader source
+        * @param string $source Name of the ResourceLoader source
         * @param ResourceLoaderContext $context
         * @param array $extraQuery
         * @return string URL to load.php. May be protocol-relative (if $wgLoadScript is procol-relative)
index 3a6d5d2..43bd562 100644 (file)
@@ -331,7 +331,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
        /**
         * Get loader script.
         *
-        * @return string|false JavaScript code to be added to startup module
+        * @return string|bool JavaScript code to be added to startup module
         */
        public function getLoaderScript() {
                if ( count( $this->loaderScripts ) === 0 ) {
@@ -804,7 +804,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @param bool $flip
         *
         * @return string CSS data in script file
-        * @throws MWException if the file doesn't exist
+        * @throws MWException If the file doesn't exist
         */
        protected function readStyleFile( $path, $flip ) {
                $localPath = $this->getLocalPath( $path );
index 73b6ea7..fe0c845 100644 (file)
@@ -34,7 +34,7 @@ class ResourceLoaderLanguageNamesModule extends ResourceLoaderModule {
 
 
        /**
-        * @param $context ResourceLoaderContext
+        * @param ResourceLoaderContext $context
         * @return array
         */
        protected function getData( ResourceLoaderContext $context ) {
@@ -45,7 +45,7 @@ class ResourceLoaderLanguageNamesModule extends ResourceLoaderModule {
        }
 
        /**
-        * @param $context ResourceLoaderContext
+        * @param ResourceLoaderContext $context
         * @return string JavaScript code
         */
        public function getScript( ResourceLoaderContext $context ) {
index 00d245c..0ace76a 100644 (file)
@@ -188,7 +188,7 @@ abstract class ResourceLoaderModule {
         * load the files directly. See also getScriptURLsForDebug()
         *
         * @param ResourceLoaderContext $context
-        * @return array array( mediaType => array( URL1, URL2, ... ), ... )
+        * @return array Array( mediaType => array( URL1, URL2, ... ), ... )
         */
        public function getStyleURLsForDebug( ResourceLoaderContext $context ) {
                $resourceLoader = $context->getResourceLoader();
@@ -548,7 +548,7 @@ abstract class ResourceLoaderModule {
                return false;
        }
 
-       /** @var JSParser lazy-initialized; use self::javaScriptParser() */
+       /** @var JSParser Lazy-initialized; use self::javaScriptParser() */
        private static $jsParser;
        private static $parseCacheVersion = 1;
 
index 87782ec..2c0f8df 100644 (file)
@@ -168,7 +168,7 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule {
         * This way we can reasonably reduce the amout of module registration
         * data send to the client.
         *
-        * @param Array &$registryData Modules keyed by name with properties:
+        * @param array &$registryData Modules keyed by name with properties:
         *  - string 'version'
         *  - array 'dependencies'
         *  - string|null 'group'
index e42301b..dc52969 100644 (file)
@@ -91,7 +91,7 @@ class RevisionDeleter {
         * Checks for a change in the bitfield for a certain option and updates the
         * provided array accordingly.
         *
-        * @param string $desc description to add to the array if the option was
+        * @param string $desc Description to add to the array if the option was
         * enabled / disabled.
         * @param int $field The bitmask describing the single option.
         * @param int $diff The xor of the old and new bitfields.
index 7923699..57cdaf4 100644 (file)
@@ -295,7 +295,7 @@ class SearchHighlighter {
        /**
         * Split text into lines and add it to extracts array
         *
-        * @param array $extracts index -> $line
+        * @param array $extracts Index -> $line
         * @param int $count
         * @param string $text
         */
index 56ae2ff..453211b 100644 (file)
@@ -217,7 +217,7 @@ class SearchResult {
        }
 
        /**
-        * @return string timestamp
+        * @return string Timestamp
         */
        function getTimestamp() {
                if ( $this->mRevision ) {
index ecc38e2..2d9f22d 100644 (file)
@@ -277,7 +277,7 @@ class SiteList extends GenericArrayObject {
                $group = new self();
 
                /**
-                * @var \Site $site
+                * @var Site $site
                 */
                foreach ( $this as $site ) {
                        if ( $site->getGroup() === $groupName ) {
index f968276..0070c74 100644 (file)
@@ -101,8 +101,8 @@ class SpecialPage {
         * @param string $name Name of the special page, as seen in links and URLs
         * @param string $restriction User right required, e.g. "block" or "delete"
         * @param bool $listed Whether the page is listed in Special:Specialpages
-        * @param callable|bool $function unused
-        * @param string $file unused
+        * @param callable|bool $function Unused
+        * @param string $file Unused
         * @param bool $includable Whether the page can be included in normal pages
         */
        public function __construct(
@@ -134,7 +134,7 @@ class SpecialPage {
        // @todo FIXME: Decide which syntax to use for this, and stick to it
        /**
         * Whether this special page is listed in Special:SpecialPages
-        * @since r3583 (v1.3)
+        * @since 1.3 (r3583)
         * @return bool
         */
        function isListed() {
@@ -328,7 +328,7 @@ class SpecialPage {
         *   - `prefixSearchSubpages( "" )` should return `array( foo", "bar", "baz" )`
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
index e4b606d..04e2f11 100644 (file)
@@ -45,7 +45,7 @@ class SpecialAllPages extends IncludableSpecialPage {
        /**
         * Constructor
         *
-        * @param string $name name of the special page, as seen in links and URLs (default: 'Allpages')
+        * @param string $name Name of the special page, as seen in links and URLs (default: 'Allpages')
         */
        function __construct( $name = 'Allpages' ) {
                parent::__construct( $name );
@@ -54,7 +54,7 @@ class SpecialAllPages extends IncludableSpecialPage {
        /**
         * Entry point : initialise variables and call subfunctions.
         *
-        * @param string $par becomes "FOO" when called like Special:Allpages/FOO (default null)
+        * @param string $par Becomes "FOO" when called like Special:Allpages/FOO (default null)
         */
        function execute( $par ) {
                $request = $this->getRequest();
index 8c46a93..f8b2e8d 100644 (file)
@@ -28,7 +28,7 @@
  * @ingroup SpecialPage
  */
 class SpecialBlock extends FormSpecialPage {
-       /** @var User user to be blocked, as passed either by parameter (url?wpTarget=Foo)
+       /** @var User User to be blocked, as passed either by parameter (url?wpTarget=Foo)
         * or as subpage (Special:Block/Foo) */
        protected $target;
 
@@ -454,7 +454,7 @@ class SpecialBlock extends FormSpecialPage {
        /**
         * Determine the target of the block, and the type of target
         * @todo Should be in Block.php?
-        * @param string $par subpage parameter passed to setup, or data value from
+        * @param string $par Subpage parameter passed to setup, or data value from
         *     the HTMLForm
         * @param WebRequest $request Optionally try and get data from a request too
         * @return array( User|string|null, Block::TYPE_ constant|null )
index ba5c7ec..ad1d597 100644 (file)
@@ -61,7 +61,7 @@ class SpecialChangePassword extends FormSpecialPage {
        /**
         * Set a message at the top of the Change Password form
         * @since 1.23
-        * @param Message $msg to parse and add to the form header
+        * @param Message $msg Message to parse and add to the form header
         */
        public function setChangeMessage( Message $msg ) {
                $this->mPreTextMessage = $msg;
@@ -230,7 +230,7 @@ class SpecialChangePassword extends FormSpecialPage {
        }
 
        /**
-        * @throws PasswordError when cannot set the new password because requirements not met.
+        * @throws PasswordError When cannot set the new password because requirements not met.
         */
        protected function attemptReset( $oldpass, $newpass, $retype ) {
                global $wgPasswordAttemptThrottle;
index 355726a..0896929 100644 (file)
@@ -121,7 +121,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
@@ -763,8 +763,8 @@ class EditWatchlistCheckboxSeriesField extends HTMLMultiSelectField {
         * form is open (bug 32126), but we know that invalid items will
         * be harmless so we can override it here.
         *
-        * @param string $value the value the field was submitted with
-        * @param array $alldata the data collected from the form
+        * @param string $value The value the field was submitted with
+        * @param array $alldata The data collected from the form
         * @return bool|string Bool true on success, or String error to display.
         */
        function validate( $value, $alldata ) {
index 0062211..0958126 100644 (file)
@@ -175,7 +175,7 @@ class SpecialEmailUser extends UnlistedSpecialPage {
        /**
         * Validate target User
         *
-        * @param string $target target user name
+        * @param string $target Target user name
         * @return User User object on success or a string on error
         */
        public static function getTarget( $target ) {
index 35a3ba1..ecbd353 100644 (file)
@@ -41,7 +41,7 @@ class SpecialExpandTemplates extends SpecialPage {
        /** @var bool Whether or not to remove <nowiki> tags in the expanded wikitext */
        protected $removeNowiki;
 
-       /** @var maximum size in bytes to include. 50MB allows fixing those huge pages */
+       /** @var int Maximum size in bytes to include. 50MB allows fixing those huge pages */
        const MAX_INCLUDE_SIZE = 50000000;
 
        function __construct() {
index bc8e728..2cf5bfe 100644 (file)
@@ -302,7 +302,7 @@ class SpecialExport extends SpecialPage {
        /**
         * Do the actual page exporting
         *
-        * @param string $page user input on what page(s) to export
+        * @param string $page User input on what page(s) to export
         * @param int $history One of the WikiExporter history export constants
         * @param bool $list_authors Whether to add distinct author list (when
         *   not returning full history)
@@ -536,7 +536,7 @@ class SpecialExport extends SpecialPage {
         * @param array $inputPages List of titles to look up
         * @param array $pageSet Associative array indexed by titles for output
         *
-        * @return array associative array index by titles
+        * @return array Associative array index by titles
         */
        private function getImages( $inputPages, $pageSet ) {
                return $this->getLinks(
index b6c9d55..354960b 100644 (file)
@@ -59,7 +59,7 @@ class FileDuplicateSearchPage extends QueryPage {
        /**
         * Fetch dupes from all connected file repositories.
         *
-        * @return array of File objects
+        * @return array Array of File objects
         */
        function getDupes() {
                return RepoGroup::singleton()->findBySha1( $this->hash );
@@ -67,7 +67,7 @@ class FileDuplicateSearchPage extends QueryPage {
 
        /**
         *
-        * @param array $dupes of File objects
+        * @param array $dupes Array of File objects
         */
        function showList( $dupes ) {
                $html = array();
index 03b3688..a67d3c0 100644 (file)
@@ -177,7 +177,7 @@ HTML;
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
index a77b70c..582f743 100644 (file)
@@ -217,12 +217,12 @@ class SpecialListGroupRights extends SpecialPage {
        /**
         * Create a user-readable list of permissions from the given array.
         *
-        * @param array $permissions of permission => bool (from $wgGroupPermissions items)
-        * @param array $revoke of permission => bool (from $wgRevokePermissions items)
-        * @param array $add of groups this group is allowed to add or true
-        * @param array $remove of groups this group is allowed to remove or true
-        * @param array $addSelf of groups this group is allowed to add to self or true
-        * @param array $removeSelf of group this group is allowed to remove from self or true
+        * @param array $permissions Array of permission => bool (from $wgGroupPermissions items)
+        * @param array $revoke Array of permission => bool (from $wgRevokePermissions items)
+        * @param array $add Array of groups this group is allowed to add or true
+        * @param array $remove Array of groups this group is allowed to remove or true
+        * @param array $addSelf Array of groups this group is allowed to add to self or true
+        * @param array $removeSelf Array of group this group is allowed to remove from self or true
         * @return string List of all granted permissions, separated by comma separator
         */
        private function formatPermissions( $permissions, $revoke, $add, $remove, $addSelf, $removeSelf ) {
index 53dddc7..feeafbc 100644 (file)
@@ -403,7 +403,7 @@ class SpecialListUsers extends IncludableSpecialPage {
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
index ced5d25..36abeb0 100644 (file)
@@ -119,7 +119,7 @@ class SpecialLog extends SpecialPage {
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
index a6c40d7..e1700de 100644 (file)
@@ -335,7 +335,7 @@ class SpecialMergeHistory extends SpecialPage {
         * The user may have to "undo" the redirect manually to finish the "unmerge".
         * Maybe this should delete redirects at the target page of merges?
         *
-        * @return boolean Success
+        * @return bool Success
         */
        function merge() {
                # Get the titles directly from the IDs, in case the target page params
index 7223efd..ee144d6 100644 (file)
@@ -126,7 +126,7 @@ class MovePageForm extends UnlistedSpecialPage {
        /**
         * Show the form
         *
-        * @param array $err error messages. Each item is an error message.
+        * @param array $err Error messages. Each item is an error message.
         *    It may either be a string message name or array message name and
         *    parameters, like the second argument to OutputPage::wrapWikiMsg().
         */
index 01bf0ec..cef0411 100644 (file)
@@ -59,7 +59,7 @@ class SpecialMyLanguage extends RedirectSpecialArticle {
         * it returns Page/fi if it exists, otherwise Page/de if it exists,
         * otherwise Page.
         *
-        * @param $par
+        * @param string $par
         * @return Title|null
         */
        public function findTitle( $par ) {
index 24eca07..75880d1 100644 (file)
@@ -30,7 +30,7 @@
  */
 class SpecialPageLanguage extends FormSpecialPage {
        /**
-        * @var $goToUrl URL to go to if language change successful
+        * @var string URL to go to if language change successful
         */
        private $goToUrl;
 
index 05f0b2b..f5b19cc 100644 (file)
@@ -82,7 +82,7 @@ class SpecialPagesWithProp extends QueryPage {
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
index 2707916..8c01ef2 100644 (file)
@@ -239,7 +239,7 @@ class SpecialRandomInCategory extends SpecialPage {
         *
         * @param Title $category
         * @return array The lowest and highest timestamp
-        * @throws MWException if category has no entries.
+        * @throws MWException If category has no entries.
         */
        protected function getMinAndMaxForCat( Title $category ) {
                $dbr = wfGetDB( DB_SLAVE );
index 4926d6d..774fd80 100644 (file)
@@ -66,7 +66,7 @@ class SpecialRedirect extends FormSpecialPage {
        /**
         * Handle Special:Redirect/user/xxxx (by redirecting to User:YYYY)
         *
-        * @return string|null url to redirect to, or null if $mValue is invalid.
+        * @return string|null Url to redirect to, or null if $mValue is invalid.
         */
        function dispatchUser() {
                if ( !ctype_digit( $this->mValue ) ) {
@@ -85,7 +85,7 @@ class SpecialRedirect extends FormSpecialPage {
        /**
         * Handle Special:Redirect/file/xxxx
         *
-        * @return string|null url to redirect to, or null if $mValue is not found.
+        * @return string|null Url to redirect to, or null if $mValue is not found.
         */
        function dispatchFile() {
                $title = Title::makeTitleSafe( NS_FILE, $this->mValue );
@@ -121,7 +121,7 @@ class SpecialRedirect extends FormSpecialPage {
         * Handle Special:Redirect/revision/xxx
         * (by redirecting to index.php?oldid=xxx)
         *
-        * @return string|null url to redirect to, or null if $mValue is invalid.
+        * @return string|null Url to redirect to, or null if $mValue is invalid.
         */
        function dispatchRevision() {
                $oldid = $this->mValue;
@@ -141,7 +141,7 @@ class SpecialRedirect extends FormSpecialPage {
        /**
         * Handle Special:Redirect/page/xxx (by redirecting to index.php?curid=xxx)
         *
-        * @return string|null url to redirect to, or null if $mValue is invalid.
+        * @return string|null Url to redirect to, or null if $mValue is invalid.
         */
        function dispatchPage() {
                $curid = $this->mValue;
@@ -164,7 +164,7 @@ class SpecialRedirect extends FormSpecialPage {
         * or do nothing (if $mValue wasn't set) allowing the form to be
         * displayed.
         *
-        * @return bool true if a redirect was successfully handled.
+        * @return bool True if a redirect was successfully handled.
         */
        function dispatch() {
                // the various namespaces supported by Special:Redirect
index 9cec847..93df289 100644 (file)
@@ -160,6 +160,14 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                if ( !$this->typeName || count( $this->ids ) == 0 ) {
                        throw new ErrorPageError( 'revdelete-nooldid-title', 'revdelete-nooldid-text' );
                }
+
+               # Allow the list type to adjust the passed target
+               $this->targetObj = RevisionDeleter::suggestTarget(
+                       $this->typeName,
+                       $this->targetObj,
+                       $this->ids
+               );
+
                $this->typeLabels = self::$UILabels[$this->typeName];
                $list = $this->getList();
                $list->reset();
@@ -170,13 +178,6 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $pageIsSuppressed = $bitfield & Revision::DELETED_RESTRICTED;
                $this->mIsAllowed = $this->mIsAllowed && !( $canViewSuppressedOnly && $pageIsSuppressed );
 
-               # Allow the list type to adjust the passed target
-               $this->targetObj = RevisionDeleter::suggestTarget(
-                       $this->typeName,
-                       $this->targetObj,
-                       $this->ids
-               );
-
                $this->otherReason = $request->getVal( 'wpReason' );
                # We need a target page!
                if ( is_null( $this->targetObj ) ) {
index b977292..54f224a 100644 (file)
@@ -47,7 +47,7 @@ class SpecialRunJobs extends UnlistedSpecialPage {
                        return;
                }
 
-               $optional = array( 'maxjobs' => 0 );
+               $optional = array( 'maxjobs' => 0, 'maxtime' => 30, 'type' => false, 'async' => true );
                $required = array_flip( array( 'title', 'tasks', 'signature', 'sigexpiry' ) );
 
                $params = array_intersect_key( $this->getRequest()->getValues(), $required + $optional );
@@ -75,18 +75,28 @@ class SpecialRunJobs extends UnlistedSpecialPage {
                // Apply any default parameter values
                $params += $optional;
 
-               // Client will usually disconnect before checking the response,
-               // but it needs to know when it is safe to disconnect. Until this
-               // reaches ignore_user_abort(), it is not safe as the jobs won't run.
-               ignore_user_abort( true ); // jobs may take a bit of time
-               header( "HTTP/1.0 202 Accepted" );
-               ob_flush();
-               flush();
-               // Once the client receives this response, it can disconnect
+               if ( $params['async'] ) {
+                       // Client will usually disconnect before checking the response,
+                       // but it needs to know when it is safe to disconnect. Until this
+                       // reaches ignore_user_abort(), it is not safe as the jobs won't run.
+                       ignore_user_abort( true ); // jobs may take a bit of time
+                       header( "HTTP/1.0 202 Accepted" );
+                       ob_flush();
+                       flush();
+                       // Once the client receives this response, it can disconnect
+               }
 
                // Do all of the specified tasks...
                if ( in_array( 'jobs', explode( '|', $params['tasks'] ) ) ) {
-                       self::executeJobs( (int)$params['maxjobs'] );
+                       $runner = new JobRunner();
+                       $response = $runner->run( array(
+                               'type'     => $params['type'],
+                               'maxJobs'  => $params['maxjobs'] ? $params['maxjobs'] : 1,
+                               'maxTime'  => $params['maxtime'] ? $params['maxjobs'] : 30
+                       ) );
+                       if ( !$params['async'] ) {
+                               print FormatJson::encode( $response, true );
+                       }
                }
        }
 
@@ -100,52 +110,4 @@ class SpecialRunJobs extends UnlistedSpecialPage {
                ksort( $query ); // stable order
                return hash_hmac( 'sha1', wfArrayToCgi( $query ), $wgSecretKey );
        }
-
-       /**
-        * Run jobs from the job queue
-        *
-        * @note also called from Wiki.php
-        *
-        * @param int $maxJobs Maximum number of jobs to run
-        * @return void
-        */
-       public static function executeJobs( $maxJobs ) {
-               $n = $maxJobs; // number of jobs to run
-               if ( $n < 1 ) {
-                       return;
-               }
-               try {
-                       $group = JobQueueGroup::singleton();
-                       $count = $group->executeReadyPeriodicTasks();
-                       if ( $count > 0 ) {
-                               wfDebugLog( 'jobqueue', "Executed $count periodic queue task(s)." );
-                       }
-
-                       do {
-                               $job = $group->pop( JobQueueGroup::TYPE_DEFAULT, JobQueueGroup::USE_CACHE );
-                               if ( $job ) {
-                                       $output = $job->toString() . "\n";
-                                       $t = -microtime( true );
-                                       wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
-                                       $success = $job->run();
-                                       wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
-                                       $group->ack( $job ); // done
-                                       $t += microtime( true );
-                                       $t = round( $t * 1000 );
-                                       if ( $success === false ) {
-                                               $output .= "Error: " . $job->getLastError() . ", Time: $t ms\n";
-                                       } else {
-                                               $output .= "Success, Time: $t ms\n";
-                                       }
-                                       wfDebugLog( 'jobqueue', $output );
-                               }
-                       } while ( --$n && $job );
-               } catch ( MWException $e ) {
-                       MWExceptionHandler::rollbackMasterChangesAndLog( $e );
-                       // We don't want exceptions thrown during job execution to
-                       // be reported to the user since the output is already sent.
-                       // Instead we just log them.
-                       MWExceptionHandler::logException( $e );
-               }
-       }
 }
index 15a7b59..541faa1 100644 (file)
@@ -406,7 +406,7 @@ class SpecialSearch extends SpecialPage {
         * @param Title $title
         * @param int $num The number of search results found
         * @param null|SearchResultSet $titleMatches Results from title search
-        * @param null|SearchResultSet $textMatches  Results from text search
+        * @param null|SearchResultSet $textMatches Results from text search
         */
        protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
                // show direct page/create link if applicable
@@ -798,7 +798,7 @@ class SpecialSearch extends SpecialPage {
         * @param SearchResult $result
         * @param string $lastInterwiki
         * @param string $query
-        * @param array $customCaptions iw prefix -> caption
+        * @param array $customCaptions Interwiki prefix -> caption
         *
         * @return string
         */
index fc18706..4fd7cd4 100644 (file)
@@ -1144,7 +1144,7 @@ class UploadForm extends HTMLForm {
        /**
         * Empty function; submission is handled elsewhere.
         *
-        * @return bool false
+        * @return bool False
         */
        function trySubmit() {
                return false;
index 75ab19f..cb821cb 100644 (file)
@@ -57,7 +57,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
        /**
         * Execute page -- can output a file directly or show a listing of them.
         *
-        * @param string $subPage subpage, e.g. in
+        * @param string $subPage Subpage, e.g. in
         *   http://example.com/wiki/Special:UploadStash/foo.jpg, the "foo.jpg" part
         * @return bool Success
         */
@@ -75,7 +75,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         * If file available in stash, cats it out to the client as a simple HTTP response.
         * n.b. Most sanity checking done in UploadStashLocalFile, so this is straightforward.
         *
-        * @param string $key the key of a particular requested file
+        * @param string $key The key of a particular requested file
         * @throws HttpError
         * @return bool
         */
@@ -227,7 +227,7 @@ class SpecialUploadStash extends UnlistedSpecialPage {
         * @param array $params Scaling parameters ( e.g. array( width => '50' ) );
         * @param int $flags Scaling flags ( see File:: constants )
         * @throws MWException
-        * @return bool success
+        * @return bool Success
         */
        private function outputRemoteScaledThumb( $file, $params, $flags ) {
                // This global probably looks something like
index 1ef96c3..0b11968 100644 (file)
@@ -1048,7 +1048,7 @@ class LoginForm extends SpecialPage {
        /**
         * Display a "successful action" page.
         *
-        * @param string $type condition of return to; see `executeReturnTo`
+        * @param string $type Condition of return to; see `executeReturnTo`
         * @param string|Message $title Page's title
         * @param string $msgname
         * @param string $injected_html
index 411970e..0ec85ba 100644 (file)
@@ -715,7 +715,7 @@ class UserrightsPage extends SpecialPage {
        /**
         * Returns $this->getUser()->changeableGroups()
         *
-        * @return array array(
+        * @return array Array(
         *   'add' => array( addablegroups ),
         *   'remove' => array( removablegroups ),
         *   'add-self' => array( addablegroups to self ),
index 28ad0f4..8ca9e23 100644 (file)
@@ -307,7 +307,7 @@ class SpecialVersion extends SpecialPage {
        }
 
        /**
-        * @return string wgVersion + a link to subversion revision of svn BASE
+        * @return string Global wgVersion + a link to subversion revision of svn BASE
         */
        private static function getVersionLinkedSvn() {
                global $IP;
@@ -349,7 +349,7 @@ class SpecialVersion extends SpecialPage {
 
        /**
         * @since 1.22 Returns the HEAD date in addition to the sha1 and link
-        * @return bool|string wgVersion + HEAD sha1 stripped to the first 7 chars
+        * @return bool|string Global wgVersion + HEAD sha1 stripped to the first 7 chars
         *   with link and date, or false on failure
         */
        private static function getVersionLinkedGit() {
index 372886c..b1fbdea 100644 (file)
@@ -83,7 +83,7 @@ class SpecialWatchlist extends ChangesListSpecialPage {
         * Return an array of subpages beginning with $search that this special page will accept.
         *
         * @param string $search Prefix to search for
-        * @param integer $limit Maximum number of results to return
+        * @param int $limit Maximum number of results to return
         * @return string[] Matching subpages
         */
        public function prefixSearchSubpages( $search, $limit = 10 ) {
index c593dca..f46cb5e 100644 (file)
@@ -45,7 +45,7 @@ class MediaWikiPageLinkRenderer implements PageLinkRenderer {
         * HtmlPageLinkRenderer, we will be using them, so it seems prudent to
         * already declare the dependency and inject them.
         *
-        * @param TitleFormatter $formatter formatter for generating the target title string
+        * @param TitleFormatter $formatter Formatter for generating the target title string
         * @param string $baseUrl (currently unused, pending refactoring of Linker).
         *        Defaults to $wgArticlePath.
         */
@@ -62,7 +62,7 @@ class MediaWikiPageLinkRenderer implements PageLinkRenderer {
         * Returns the (partial) URL for the given page (including any section identifier).
         *
         * @param TitleValue $page The link's target
-        * @param array $params any additional URL parameters.
+        * @param array $params Any additional URL parameters.
         *
         * @return string
         */
index 3a9ab40..12b7143 100644 (file)
@@ -49,8 +49,8 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
        protected $localInterwikis;
 
        /**
-        * @param Language $language the language object to use for localizing namespace names.
-        * @param GenderCache $genderCache the gender cache for generating gendered namespace names
+        * @param Language $language The language object to use for localizing namespace names.
+        * @param GenderCache $genderCache The gender cache for generating gendered namespace names
         * @param string[]|string $localInterwikis
         */
        public function __construct( Language $language, GenderCache $genderCache,
@@ -67,7 +67,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
         * @param int $namespace
         * @param string $text
         *
-        * @throws InvalidArgumentException if the namespace is invalid
+        * @throws InvalidArgumentException If the namespace is invalid
         * @return string
         */
        public function getNamespaceName( $namespace, $text ) {
@@ -97,7 +97,7 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser {
         *        Underscores will be replaced.
         * @param string $fragment The fragment name (may be empty).
         *
-        * @throws InvalidArgumentException if the namespace is invalid
+        * @throws InvalidArgumentException If the namespace is invalid
         * @return string
         */
        public function formatTitle( $namespace, $text, $fragment = '' ) {
index a277594..fb1096e 100644 (file)
@@ -37,7 +37,7 @@ interface PageLinkRenderer {
         * @todo expand this to cover the functionality of Linker::linkUrl
         *
         * @param TitleValue $page The link's target
-        * @param array $params any additional URL parameters.
+        * @param array $params Any additional URL parameters.
         *
         * @return string
         */
index cb28028..7c71ef5 100644 (file)
@@ -50,7 +50,7 @@ interface TitleFormatter {
         *
         * @note Only minimal normalization is applied. Consider using TitleValue::getText() directly.
         *
-        * @param TitleValue $title the title to format
+        * @param TitleValue $title The title to format
         *
         * @return string
         */
@@ -59,7 +59,7 @@ interface TitleFormatter {
        /**
         * Returns the title formatted for display, including the namespace name.
         *
-        * @param TitleValue $title the title to format
+        * @param TitleValue $title The title to format
         *
         * @return string
         */
@@ -68,7 +68,7 @@ interface TitleFormatter {
        /**
         * Returns the title formatted for display, with namespace and fragment.
         *
-        * @param TitleValue $title the title to format
+        * @param TitleValue $title The title to format
         *
         * @return string
         */
index d548663..0635ee8 100644 (file)
@@ -37,8 +37,8 @@ interface TitleParser {
         *
         * @note this only parses local page links, interwiki-prefixes etc. are not considered!
         *
-        * @param string $text the text to parse
-        * @param int $defaultNamespace namespace to assume per default (usually NS_MAIN)
+        * @param string $text The text to parse
+        * @param int $defaultNamespace Namespace to assume per default (usually NS_MAIN)
         *
         * @throws MalformedTitleException If the text is not a valid representation of a page title.
         * @return TitleValue
index 5defd45..24a93e4 100644 (file)
@@ -283,7 +283,7 @@ abstract class UploadBase {
 
        /**
         * Verify whether the upload is sane.
-        * @return mixed self::OK or else an array with error information
+        * @return mixed Const self::OK or else an array with error information
         */
        public function verifyUpload() {
                wfProfileIn( __METHOD__ );
@@ -593,7 +593,7 @@ abstract class UploadBase {
         * isAllowed() should be called as well for generic is-user-blocked or
         * can-user-upload checking.
         *
-        * @param User $user object to verify the permissions against
+        * @param User $user User object to verify the permissions against
         * @return mixed An array as returned by getUserPermissionsErrors or true
         *   in case the user has proper permissions.
         */
@@ -1276,8 +1276,8 @@ abstract class UploadBase {
 
        /**
         * Callback to filter SVG Processing Instructions.
-        * @param string $target processing instruction name
-        * @param string $data processing instruction attribute and value
+        * @param string $target Processing instruction name
+        * @param string $data Processing instruction attribute and value
         * @return bool (true if the filter identified something bad)
         */
        public static function checkSvgPICallback( $target, $data ) {
index 6f90280..bea7128 100644 (file)
@@ -68,7 +68,7 @@ class UploadFromChunks extends UploadFromFile {
         * Calls the parent stashFile and updates the uploadsession table to handle "chunks"
         *
         * @param User|null $user
-        * @return UploadStashFile stashed file
+        * @return UploadStashFile Stashed file
         */
        public function stashFile( User $user = null ) {
                // Stash file is the called on creating a new chunk session:
@@ -201,9 +201,9 @@ class UploadFromChunks extends UploadFromFile {
        /**
         * Add a chunk to the temporary directory
         *
-        * @param string $chunkPath path to temporary chunk file
-        * @param int $chunkSize size of the current chunk
-        * @param int $offset offset of current chunk ( mutch match database chunk offset )
+        * @param string $chunkPath Path to temporary chunk file
+        * @param int $chunkSize Size of the current chunk
+        * @param int $offset Offset of current chunk ( mutch match database chunk offset )
         * @return Status
         */
        public function addChunk( $chunkPath, $chunkSize, $offset ) {
index a7e7100..23a7a3a 100644 (file)
@@ -167,7 +167,7 @@ class UploadStash {
        /**
         * Getter for file metadata.
         *
-        * @param string $key key under which file information is stored
+        * @param string $key Key under which file information is stored
         * @return array
         */
        public function getMetadata( $key ) {
@@ -179,7 +179,7 @@ class UploadStash {
        /**
         * Getter for fileProps
         *
-        * @param string $key key under which file information is stored
+        * @param string $key Key under which file information is stored
         * @return array
         */
        public function getFileProps( $key ) {
@@ -523,7 +523,7 @@ class UploadStash {
        /**
         * Helper function: Initialize the UploadStashFile for a given file.
         *
-        * @param string $key key under which to store the object
+        * @param string $key Key under which to store the object
         * @throws UploadStashZeroLengthFileException
         * @return bool
         */
index b6df18b..1e521cb 100644 (file)
@@ -151,8 +151,7 @@ class ArrayUtils {
         * @since 1.23
         *
         * @param array $array1 The array to compare from
-        * @param array $array2 An array to compare against
-        * @param array ... More arrays to compare against
+        * @param array $array2,... More arrays to compare against
         * @return array An array containing all the values from array1
         *               that are not present in any of the other arrays.
         */
index c730de8..e235ad0 100644 (file)
        "importlogpage": "Import log",
        "importlogpagetext": "Administrative imports of pages with edit history from other wikis.",
        "import-logentry-upload": "imported [[$1]] by file upload",
-       "import-logentry-upload-detail": "$1 {{PLURAL:$1|revision|revisions}}",
+       "import-logentry-upload-detail": "$1 {{PLURAL:$1|revision|revisions}} imported",
        "import-logentry-interwiki": "transwikied $1",
-       "import-logentry-interwiki-detail": "$1 {{PLURAL:$1|revision|revisions}} from $2",
+       "import-logentry-interwiki-detail": "$1 {{PLURAL:$1|revision|revisions}} imported from $2",
        "javascripttest": "JavaScript testing",
        "javascripttest-backlink": "< $1",
        "javascripttest-title": "Running $1 tests",
index d54d721..ea6a839 100644 (file)
        "importlogpage": "{{doc-logpage}}",
        "importlogpagetext": "This text appears at the top of the [{{canonicalurl:Special:Log|type=import}} import log] special page.",
        "import-logentry-upload": "This is the text of an entry in the Import log (and Recent Changes), after hour (and date, only in the Import log) and sysop name:\n* $1 is the name of the imported file",
-       "import-logentry-upload-detail": "Used as success message. Parameters:\n* $1 - number of succeeded revisions\nSee also:\n* {{msg-mw|Import-logentry-interwiki-detail}}",
+       "import-logentry-upload-detail": "Used as success message and log entry. Parameters:\n* $1 - number of succeeded revisions\nSee also:\n* {{msg-mw|Import-logentry-interwiki-detail}}",
        "import-logentry-interwiki": "Used as action listed in the log. Parameters:\n* $1 - page title",
-       "import-logentry-interwiki-detail": "Used as success message. Parameters:\n* $1 - number of succeeded revisions\n* $2 - interwiki name\nSee also:\n* {{msg-mw|Import-logentry-upload-detail}}",
+       "import-logentry-interwiki-detail": "Used as success message and log entry. Parameters:\n* $1 - number of succeeded revisions\n* $2 - interwiki name\nSee also:\n* {{msg-mw|Import-logentry-upload-detail}}",
        "javascripttest": "Title of the special page [[Special:JavaScriptTest]].\n\nSee also:\n* {{msg-mw|Javascripttest|title}}\n* {{msg-mw|Javascripttest-pagetext-noframework|summary}}\n* {{msg-mw|Javascripttest-pagetext-unknownframework|error message}}",
        "javascripttest-backlink": "{{optional}}\nUsed as subtitle in [[Special:JavaScriptTest]]. Parameters:\n* $1 - page title",
        "javascripttest-title": "Title of the special page when running a test suite. Parameters:\n* $1 is the name of the framework, for example QUnit.",
index e56640f..3e6fa52 100644 (file)
@@ -65,214 +65,21 @@ class RunJobs extends Maintenance {
                        }
                }
 
-               $type = $this->getOption( 'type', false );
-               $maxJobs = $this->getOption( 'maxjobs', false );
-               $maxTime = $this->getOption( 'maxtime', false );
-               $noThrottle = $this->hasOption( 'nothrottle' );
-               $startTime = time();
-
-               $group = JobQueueGroup::singleton();
-               // Handle any required periodic queue maintenance
-               $count = $group->executeReadyPeriodicTasks();
-               if ( $count > 0 ) {
-                       $this->runJobsLog( "Executed $count periodic queue task(s)." );
-               }
-
-               $backoffs = $this->loadBackoffs(); // map of (type => UNIX expiry)
-               $startingBackoffs = $backoffs; // avoid unnecessary writes
-               $backoffExpireFunc = function ( $t ) {
-                       return $t > time();
-               };
-
-               $jobsRun = 0; // counter
-               $flags = JobQueueGroup::USE_CACHE;
-               $lastTime = microtime( true ); // time since last slave check
-               do {
-                       $backoffs = array_filter( $backoffs, $backoffExpireFunc );
-                       $blacklist = $noThrottle ? array() : array_keys( $backoffs );
-                       if ( $type === false ) {
-                               $job = $group->pop( JobQueueGroup::TYPE_DEFAULT, $flags, $blacklist );
-                       } elseif ( in_array( $type, $blacklist ) ) {
-                               $job = false; // requested queue in backoff state
-                       } else {
-                               $job = $group->pop( $type ); // job from a single queue
-                       }
-                       if ( $job ) { // found a job
-                               ++$jobsRun;
-                               $this->runJobsLog( $job->toString() . " STARTING" );
-
-                               // Run the job...
-                               wfProfileIn( __METHOD__ . '-' . get_class( $job ) );
-                               $t = microtime( true );
-                               try {
-                                       $status = $job->run();
-                                       $error = $job->getLastError();
-                               } catch ( MWException $e ) {
-                                       MWExceptionHandler::rollbackMasterChangesAndLog( $e );
-                                       $status = false;
-                                       $error = get_class( $e ) . ': ' . $e->getMessage();
-                                       $e->report(); // write error to STDERR and the log
-                               }
-                               $timeMs = intval( ( microtime( true ) - $t ) * 1000 );
-                               wfProfileOut( __METHOD__ . '-' . get_class( $job ) );
-
-                               // Mark the job as done on success or when the job cannot be retried
-                               if ( $status !== false || !$job->allowRetries() ) {
-                                       $group->ack( $job ); // done
-                               }
-
-                               if ( $status === false ) {
-                                       $this->runJobsLog( $job->toString() . " t=$timeMs error={$error}" );
-                               } else {
-                                       $this->runJobsLog( $job->toString() . " t=$timeMs good" );
-                               }
-
-                               // Back off of certain jobs for a while (for throttling and for errors)
-                               $ttw = $this->getBackoffTimeToWait( $job );
-                               if ( $status === false && mt_rand( 0, 49 ) == 0 ) {
-                                       $ttw = max( $ttw, 30 );
-                               }
-                               if ( $ttw > 0 ) {
-                                       $jType = $job->getType();
-                                       $backoffs[$jType] = isset( $backoffs[$jType] ) ? $backoffs[$jType] : 0;
-                                       $backoffs[$jType] = max( $backoffs[$jType], time() + $ttw );
-                               }
-
-                               // Break out if we hit the job count or wall time limits...
-                               if ( $maxJobs && $jobsRun >= $maxJobs ) {
-                                       break;
-                               } elseif ( $maxTime && ( time() - $startTime ) > $maxTime ) {
-                                       break;
-                               }
-
-                               // Don't let any of the main DB slaves get backed up
-                               $timePassed = microtime( true ) - $lastTime;
-                               if ( $timePassed >= 5 || $timePassed < 0 ) {
-                                       wfWaitForSlaves( $lastTime );
-                                       $lastTime = microtime( true );
-                               }
-                               // Don't let any queue slaves/backups fall behind
-                               if ( $jobsRun > 0 && ( $jobsRun % 100 ) == 0 ) {
-                                       $group->waitForBackups();
-                               }
-
-                               // Bail if near-OOM instead of in a job
-                               $this->assertMemoryOK();
-                       }
-               } while ( $job ); // stop when there are no jobs
-               // Sync the persistent backoffs for the next runJobs.php pass
-               $backoffs = array_filter( $backoffs, $backoffExpireFunc );
-               if ( $backoffs !== $startingBackoffs ) {
-                       $this->syncBackoffs( $backoffs );
-               }
-       }
-
-       /**
-        * @param Job $job
-        * @return int Seconds for this runner to avoid doing more jobs of this type
-        * @see $wgJobBackoffThrottling
-        */
-       private function getBackoffTimeToWait( Job $job ) {
-               global $wgJobBackoffThrottling;
-
-               if ( !isset( $wgJobBackoffThrottling[$job->getType()] ) ||
-                       $job instanceof DuplicateJob // no work was done
-               ) {
-                       return 0; // not throttled
-               }
-
-               $itemsPerSecond = $wgJobBackoffThrottling[$job->getType()];
-               if ( $itemsPerSecond <= 0 ) {
-                       return 0; // not throttled
-               }
-
-               $seconds = 0;
-               if ( $job->workItemCount() > 0 ) {
-                       $exactSeconds = $job->workItemCount() / $itemsPerSecond;
-                       // use randomized rounding
-                       $seconds = floor( $exactSeconds );
-                       $remainder = $exactSeconds - $seconds;
-                       $seconds += ( mt_rand() / mt_getrandmax() < $remainder ) ? 1 : 0;
-               }
-
-               return (int)$seconds;
-       }
-
-       /**
-        * Get the previous backoff expiries from persistent storage
-        *
-        * @return array Map of (job type => backoff expiry timestamp)
-        */
-       private function loadBackoffs() {
-               $section = new ProfileSection( __METHOD__ );
-
-               $backoffs = array();
-               $file = wfTempDir() . '/mw-runJobs-backoffs.json';
-               if ( is_file( $file ) ) {
-                       $handle = fopen( $file, 'rb' );
-                       flock( $handle, LOCK_SH );
-                       $content = stream_get_contents( $handle );
-                       flock( $handle, LOCK_UN );
-                       fclose( $handle );
-                       $backoffs = json_decode( $content, true ) ? : array();
-               }
-
-               return $backoffs;
-       }
-
-       /**
-        * Merge the current backoff expiries from persistent storage
-        *
-        * @param array $backoffs Map of (job type => backoff expiry timestamp)
-        */
-       private function syncBackoffs( array $backoffs ) {
-               $section = new ProfileSection( __METHOD__ );
-
-               $file = wfTempDir() . '/mw-runJobs-backoffs.json';
-               $handle = fopen( $file, 'wb+' );
-               flock( $handle, LOCK_EX );
-               $content = stream_get_contents( $handle );
-               $cBackoffs = json_decode( $content, true ) ? : array();
-               foreach ( $backoffs as $type => $timestamp ) {
-                       $cBackoffs[$type] = isset( $cBackoffs[$type] ) ? $cBackoffs[$type] : 0;
-                       $cBackoffs[$type] = max( $cBackoffs[$type], $backoffs[$type] );
-               }
-               ftruncate( $handle, 0 );
-               fwrite( $handle, json_encode( $backoffs ) );
-               flock( $handle, LOCK_UN );
-               fclose( $handle );
-       }
-
-       /**
-        * Make sure that this script is not too close to the memory usage limit.
-        * It is better to die in between jobs than OOM right in the middle of one.
-        * @throws MWException
-        */
-       private function assertMemoryOK() {
-               static $maxBytes = null;
-               if ( $maxBytes === null ) {
-                       $m = array();
-                       if ( preg_match( '!^(\d+)(k|m|g|)$!i', ini_get( 'memory_limit' ), $m ) ) {
-                               list( , $num, $unit ) = $m;
-                               $conv = array( 'g' => 1073741824, 'm' => 1048576, 'k' => 1024, '' => 1 );
-                               $maxBytes = $num * $conv[strtolower( $unit )];
-                       } else {
-                               $maxBytes = 0;
-                       }
-               }
-               $usedBytes = memory_get_usage();
-               if ( $maxBytes && $usedBytes >= 0.95 * $maxBytes ) {
-                       throw new MWException( "Detected excessive memory usage ($usedBytes/$maxBytes)." );
-               }
+               $runner = new JobRunner();
+               $runner->setDebugHandler( array( $this, 'debugInternal' ) );
+               $runner->run( array(
+                       'type'     => $this->getOption( 'type', false ),
+                       'maxJobs'  => $this->getOption( 'maxjobs', false ),
+                       'maxTime'  => $this->getOption( 'maxtime', false ),
+                       'throttle' => $this->hasOption( 'nothrottle' ) ? false : true,
+               ) );
        }
 
        /**
-        * Log the job message
-        * @param string $msg The message to log
+        * @param string $s
         */
-       private function runJobsLog( $msg ) {
-               $this->output( wfTimestamp( TS_DB ) . " $msg\n" );
-               wfDebugLog( 'runJobs', $msg );
+       public function debugInternal( $s ) {
+               $this->output( $s );
        }
 }