/**
* Like array_diff( $a, $b ) except that it works with two-dimensional arrays.
- * @param $a array
- * @param $b array
+ * @param array $a
+ * @param array $b
* @return array
*/
function wfArrayDiff2( $a, $b ) {
}
/**
- * @param $a array|string
- * @param $b array|string
+ * @param array|string $a
+ * @param array|string $b
* @return int
*/
function wfArrayDiff2_cmp( $a, $b ) {
* values in array $a with the corresponding keys
*
* @deprecated since 1.22; use array_intersect_key()
- * @param $a Array
- * @param $b Array
+ * @param array $a
+ * @param array $b
* @return array
*/
function wfArrayLookup( $a, $b ) {
/**
* Appends to second array if $value differs from that in $default
*
- * @param $key String|Int
- * @param $value Mixed
- * @param $default Mixed
- * @param array $changed to alter
+ * @param string|int $key
+ * @param mixed $value
+ * @param mixed $default
+ * @param array $changed Array to alter
* @throws MWException
*/
function wfAppendToArrayIfNotDefault( $key, $value, $default, &$changed ) {
*
* @param array $array The array.
* @param array $insert The array to insert.
- * @param $after Mixed: The key to insert after
- * @return Array
+ * @param mixed $after The key to insert after
+ * @return array
*/
function wfArrayInsertAfter( array $array, array $insert, $after ) {
// Find the offset of the element to insert after.
/**
* Recursively converts the parameter (an object) to an array with the same data
*
- * @param $objOrArray Object|Array
- * @param $recursive Bool
- * @return Array
+ * @param object|array $objOrArray
+ * @param bool $recursive
+ * @return array
*/
function wfObjectToArray( $objOrArray, $recursive = true ) {
$array = array();
* of token please use MWCryptRand instead.
*
* @param int $length The length of the string to generate
- * @return String
+ * @return string
* @since 1.20
*/
function wfRandomString( $length = 32 ) {
*
* %2F in the page titles seems to fatally break for some reason.
*
- * @param $s String:
+ * @param string $s
* @return string
*/
function wfUrlencode( $s ) {
*
* @param array $array1 ( String|Array )
* @param array $array2 ( String|Array )
- * @param $prefix String
- * @return String
+ * @param string $prefix
+ * @return string
*/
function wfArrayToCgi( $array1, $array2 = null, $prefix = '' ) {
if ( !is_null( $array2 ) ) {
* with legacy functions that accept raw query strings instead of nice
* arrays. Of course, keys and values are urldecode()d.
*
- * @param string $query query string
+ * @param string $query Query string
* @return string[] Array version of input
*/
function wfCgiToArray( $query ) {
* @todo this won't work with current-path-relative URLs
* like "subdir/foo.html", etc.
*
- * @param string $url either fully-qualified or a local path + query
- * @param $defaultProto Mixed: one of the PROTO_* constants. Determines the
+ * @param string $url Either fully-qualified or a local path + query
+ * @param string $defaultProto One of the PROTO_* constants. Determines the
* protocol to use if $url or $wgServer is protocol-relative
* @return string Fully-qualified URL, current-path-relative URL or false if
* no valid URL can be constructed
*
* @param bool $includeProtocolRelative If false, remove '//' from the returned protocol list.
* DO NOT USE this directly, use wfUrlProtocolsWithoutProtRel() instead
- * @return String
+ * @return string
*/
function wfUrlProtocols( $includeProtocolRelative = true ) {
global $wgUrlProtocols;
* Like wfUrlProtocols(), but excludes '//' from the protocol list. Use this if
* you need a regex that matches all URL protocols but does not match protocol-
* relative URLs
- * @return String
+ * @return string
*/
function wfUrlProtocolsWithoutProtRel() {
return wfUrlProtocols( false );
* protocol-relative URLs) correctly.
* 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2)).
*
- * @param string $url a URL to parse
+ * @param string $url A URL to parse
* @return string[] Bits of the URL in an associative array, per PHP docs
*/
function wfParseUrl( $url ) {
*
* @todo handle punycode domains too
*
- * @param $url string
+ * @param string $url
* @return string
*/
function wfExpandIRI( $url ) {
/**
* Make URL indexes, appropriate for the el_index field of externallinks.
*
- * @param $url String
+ * @param string $url
* @return array
*/
function wfMakeUrlIndexes( $url ) {
* $wgDebugRawPage - if false, 'action=raw' hits will not result in debug output.
* $wgDebugComments - if on, some debug items may appear in comments in the HTML output.
*
- * @param $text String
+ * @param string $text
* @param string|bool $dest Destination of the message:
* - 'all': both to the log and HTML (debug toolbar or HTML comments)
* - 'log': only to the log and not in HTML
/**
* Send a line giving PHP memory usage.
*
- * @param bool $exact print exact values instead of kilobytes (default: false)
+ * @param bool $exact Print exact values instead of kilobytes (default: false)
*/
function wfDebugMem( $exact = false ) {
$mem = memory_get_usage();
/**
* Log for database errors
*
- * @param string $text database error message.
+ * @param string $text Database error message.
*/
function wfLogDBError( $text ) {
global $wgDBerrorLog, $wgDBerrorLogTZ;
/**
* Throws a warning that $function is deprecated
*
- * @param $function String
+ * @param string $function
* @param string|bool $version Version of MediaWiki that the function
* was deprecated in (Added in 1.19).
* @param string|bool $component Added in 1.19.
- * @param $callerOffset integer: How far up the call stack is the original
+ * @param int $callerOffset How far up the call stack is the original
* caller. 2 = function that called the function that called
* wfDeprecated (Added in 1.20)
*
* $wgDevelopmentWarnings. To log warnings in production, use wfLogWarning() instead.
*
* @param string $msg message to send
- * @param $callerOffset Integer: number of items to go back in the backtrace to
+ * @param int $callerOffset Number of items to go back in the backtrace to
* find the correct caller (1 = function calling wfWarn, ...)
- * @param $level Integer: PHP error level; defaults to E_USER_NOTICE;
+ * @param int $level PHP error level; defaults to E_USER_NOTICE;
* only used when $wgDevelopmentWarnings is true
*/
function wfWarn( $msg, $callerOffset = 1, $level = E_USER_NOTICE ) {
* Send a warning as a PHP error and the debug log. This is intended for logging
* warnings in production. For logging development warnings, use WfWarn instead.
*
- * @param $msg String: message to send
- * @param $callerOffset Integer: number of items to go back in the backtrace to
+ * @param string $msg Message to send
+ * @param int $callerOffset Number of items to go back in the backtrace to
* find the correct caller (1 = function calling wfLogWarning, ...)
- * @param $level Integer: PHP error level; defaults to E_USER_WARNING
+ * @param int $level PHP error level; defaults to E_USER_WARNING
*/
function wfLogWarning( $msg, $callerOffset = 1, $level = E_USER_WARNING ) {
MWDebug::warning( $msg, $callerOffset + 1, $level, 'production' );
* Can also log to TCP or UDP with the syntax udp://host:port/prefix. This will
* send lines to the specified port, prefixed by the specified prefix and a space.
*
- * @param $text String
- * @param string $file filename
+ * @param string $text
+ * @param string $file Filename
* @throws MWException
*/
function wfErrorLog( $text, $file ) {
/**
* Increment a statistics counter
*
- * @param $key String
- * @param $count Int
+ * @param string $key
+ * @param int $count
* @return void
*/
function wfIncrStats( $key, $count = 1 ) {
/**
* Get the value of $wgReadOnly or the contents of $wgReadOnlyFile.
*
- * @return string|bool: String when in read-only mode; false otherwise
+ * @return string|bool String when in read-only mode; false otherwise
*/
function wfReadOnlyReason() {
global $wgReadOnly, $wgReadOnlyFile;
/**
* Return a Language object from $langcode
*
- * @param $langcode Mixed: either:
+ * @param Language|string|bool $langcode Either:
* - a Language object
* - code of the language to get the message for, if it is
* a valid code create a language for that language, if
* the current user's language (as a fallback for the old parameter
* functionality), or if it is true then use global object
* for the wiki's content language.
- * @return Language object
+ * @return Language
*/
function wfGetLangObj( $langcode = false ) {
# Identify which language to get or create a language object for.
* - As an array in the second parameter
* These are not shown in the function definition.
*
- * @return String
+ * @return string
*/
function wfMsg( $key ) {
wfDeprecated( __METHOD__, '1.21' );
*
* @deprecated since 1.18
*
- * @param $key String
- * @return String
+ * @param string $key
+ * @return string
*/
function wfMsgNoTrans( $key ) {
wfDeprecated( __METHOD__, '1.21' );
*
* @deprecated since 1.18
*
- * @param string $key lookup key for the message, usually
+ * @param string $key Lookup key for the message, usually
* defined in languages/Language.php
- * @return String
+ * @return string
*/
function wfMsgForContent( $key ) {
wfDeprecated( __METHOD__, '1.21' );
*
* @deprecated since 1.18
*
- * @param $key String
- * @return String
+ * @param string $key
+ * @return string
*/
function wfMsgForContentNoTrans( $key ) {
wfDeprecated( __METHOD__, '1.21' );
*
* @deprecated since 1.18
*
- * @param string $key key to get.
+ * @param string $key Key to get.
* @param array $args
* @param bool $useDB
* @param string|bool $forContent Language code, or false for user lang, true for content lang.
* @param string $key
* @param bool $useDB
* @param string|bool $langCode Code of the language to get the message for, or
- * behaves as a content language switch if it is a boolean.
+ * behaves as a content language switch if it is a boolean.
* @param bool $transform Whether to parse magic words, etc.
* @return string
*/
*
* @deprecated since 1.18
*
- * @param string $key key of the message
- * @param array $options processing rules.
+ * @param string $key Key of the message
+ * @param array $options Processing rules.
* Can take the following options:
* parse: parses wikitext to HTML
* parseinline: parses wikitext to HTML and removes the surrounding
* (overridden by content).
* Behavior for conflicting options (e.g., parse+parseinline) is undefined.
*
- * @return String
+ * @return string
*/
function wfMsgExt( $key, $options ) {
wfDeprecated( __METHOD__, '1.21' );
* but now throws an exception instead, with similar results.
*
* @deprecated since 1.22; just throw an MWException yourself
- * @param string $msg message shown when dying.
+ * @param string $msg Message shown when dying.
* @throws MWException
*/
function wfDebugDieBacktrace( $msg = '' ) {
*
* @param int $limit This parameter can be used to limit the number of stack frames returned
*
- * @return array of backtrace information
+ * @return array Array of backtrace information
*/
function wfDebugBacktrace( $limit = 0 ) {
static $disabled = null;
* wfGetCaller( 2 ) [default] is the caller of the function running wfGetCaller()
* wfGetCaller( 3 ) is the parent of that.
*
- * @param $level Int
+ * @param int $level
* @return string
*/
function wfGetCaller( $level = 2 ) {
* Return a string consisting of callers in the stack. Useful sometimes
* for profiling specific points.
*
- * @param int $limit The maximum depth of the stack frame to return, or false for
- * the entire stack.
- * @return String
+ * @param int $limit The maximum depth of the stack frame to return, or false for the entire stack.
+ * @return string
*/
function wfGetAllCallers( $limit = 3 ) {
$trace = array_reverse( wfDebugBacktrace() );
/**
* Return a string representation of frame
*
- * @param $frame Array
+ * @param array $frame
* @return string
*/
function wfFormatStackFrame( $frame ) {
* @param string $offset
* @param int $limit
* @param string $link
- * @param string $query optional URL query parameter string
- * @param bool $atend optional param for specified if this is the last page
+ * @param string $query Optional URL query parameter string
+ * @param bool $atend Optional param for specified if this is the last page
* @return string
* @deprecated since 1.19; use Language::viewPrevNext() instead
*/
* Obtain the offset and limit values from the request string;
* used in special pages
*
- * @param int $deflimit default limit if none supplied
+ * @param int $deflimit Default limit if none supplied
* @param string $optionname Name of a user preference to check against
* @return array
- *
*/
function wfCheckLimits( $deflimit = 50, $optionname = 'rclimit' ) {
global $wgRequest;
* is achieved by substituting certain characters with HTML entities.
* As required by the callers, "<nowiki>" is not used.
*
- * @param string $text text to be escaped
- * @return String
+ * @param string $text Text to be escaped
+ * @return string
*/
function wfEscapeWikiText( $text ) {
static $repl = null, $repl2 = null;
/**
* Get the current unix timestamp with microseconds. Useful for profiling
* @deprecated since 1.22; call microtime() directly
- * @return Float
+ * @return float
*/
function wfTime() {
wfDeprecated( __FUNCTION__, '1.22' );
* If source is NULL, it just returns the value, it doesn't set the variable
* If force is true, it will set the value even if source is NULL
*
- * @param $dest Mixed
- * @param $source Mixed
- * @param $force Bool
- * @return Mixed
+ * @param mixed $dest
+ * @param mixed $source
+ * @param bool $force
+ * @return mixed
*/
function wfSetVar( &$dest, $source, $force = false ) {
$temp = $dest;
/**
* As for wfSetVar except setting a bit
*
- * @param $dest Int
- * @param $bit Int
- * @param $state Bool
+ * @param int $dest
+ * @param int $bit
+ * @param bool $state
*
* @return bool
*/
* A wrapper around the PHP function var_export().
* Either print it or add it to the regular output ($wgOut).
*
- * @param $var mixed A PHP variable to dump.
+ * @param mixed $var A PHP variable to dump.
*/
function wfVarDump( $var ) {
global $wgOut;
/**
* Provide a simple HTTP error.
*
- * @param $code Int|String
- * @param $label String
- * @param $desc String
+ * @param int|string $code
+ * @param string $label
+ * @param string $desc
*/
function wfHttpError( $code, $label, $desc ) {
global $wgOut;
* Note that some PHP configuration options may add output buffer
* layers which cannot be removed; these are left in place.
*
- * @param $resetGzipEncoding Bool
+ * @param bool $resetGzipEncoding
*/
function wfResetOutputBuffers( $resetGzipEncoding = true ) {
if ( $resetGzipEncoding ) {
* array of type to preference (preference is a float between 0.0 and 1.0).
* Wildcards in the types are acceptable.
*
- * @param array $cprefs client's acceptable type list
- * @param array $sprefs server's offered types
+ * @param array $cprefs Client's acceptable type list
+ * @param array $sprefs Server's offered types
* @return string
*
* @todo FIXME: Doesn't handle params like 'text/plain; charset=UTF-8'
/**
* Reference-counted warning suppression
*
- * @param $end Bool
+ * @param bool $end
*/
function wfSuppressWarnings( $end = false ) {
static $suppressCount = 0;
/**
* Get a timestamp string in one of various formats
*
- * @param $outputtype Mixed: A timestamp in one of the supported formats, the
- * function will autodetect which format is supplied and act
- * accordingly.
- * @param $ts Mixed: optional timestamp to convert, default 0 for the current time
- * @return Mixed: String / false The same date in the format specified in $outputtype or false
+ * @param mixed $outputtype A timestamp in one of the supported formats, the
+ * function will autodetect which format is supplied and act accordingly.
+ * @param mixed $ts Optional timestamp to convert, default 0 for the current time
+ * @return string|bool String / false The same date in the format specified in $outputtype or false
*/
function wfTimestamp( $outputtype = TS_UNIX, $ts = 0 ) {
try {
/**
* Make directory, and make all parent directories if they don't exist
*
- * @param string $dir full path to directory to create
+ * @param string $dir Full path to directory to create
* @param int $mode Chmod value to use, default is $wgDirectoryMode
- * @param string $caller optional caller param for debugging.
+ * @param string $caller Optional caller param for debugging.
* @throws MWException
* @return bool
*/
/**
* Remove a directory and all its content.
* Does not hide error.
+ * @param string $dir
*/
function wfRecursiveRemoveDir( $dir ) {
wfDebug( __FUNCTION__ . "( $dir )\n" );
}
/**
- * @param number $nr The number to format
+ * @param int $nr The number to format
* @param int $acc The number of digits after the decimal point, default 2
* @param bool $round Whether or not to round the value, default true
* @return string
* configuration if supported.
*
* @param string $cmd Command line, properly escaped for shell.
- * @param &$retval null|Mixed optional, will receive the program's exit code.
- * (non-zero is usually failure). If there is an error from
- * read, select, or proc_open(), this will be set to -1.
- * @param array $environ optional environment variables which should be
- * added to the executed command environment.
- * @param array $limits optional array with limits(filesize, memory, time, walltime)
- * this overwrites the global wgMaxShell* limits.
+ * @param null|mixed &$retval Optional, will receive the program's exit code.
+ * (non-zero is usually failure). If there is an error from
+ * read, select, or proc_open(), this will be set to -1.
+ * @param array $environ Optional environment variables which should be
+ * added to the executed command environment.
+ * @param array $limits Optional array with limits(filesize, memory, time, walltime)
+ * this overwrites the global wgMaxShell* limits.
* @param array $options Array of options:
- * - duplicateStderr: Set this to true to duplicate stderr to stdout,
- * including errors from limit.sh
+ * - duplicateStderr: Set this to true to duplicate stderr to stdout,
+ * including errors from limit.sh
*
- * @return string collected stdout as a string
+ * @return string Collected stdout as a string
*/
function wfShellExec( $cmd, &$retval = null, $environ = array(),
$limits = array(), $options = array()
*
* @note This also includes errors from limit.sh, e.g. if $wgMaxShellFileSize is exceeded.
* @param string $cmd Command line, properly escaped for shell.
- * @param &$retval null|Mixed optional, will receive the program's exit code.
- * (non-zero is usually failure)
+ * @param null|mixed &$retval Optional, will receive the program's exit code.
+ * (non-zero is usually failure)
* @param array $environ optional environment variables which should be
- * added to the executed command environment.
- * @param array $limits optional array with limits(filesize, memory, time, walltime)
- * this overwrites the global wgShellMax* limits.
- * @return string collected stdout and stderr as a string
+ * added to the executed command environment.
+ * @param array $limits Optional array with limits(filesize, memory, time, walltime)
+ * this overwrites the global wgShellMax* limits.
+ * @return string Collected stdout and stderr as a string
*/
function wfShellExecWithStderr( $cmd, &$retval = null, $environ = array(), $limits = array() ) {
return wfShellExec( $cmd, $retval, $environ, $limits, array( 'duplicateStderr' => true ) );
* Returns unified plain-text diff of two texts.
* Useful for machine processing of diffs.
*
- * @param string $before the text before the changes.
- * @param string $after the text after the changes.
- * @param string $params command-line options for the diff command.
+ * @param string $before The text before the changes.
+ * @param string $after The text after the changes.
+ * @param string $params Command-line options for the diff command.
* @return string Unified diff of $before and $after
*/
function wfDiff( $before, $after, $params = '-u' ) {
*
* @see perldoc -f use
*
- * @param string|number $req_ver The version to check, can be a string, an integer, or
- * a float
+ * @param string|int|float $req_ver The version to check, can be a string, an integer, or a float
* @throws MWException
*/
function wfUsePHP( $req_ver ) {
*
* @see perldoc -f use
*
- * @param string|number $req_ver The version to check, can be a string, an integer, or
- * a float
+ * @param string|int|float $req_ver The version to check, can be a string, an integer, or a float
* @throws MWException
*/
function wfUseMW( $req_ver ) {
* We'll consider it so always, as we don't want '\s' in our Unix paths either.
*
* @param string $path
- * @param string $suffix to remove if present
+ * @param string $suffix String to remove if present
* @return string
*/
function wfBaseName( $path, $suffix = '' ) {
* May explode on non-matching case-insensitive paths,
* funky symlinks, etc.
*
- * @param string $path absolute destination path including target filename
+ * @param string $path Absolute destination path including target filename
* @param string $from Absolute source path, directory only
* @return string
*/
*
* bypassCache: If true, do not use the process-local cache of File objects
*
- * @return File, or false if the file does not exist
+ * @return File|bool File, or false if the file does not exist
*/
function wfFindFile( $title, $options = array() ) {
return RepoGroup::singleton()->findFile( $title, $options );
* extensions; this is a wrapper around $wgScriptExtension etc.
* except for 'index' and 'load' which use $wgScript/$wgLoadScript
*
- * @param string $script script filename, sans extension
+ * @param string $script Script filename, sans extension
* @return string
*/
function wfScript( $script = 'index' ) {
/**
* Get a cache object.
*
- * @param $inputType integer Cache type, one the the CACHE_* constants.
+ * @param int $inputType Cache type, one the the CACHE_* constants.
* @return BagOStuff
*/
function wfGetCache( $inputType ) {
/**
* Call hook functions defined in $wgHooks
*
- * @param string $event event name
- * @param array $args parameters passed to hook functions
- * @param string|null $deprecatedVersion optionally mark hook as deprecated with version number
+ * @param string $event Event name
+ * @param array $args Parameters passed to hook functions
+ * @param string|null $deprecatedVersion Optionally mark hook as deprecated with version number
*
* @return bool True if no handler aborted the hook
*/
* * Any subsequent links on the same line are considered to be exceptions,
* i.e. articles where the image may occur inline.
*
- * @param string $name the image name to check
+ * @param string $name The image name to check
* @param Title|bool $contextTitle The page on which the image occurs, if known
- * @param string $blacklist wikitext of a file blacklist
+ * @param string $blacklist Wikitext of a file blacklist
* @return bool
*/
function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
* access the wiki via HTTPS.
*
* @param string $ip The IPv4/6 address in the normal human-readable form
- * @return boolean
+ * @return bool
*/
function wfCanIPUseHTTPS( $ip ) {
$canDo = true;
/**
* Create a new Title from a prefixed DB key
*
- * @param string $key the database key, which has underscores
+ * @param string $key The database key, which has underscores
* instead of spaces, possibly including namespace and
* interwiki prefixes
- * @return Title, or NULL on an error
+ * @return Title|null Title, or NULL on an error
*/
public static function newFromDBkey( $key ) {
$t = new Title();
/**
* Create a new Title from a TitleValue
*
- * @param TitleValue $titleValue, assumed to be safe.
+ * @param TitleValue $titleValue Assumed to be safe.
*
* @return Title
*/
* Create a new Title from text, such as what one would find in a link. De-
* codes any HTML entities in the text.
*
- * @param string $text the link text; spaces, prefixes, and an
+ * @param string $text The link text; spaces, prefixes, and an
* initial ':' indicating the main namespace are accepted.
- * @param int $defaultNamespace the namespace to use if none is specified
+ * @param int $defaultNamespace The namespace to use if none is specified
* by a prefix. If you want to force a specific namespace even if
* $text might begin with a namespace prefix, use makeTitle() or
* makeTitleSafe().
* @throws MWException
- * @return Title|null - Title or null on an error.
+ * @return Title|null Title or null on an error.
*/
public static function newFromText( $text, $defaultNamespace = NS_MAIN ) {
if ( is_object( $text ) ) {
* Create a new Title from URL-encoded text. Ensures that
* the given title's length does not exceed the maximum.
*
- * @param string $url the title, as might be taken from a URL
- * @return Title the new object, or NULL on an error
+ * @param string $url The title, as might be taken from a URL
+ * @return Title|null The new object, or null on an error
*/
public static function newFromURL( $url ) {
$t = new Title();
/**
* Create a new Title from an article ID
*
- * @param int $id the page_id corresponding to the Title to create
- * @param int $flags use Title::GAID_FOR_UPDATE to use master
- * @return Title|null the new object, or NULL on an error
+ * @param int $id The page_id corresponding to the Title to create
+ * @param int $flags Use Title::GAID_FOR_UPDATE to use master
+ * @return Title|null The new object, or NULL on an error
*/
public static function newFromID( $id, $flags = 0 ) {
$db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
/**
* Make an array of titles from an array of IDs
*
- * @param array $ids of Int Array of IDs
- * @return Array of Titles
+ * @param array $ids Array of IDs
+ * @return array Array of Titles
*/
public static function newFromIDs( $ids ) {
if ( !count( $ids ) ) {
* Make a Title object from a DB row
*
* @param stdClass $row Object database row (needs at least page_title,page_namespace)
- * @return Title corresponding Title
+ * @return Title Corresponding Title
*/
public static function newFromRow( $row ) {
$t = self::makeTitle( $row->page_namespace, $row->page_title );
* Load Title object fields from a DB row.
* If false is given, the title will be treated as non-existing.
*
- * @param $row stdClass|bool database row
+ * @param stdClass|bool $row Database row
*/
public function loadFromRow( $row ) {
if ( $row ) { // page found
* For convenience, spaces are converted to underscores so that
* eg user_text fields can be used directly.
*
- * @param int $ns the namespace of the article
- * @param string $title the unprefixed database key form
- * @param string $fragment the link fragment (after the "#")
- * @param string $interwiki the interwiki prefix
- * @return Title the new object
+ * @param int $ns The namespace of the article
+ * @param string $title The unprefixed database key form
+ * @param string $fragment The link fragment (after the "#")
+ * @param string $interwiki The interwiki prefix
+ * @return Title The new object
*/
public static function &makeTitle( $ns, $title, $fragment = '', $interwiki = '' ) {
$t = new Title();
* The parameters will be checked for validity, which is a bit slower
* than makeTitle() but safer for user-provided data.
*
- * @param int $ns the namespace of the article
- * @param string $title database key form
- * @param string $fragment the link fragment (after the "#")
- * @param string $interwiki interwiki prefix
- * @return Title the new object, or NULL on an error
+ * @param int $ns The namespace of the article
+ * @param string $title Database key form
+ * @param string $fragment The link fragment (after the "#")
+ * @param string $interwiki Interwiki prefix
+ * @return Title The new object, or NULL on an error
*/
public static function makeTitleSafe( $ns, $title, $fragment = '', $interwiki = '' ) {
if ( !MWNamespace::exists( $ns ) ) {
/**
* Create a new Title for the Main Page
*
- * @return Title the new object
+ * @return Title The new object
*/
public static function newMainPage() {
$title = Title::newFromText( wfMessage( 'mainpage' )->inContentLanguage()->text() );
* the redirect table and other checks that don't need full recursion
*
* @param string $text Text with possible redirect
- * @return Title: The corresponding Title
+ * @return Title The corresponding Title
* @deprecated since 1.21, use Content::getRedirectTarget instead.
*/
public static function newFromRedirect( $text ) {
* have been resolved (up to $wgMaxRedirects times)
*
* @param string $text Text with possible redirect
- * @return Array of Titles, with the destination last
+ * @return array Array of Titles, with the destination last
* @deprecated since 1.21, use Content::getRedirectChain instead.
*/
public static function newFromRedirectArray( $text ) {
/**
* Get the prefixed DB key associated with an ID
*
- * @param int $id the page_id of the article
- * @return Title an object representing the article, or NULL if no such article was found
+ * @param int $id The page_id of the article
+ * @return Title|null An object representing the article, or NULL if no such article was found
*/
public static function nameOf( $id ) {
$dbr = wfGetDB( DB_SLAVE );
/**
* Get a regex character class describing the legal characters in a link
*
- * @return String the list of characters, not delimited
+ * @return string The list of characters, not delimited
*/
public static function legalChars() {
global $wgLegalTitleChars;
*
* @todo: move this into MediaWikiTitleCodec
*
- * @return String regex string
+ * @return string Regex string
*/
static function getTitleInvalidRegex() {
static $rxTc = false;
/**
* Make a prefixed DB key from a DB key and a namespace index
*
- * @param int $ns numerical representation of the namespace
- * @param string $title the DB key form the title
+ * @param int $ns Numerical representation of the namespace
+ * @param string $title The DB key form the title
* @param string $fragment The link fragment (after the "#")
* @param string $interwiki The interwiki prefix
- * @return String the prefixed form of the title
+ * @return string The prefixed form of the title
*/
public static function makeName( $ns, $title, $fragment = '', $interwiki = '' ) {
global $wgContLang;
/**
* Escape a text fragment, say from a link, for a URL
*
- * @param string $fragment containing a URL or link fragment (after the "#")
- * @return String: escaped string
+ * @param string $fragment Containing a URL or link fragment (after the "#")
+ * @return string Escaped string
*/
static function escapeFragmentForURL( $fragment ) {
# Note that we don't urlencode the fragment. urlencoded Unicode
/**
* Callback for usort() to do title sorts by (namespace, title)
*
- * @param $a Title
- * @param $b Title
+ * @param Title $a
+ * @param Title $b
*
- * @return Integer: result of string comparison, or namespace comparison
+ * @return int Result of string comparison, or namespace comparison
*/
public static function compare( $a, $b ) {
if ( $a->getNamespace() == $b->getNamespace() ) {
* Determine whether the object refers to a page within
* this project.
*
- * @return Bool TRUE if this is an in-project interwiki link or a wikilink, FALSE otherwise
+ * @return bool True if this is an in-project interwiki link or a wikilink, false otherwise
*/
public function isLocal() {
if ( $this->isExternal() ) {
/**
* Is this Title interwiki?
*
- * @return Bool
+ * @return bool
*/
public function isExternal() {
return $this->mInterwiki !== '';
*
* Use Title::isExternal to check if a interwiki is set
*
- * @return String Interwiki prefix
+ * @return string Interwiki prefix
*/
public function getInterwiki() {
return $this->mInterwiki;
* Determine whether the object refers to a page within
* this project and is transcludable.
*
- * @return Bool TRUE if this is transcludable
+ * @return bool TRUE if this is transcludable
*/
public function isTrans() {
if ( !$this->isExternal() ) {
/**
* Returns the DB name of the distant wiki which owns the object.
*
- * @return String the DB name
+ * @return string The DB name
*/
public function getTransWikiID() {
if ( !$this->isExternal() ) {
/**
* Get the text form (spaces not underscores) of the main part
*
- * @return String Main part of the title
+ * @return string Main part of the title
*/
public function getText() {
return $this->mTextform;
/**
* Get the URL-encoded form of the main part
*
- * @return String Main part of the title, URL-encoded
+ * @return string Main part of the title, URL-encoded
*/
public function getPartialURL() {
return $this->mUrlform;
/**
* Get the main part with underscores
*
- * @return String: Main part of the title, with underscores
+ * @return string Main part of the title, with underscores
*/
public function getDBkey() {
return $this->mDbkeyform;
/**
* Get the DB key with the initial letter case as specified by the user
*
- * @return String DB key
+ * @return string DB key
*/
function getUserCaseDBKey() {
if ( !is_null( $this->mUserCaseDBKey ) ) {
/**
* Get the namespace index, i.e. one of the NS_xxxx constants.
*
- * @return Integer: Namespace index
+ * @return int Namespace index
*/
public function getNamespace() {
return $this->mNamespace;
* Get the page's content model id, see the CONTENT_MODEL_XXX constants.
*
* @throws MWException
- * @return String: Content model id
+ * @return string Content model id
*/
public function getContentModel() {
if ( !$this->mContentModel ) {
* Convenience method for checking a title's content model name
*
* @param string $id The content model ID (use the CONTENT_MODEL_XXX constants).
- * @return Boolean true if $this->getContentModel() == $id
+ * @return bool True if $this->getContentModel() == $id
*/
public function hasContentModel( $id ) {
return $this->getContentModel() == $id;
/**
* Get the namespace text
*
- * @return String: Namespace text
+ * @return string Namespace text
*/
public function getNsText() {
if ( $this->isExternal() ) {
/**
* Get the namespace text of the subject (rather than talk) page
*
- * @return String Namespace text
+ * @return string Namespace text
*/
public function getSubjectNsText() {
global $wgContLang;
/**
* Get the namespace text of the talk page
*
- * @return String Namespace text
+ * @return string Namespace text
*/
public function getTalkNsText() {
global $wgContLang;
/**
* Could this title have a corresponding talk page?
*
- * @return Bool TRUE or FALSE
+ * @return bool
*/
public function canTalk() {
return MWNamespace::canTalk( $this->mNamespace );
/**
* Is this in a namespace that allows actual pages?
*
- * @return Bool
+ * @return bool
* @internal note -- uses hardcoded namespace index instead of constants
*/
public function canExist() {
/**
* Can this title be added to a user's watchlist?
*
- * @return Bool TRUE or FALSE
+ * @return bool
*/
public function isWatchable() {
return !$this->isExternal() && MWNamespace::isWatchable( $this->getNamespace() );
/**
* Returns true if this is a special page.
*
- * @return boolean
+ * @return bool
*/
public function isSpecialPage() {
return $this->getNamespace() == NS_SPECIAL;
* Returns true if this title resolves to the named special page
*
* @param string $name The special page name
- * @return boolean
+ * @return bool
*/
public function isSpecial( $name ) {
if ( $this->isSpecialPage() ) {
* This is MUCH simpler than individually testing for equivalence
* against both NS_USER and NS_USER_TALK, and is also forward compatible.
* @since 1.19
- * @param $ns int
+ * @param int $ns
* @return bool
*/
public function hasSubjectNamespace( $ns ) {
* In other words, is this a content page, for the purposes of calculating
* statistics, etc?
*
- * @return Boolean
+ * @return bool
*/
public function isContentPage() {
return MWNamespace::isContent( $this->getNamespace() );
* Would anybody with sufficient privileges be able to move this page?
* Some pages just aren't movable.
*
- * @return Bool TRUE or FALSE
+ * @return bool
*/
public function isMovable() {
if ( !MWNamespace::isMovable( $this->getNamespace() ) || $this->isExternal() ) {
* ends up reporting something differently than $title->isMainPage();
*
* @since 1.18
- * @return Bool
+ * @return bool
*/
public function isMainPage() {
return $this->equals( Title::newMainPage() );
/**
* Is this a subpage?
*
- * @return Bool
+ * @return bool
*/
public function isSubpage() {
return MWNamespace::hasSubpages( $this->mNamespace )
/**
* Is this a conversion table for the LanguageConverter?
*
- * @return Bool
+ * @return bool
*/
public function isConversionTable() {
// @todo ConversionTable should become a separate content model.
/**
* Does that page contain wikitext, or it is JS, CSS or whatever?
*
- * @return Bool
+ * @return bool
*/
public function isWikitextPage() {
return $this->hasContentModel( CONTENT_MODEL_WIKITEXT );
*
* Note that this method should not return true for pages that contain and show "inactive" CSS or JS.
*
- * @return Bool
+ * @return bool
*/
public function isCssOrJsPage() {
$isCssOrJsPage = NS_MEDIAWIKI == $this->mNamespace
/**
* Is this a .css or .js subpage of a user page?
- * @return Bool
+ * @return bool
*/
public function isCssJsSubpage() {
return ( NS_USER == $this->mNamespace && $this->isSubpage()
/**
* Trim down a .css or .js subpage title to get the corresponding skin name
*
- * @return string containing skin name from .css or .js subpage title
+ * @return string Containing skin name from .css or .js subpage title
*/
public function getSkinFromCssJsSubpage() {
$subpage = explode( '/', $this->mTextform );
/**
* Is this a .css subpage of a user page?
*
- * @return Bool
+ * @return bool
*/
public function isCssSubpage() {
return ( NS_USER == $this->mNamespace && $this->isSubpage()
/**
* Is this a .js subpage of a user page?
*
- * @return Bool
+ * @return bool
*/
public function isJsSubpage() {
return ( NS_USER == $this->mNamespace && $this->isSubpage()
/**
* Is this a talk page of some sort?
*
- * @return Bool
+ * @return bool
*/
public function isTalkPage() {
return MWNamespace::isTalk( $this->getNamespace() );
/**
* Get a Title object associated with the talk page of this article
*
- * @return Title the object for the talk page
+ * @return Title The object for the talk page
*/
public function getTalkPage() {
return Title::makeTitle( MWNamespace::getTalk( $this->getNamespace() ), $this->getDBkey() );
* Get a title object associated with the subject page of this
* talk page
*
- * @return Title the object for the subject page
+ * @return Title The object for the subject page
*/
public function getSubjectPage() {
// Is this the same title?
/**
* Get the default namespace index, for when there is no namespace
*
- * @return Int Default namespace index
+ * @return int Default namespace index
*/
public function getDefaultNamespace() {
return $this->mDefaultNamespace;
*
* Use Title::hasFragment to check for a fragment
*
- * @return String Title fragment
+ * @return string Title fragment
*/
public function getFragment() {
return $this->mFragment;
/**
* Get the fragment in URL form, including the "#" character if there is one
- * @return String Fragment in URL form
+ * @return string Fragment in URL form
*/
public function getFragmentForURL() {
if ( !$this->hasFragment() ) {
* Deprecated for public use, use Title::makeTitle() with fragment parameter.
* Still in active use privately.
*
- * @param string $fragment text
+ * @param string $fragment Text
*/
public function setFragment( $fragment ) {
$this->mFragment = str_replace( '_', ' ', substr( $fragment, 1 ) );
* Prefix some arbitrary text with the namespace or interwiki prefix
* of this object
*
- * @param string $name the text
- * @return String the prefixed text
+ * @param string $name The text
+ * @return string The prefixed text
* @private
*/
private function prefix( $name ) {
/**
* Get the prefixed database key form
*
- * @return String the prefixed title, with underscores and
+ * @return string The prefixed title, with underscores and
* any interwiki and namespace prefixes
*/
public function getPrefixedDBkey() {
* Get the prefixed title with spaces.
* This is the form usually used for display
*
- * @return String the prefixed title, with spaces
+ * @return string The prefixed title, with spaces
*/
public function getPrefixedText() {
if ( $this->mPrefixedText === null ) {
/**
* Return a string representation of this title
*
- * @return String representation of this title
+ * @return string Representation of this title
*/
public function __toString() {
return $this->getPrefixedText();
* Get the prefixed title with spaces, plus any fragment
* (part beginning with '#')
*
- * @return String the prefixed title, with spaces and the fragment, including '#'
+ * @return string The prefixed title, with spaces and the fragment, including '#'
*/
public function getFullText() {
$text = $this->getPrefixedText();
* # returns: 'Foo'
* @endcode
*
- * @return String Root name
+ * @return string Root name
* @since 1.20
*/
public function getRootText() {
* # returns: 'Foo/Bar'
* @endcode
*
- * @return String Base name
+ * @return string Base name
*/
public function getBaseText() {
if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
* # returns: "Baz"
* @endcode
*
- * @return String Subpage name
+ * @return string Subpage name
*/
public function getSubpageText() {
if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
* Get the HTML-escaped displayable text form.
* Used for the title field in <a> tags.
*
- * @return String the text, including any prefixes
+ * @return string The text, including any prefixes
* @deprecated since 1.19
*/
public function getEscapedText() {
/**
* Get a URL-encoded form of the subpage text
*
- * @return String URL-encoded subpage name
+ * @return string URL-encoded subpage name
*/
public function getSubpageUrlForm() {
$text = $this->getSubpageText();
/**
* Get a URL-encoded title (not an actual URL) including interwiki
*
- * @return String the URL-encoded form
+ * @return string The URL-encoded form
*/
public function getPrefixedURL() {
$s = $this->prefix( $this->mDbkeyform );
* and the wfArrayToCgi moved to getLocalURL();
*
* @since 1.19 (r105919)
- * @param $query
- * @param $query2 bool
- * @return String
+ * @param array|string $query
+ * @param bool $query2
+ * @return string
*/
private static function fixUrlQueryArgs( $query, $query2 = false ) {
if ( $query2 !== false ) {
*
* @see self::getLocalURL for the arguments.
* @see wfExpandUrl
- * @param $query
- * @param $query2 bool
- * @param $proto Protocol type to use in URL
- * @return String the URL
+ * @param array|string $query
+ * @param bool $query2
+ * @param string $proto Protocol type to use in URL
+ * @return string The URL
*/
public function getFullURL( $query = '', $query2 = false, $proto = PROTO_RELATIVE ) {
$query = self::fixUrlQueryArgs( $query, $query2 );
* not used for interwiki links. Can be specified as an associative array as well,
* e.g., array( 'action' => 'edit' ) (keys and values will be URL-escaped).
* Some query patterns will trigger various shorturl path replacements.
- * @param $query2 Mixed: An optional secondary query array. This one MUST
+ * @param array $query2 An optional secondary query array. This one MUST
* be an array. If a string is passed it will be interpreted as a deprecated
* variant argument and urlencoded into a variant= argument.
* This second query argument will be added to the $query
* The second parameter is deprecated since 1.19. Pass it as a key,value
* pair in the first parameter array instead.
*
- * @return String of the URL.
+ * @return string String of the URL.
*/
public function getLocalURL( $query = '', $query2 = false ) {
global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
* The result obviously should not be URL-escaped, but does need to be
* HTML-escaped if it's being output in HTML.
*
- * @param $query
- * @param $query2 bool
- * @param $proto Protocol to use; setting this will cause a full URL to be used
+ * @param array $query
+ * @param bool $query2
+ * @param string $proto Protocol to use; setting this will cause a full URL to be used
* @see self::getLocalURL for the arguments.
- * @return String the URL
+ * @return string The URL
*/
public function getLinkURL( $query = '', $query2 = false, $proto = PROTO_RELATIVE ) {
wfProfileIn( __METHOD__ );
* using in a link, without a server name or fragment
*
* @see self::getLocalURL for the arguments.
- * @param $query string
- * @param $query2 bool|string
- * @return String the URL
+ * @param string $query
+ * @param bool|string $query2
+ * @return string The URL
* @deprecated since 1.19
*/
public function escapeLocalURL( $query = '', $query2 = false ) {
* using in a link, including the server name and fragment
*
* @see self::getLocalURL for the arguments.
- * @return String the URL
+ * @return string The URL
* @deprecated since 1.19
*/
public function escapeFullURL( $query = '', $query2 = false ) {
* protocol-relative, the URL will be expanded to http://
*
* @see self::getLocalURL for the arguments.
- * @return String the URL
+ * @return string The URL
*/
public function getInternalURL( $query = '', $query2 = false ) {
global $wgInternalServer, $wgServer;
/**
* Get the edit URL for this Title
*
- * @return String the URL, or a null string if this is an
- * interwiki link
+ * @return string The URL, or a null string if this is an interwiki link
*/
public function getEditURL() {
if ( $this->isExternal() ) {
* Is $wgUser watching this page?
*
* @deprecated since 1.20; use User::isWatched() instead.
- * @return Bool
+ * @return bool
*/
public function userIsWatching() {
global $wgUser;
* Can $wgUser read this page?
*
* @deprecated since 1.19; use userCan(), quickUserCan() or getUserPermissionsErrors() instead
- * @return Bool
+ * @return bool
*/
public function userCanRead() {
wfDeprecated( __METHOD__, '1.19' );
*
* May provide false positives, but should never provide a false negative.
*
- * @param string $action action that permission needs to be checked for
- * @param $user User to check (since 1.19); $wgUser will be used if not
- * provided.
- * @return Bool
+ * @param string $action Action that permission needs to be checked for
+ * @param User $user User to check (since 1.19); $wgUser will be used if not provided.
+ * @return bool
*/
public function quickUserCan( $action, $user = null ) {
return $this->userCan( $action, $user, false );
/**
* Can $user perform $action on this page?
*
- * @param string $action action that permission needs to be checked for
- * @param $user User to check (since 1.19); $wgUser will be used if not
+ * @param string $action Action that permission needs to be checked for
+ * @param User $user User to check (since 1.19); $wgUser will be used if not
* provided.
* @param bool $doExpensiveQueries Set this to false to avoid doing
* unnecessary queries.
- * @return Bool
+ * @return bool
*/
public function userCan( $action, $user = null, $doExpensiveQueries = true ) {
if ( !$user instanceof User ) {
* @todo FIXME: This *does not* check throttles (User::pingLimiter()).
*
* @param string $action action that permission needs to be checked for
- * @param $user User to check
+ * @param User $user User to check
* @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary
* queries by skipping checks for cascading protections and user blocks.
* @param array $ignoreErrors of Strings Set this to a list of message keys
* whose corresponding errors may be ignored.
- * @return Array of arguments to wfMessage to explain permissions problems.
+ * @return array Array of arguments to wfMessage to explain permissions problems.
*/
public function getUserPermissionsErrors( $action, $user, $doExpensiveQueries = true, $ignoreErrors = array() ) {
$errors = $this->getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries );
* Permissions checks that fail most often, and which are easiest to test.
*
* @param string $action the action to check
- * @param $user User user to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkQuickPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
if ( !wfRunHooks( 'TitleQuickPermissions', array( $this, $user, $action, &$errors, $doExpensiveQueries, $short ) ) ) {
/**
* Add the resulting error code to the errors array
*
- * @param array $errors list of current errors
- * @param $result Mixed result of errors
+ * @param array $errors List of current errors
+ * @param array $result Result of errors
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function resultToError( $errors, $result ) {
if ( is_array( $result ) && count( $result ) && !is_array( $result[0] ) ) {
/**
* Check various permission hooks
*
- * @param string $action the action to check
- * @param $user User user to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param string $action The action to check
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkPermissionHooks( $action, $user, $errors, $doExpensiveQueries, $short ) {
// Use getUserPermissionsErrors instead
/**
* Check permissions on special pages & namespaces
*
- * @param string $action the action to check
- * @param $user User user to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param string $action The action to check
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkSpecialsAndNSPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
# Only 'createaccount' can be performed on special pages,
/**
* Check CSS/JS sub-page permissions
*
- * @param string $action the action to check
- * @param $user User user to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param string $action The action to check
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkCSSandJSPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
# Protect css/js subpages of user pages
* page. The user must possess all required rights for this
* action.
*
- * @param string $action the action to check
- * @param $user User user to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param string $action The action to check
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkPageRestrictions( $action, $user, $errors, $doExpensiveQueries, $short ) {
foreach ( $this->getRestrictions( $action ) as $right ) {
/**
* Check restrictions on cascading pages.
*
- * @param string $action the action to check
- * @param $user User to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param string $action The action to check
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkCascadingSourcesRestrictions( $action, $user, $errors, $doExpensiveQueries, $short ) {
if ( $doExpensiveQueries && !$this->isCssJsSubpage() ) {
/**
* Check action permissions not already checked in checkQuickPermissions
*
- * @param string $action the action to check
- * @param $user User to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param string $action The action to check
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkActionPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
global $wgDeleteRevisionsLimit, $wgLang;
/**
* Check that the user isn't blocked from editing.
*
- * @param string $action the action to check
- * @param $user User to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param string $action The action to check
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkUserBlock( $action, $user, $errors, $doExpensiveQueries, $short ) {
// Account creation blocks handled at userlogin.
/**
* Check that the user is allowed to read this page.
*
- * @param string $action the action to check
- * @param $user User to check
- * @param array $errors list of current errors
- * @param $doExpensiveQueries Boolean whether or not to perform expensive queries
- * @param $short Boolean short circuit on first error
+ * @param string $action The action to check
+ * @param User $user User to check
+ * @param array $errors List of current errors
+ * @param bool $doExpensiveQueries Whether or not to perform expensive queries
+ * @param bool $short Short circuit on first error
*
- * @return Array list of errors
+ * @return array List of errors
*/
private function checkReadPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
global $wgWhitelistRead, $wgWhitelistReadRegexp;
* Get a description array when the user doesn't have the right to perform
* $action (i.e. when User::isAllowed() returns false)
*
- * @param string $action the action to check
- * @param $short Boolean short circuit on first error
- * @return Array list of errors
+ * @param string $action The action to check
+ * @param bool $short Short circuit on first error
+ * @return array List of errors
*/
private function missingPermissionError( $action, $short ) {
// We avoid expensive display logic for quickUserCan's and such
* which checks ONLY that previously checked by userCan (i.e. it leaves out
* checks on wfReadOnly() and blocks)
*
- * @param string $action action that permission needs to be checked for
- * @param $user User to check
+ * @param string $action Action that permission needs to be checked for
+ * @param User $user User to check
* @param bool $doExpensiveQueries Set this to false to avoid doing unnecessary queries.
* @param bool $short Set this to true to stop after the first permission error.
- * @return Array of arrays of the arguments to wfMessage to explain permissions problems.
+ * @return array Array of arrays of the arguments to wfMessage to explain permissions problems.
*/
protected function getUserPermissionsErrorsInternal( $action, $user, $doExpensiveQueries = true, $short = false ) {
wfProfileIn( __METHOD__ );
/**
* Returns restriction types for the current Title
*
- * @return array applicable restriction types
+ * @return array Applicable restriction types
*/
public function getRestrictionTypes() {
if ( $this->isSpecialPage() ) {
* Is this title subject to title protection?
* Title protection is the one applied against creation of such title.
*
- * @return Mixed An associative array representing any existent title
+ * @return array|bool An associative array representing any existent title
* protection, or false if there's none.
*/
private function getTitleProtection() {
* Update the title protection status
*
* @deprecated since 1.19; use WikiPage::doUpdateRestrictions() instead.
- * @param $create_perm String Permission required for creation
+ * @param string $create_perm Permission required for creation
* @param string $reason Reason for protection
* @param string $expiry Expiry timestamp
- * @return boolean true
+ * @return bool
*/
public function updateTitleProtection( $create_perm, $reason, $expiry ) {
wfDeprecated( __METHOD__, '1.19' );
* in $wgSemiprotectedRestrictionLevels?
*
* @param string $action Action to check (default: edit)
- * @return Bool
+ * @return bool
*/
public function isSemiProtected( $action = 'edit' ) {
global $wgSemiprotectedRestrictionLevels;
*
* @param string $action the action the page is protected from,
* by default checks all actions.
- * @return Bool
+ * @return bool
*/
public function isProtected( $action = '' ) {
global $wgRestrictionLevels;
* Determines if $user is unable to edit this page because it has been protected
* by $wgNamespaceProtection.
*
- * @param $user User object to check permissions
- * @return Bool
+ * @param User $user User object to check permissions
+ * @return bool
*/
public function isNamespaceProtected( User $user ) {
global $wgNamespaceProtection;
/**
* Cascading protection: Return true if cascading restrictions apply to this page, false if not.
*
- * @return Bool If the page is subject to cascading restrictions.
+ * @return bool If the page is subject to cascading restrictions.
*/
public function isCascadeProtected() {
list( $sources, /* $restrictions */ ) = $this->getCascadeProtectionSources( false );
*
* @param bool $getPages Whether or not to retrieve the actual pages
* that the restrictions have come from.
- * @return Mixed Array of Title objects of the pages from which cascading restrictions
+ * @return array|bool Array of Title objects of the pages from which cascading restrictions
* have come, false for none, or true if such restrictions exist, but $getPages
* was not set. The restriction array is an array of each type, each of which
* contains a array of unique groups.
/**
* Accessor/initialisation for mRestrictions
*
- * @param string $action action that permission needs to be checked for
- * @return Array of Strings the array of groups allowed to edit this article
+ * @param string $action Action that permission needs to be checked for
+ * @return array Array of Strings the array of groups allowed to edit this article
*/
public function getRestrictions( $action ) {
if ( !$this->mRestrictionsLoaded ) {
/**
* Accessor/initialisation for mRestrictions
*
- * @return Array of Arrays of Strings the first level indexed by
+ * @return array Array of Arrays of Strings the first level indexed by
* action, the second level containing the names of the groups
* allowed to perform each action
* @since 1.23
/**
* Get the expiry time for the restriction against a given action
*
- * @param $action
- * @return String|Bool 14-char timestamp, or 'infinity' if the page is protected forever
+ * @param string $action
+ * @return string|bool 14-char timestamp, or 'infinity' if the page is protected forever
* or not protected at all, or false if the action is not recognised.
*/
public function getRestrictionExpiry( $action ) {
/**
* Returns cascading restrictions for the current article
*
- * @return Boolean
+ * @return bool
*/
function areRestrictionsCascading() {
if ( !$this->mRestrictionsLoaded ) {
/**
* Loads a string into mRestrictions array
*
- * @param $res Resource restrictions as an SQL result.
- * @param string $oldFashionedRestrictions comma-separated list of page
+ * @param ResultWrapper $res Resource restrictions as an SQL result.
+ * @param string $oldFashionedRestrictions Comma-separated list of page
* restrictions from page table (pre 1.10)
*/
private function loadRestrictionsFromResultWrapper( $res, $oldFashionedRestrictions = null ) {
* and page_restrictions table for this existing page.
* Public for usage by LiquidThreads.
*
- * @param array $rows of db result objects
- * @param string $oldFashionedRestrictions comma-separated list of page
- * restrictions from page table (pre 1.10)
+ * @param array $rows Array of db result objects
+ * @param string $oldFashionedRestrictions Comma-separated list of page
+ * restrictions from page table (pre 1.10)
*/
public function loadRestrictionsFromRows( $rows, $oldFashionedRestrictions = null ) {
global $wgContLang;
/**
* Load restrictions from the page_restrictions table
*
- * @param string $oldFashionedRestrictions comma-separated list of page
- * restrictions from page table (pre 1.10)
+ * @param string $oldFashionedRestrictions Comma-separated list of page
+ * restrictions from page table (pre 1.10)
*/
public function loadRestrictions( $oldFashionedRestrictions = null ) {
global $wgContLang;
/**
* Does this have subpages? (Warning, usually requires an extra DB query.)
*
- * @return Bool
+ * @return bool
*/
public function hasSubpages() {
if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
/**
* Get all subpages of this page.
*
- * @param int $limit maximum number of subpages to fetch; -1 for no limit
- * @return mixed TitleArray, or empty array if this page's namespace
+ * @param int $limit Maximum number of subpages to fetch; -1 for no limit
+ * @return TitleArray|array TitleArray, or empty array if this page's namespace
* doesn't allow subpages
*/
public function getSubpages( $limit = -1 ) {
/**
* Is there a version of this page in the deletion archive?
*
- * @return Int the number of archived revisions
+ * @return int The number of archived revisions
*/
public function isDeleted() {
if ( $this->getNamespace() < 0 ) {
/**
* Is there a version of this page in the deletion archive?
*
- * @return Boolean
+ * @return bool
*/
public function isDeletedQuick() {
if ( $this->getNamespace() < 0 ) {
* Get the article ID for this Title from the link cache,
* adding it if necessary
*
- * @param int $flags a bit field; may be Title::GAID_FOR_UPDATE to select
+ * @param int $flags A bit field; may be Title::GAID_FOR_UPDATE to select
* for update
- * @return Int the ID
+ * @return int The ID
*/
public function getArticleID( $flags = 0 ) {
if ( $this->getNamespace() < 0 ) {
* Is this an article that is a redirect page?
* Uses link cache, adding it if necessary
*
- * @param int $flags a bit field; may be Title::GAID_FOR_UPDATE to select for update
- * @return Bool
+ * @param int $flags A bit field; may be Title::GAID_FOR_UPDATE to select for update
+ * @return bool
*/
public function isRedirect( $flags = 0 ) {
if ( !is_null( $this->mRedirect ) ) {
* What is the length of this page?
* Uses link cache, adding it if necessary
*
- * @param int $flags a bit field; may be Title::GAID_FOR_UPDATE to select for update
- * @return Int
+ * @param int $flags A bit field; may be Title::GAID_FOR_UPDATE to select for update
+ * @return int
*/
public function getLength( $flags = 0 ) {
if ( $this->mLength != -1 ) {
/**
* What is the page_latest field for this page?
*
- * @param int $flags a bit field; may be Title::GAID_FOR_UPDATE to select for update
- * @return Int or 0 if the page doesn't exist
+ * @param int $flags A bit field; may be Title::GAID_FOR_UPDATE to select for update
+ * @return int Int or 0 if the page doesn't exist
*/
public function getLatestRevID( $flags = 0 ) {
if ( !( $flags & Title::GAID_FOR_UPDATE ) && $this->mLatestID !== false ) {
* loading of the new page_id. It's also called from
* WikiPage::doDeleteArticleReal()
*
- * @param int $newid the new Article ID
+ * @param int $newid The new Article ID
*/
public function resetArticleID( $newid ) {
$linkCache = LinkCache::singleton();
/**
* Capitalize a text string for a title if it belongs to a namespace that capitalizes
*
- * @param string $text containing title to capitalize
- * @param int $ns namespace index, defaults to NS_MAIN
- * @return String containing capitalized title
+ * @param string $text Containing title to capitalize
+ * @param int $ns Namespace index, defaults to NS_MAIN
+ * @return string Containing capitalized title
*/
public static function capitalize( $text, $ns = NS_MAIN ) {
global $wgContLang;
* namespace prefixes, sets the other forms, and canonicalizes
* everything.
*
- * @return Bool true on success
+ * @return bool True on success
*/
private function secureAndSplit() {
# Initialisation
* WARNING: do not use this function on arbitrary user-supplied titles!
* On heavily-used templates it will max out the memory.
*
- * @param array $options may be FOR UPDATE
- * @param string $table table name
- * @param string $prefix fields prefix
- * @return Array of Title objects linking here
+ * @param array $options May be FOR UPDATE
+ * @param string $table Table name
+ * @param string $prefix Fields prefix
+ * @return array Array of Title objects linking here
*/
public function getLinksTo( $options = array(), $table = 'pagelinks', $prefix = 'pl' ) {
if ( count( $options ) > 0 ) {
* WARNING: do not use this function on arbitrary user-supplied titles!
* On heavily-used templates it will max out the memory.
*
- * @param array $options may be FOR UPDATE
- * @return Array of Title the Title objects linking here
+ * @param array $options May be FOR UPDATE
+ * @return array Array of Title the Title objects linking here
*/
public function getTemplateLinksTo( $options = array() ) {
return $this->getLinksTo( $options, 'templatelinks', 'tl' );
* WARNING: do not use this function on arbitrary user-supplied titles!
* On heavily-used templates it will max out the memory.
*
- * @param array $options may be FOR UPDATE
- * @param string $table table name
- * @param string $prefix fields prefix
- * @return Array of Title objects linking here
+ * @param array $options May be FOR UPDATE
+ * @param string $table Table name
+ * @param string $prefix Fields prefix
+ * @return array Array of Title objects linking here
*/
public function getLinksFrom( $options = array(), $table = 'pagelinks', $prefix = 'pl' ) {
global $wgContentHandlerUseDB;
* WARNING: do not use this function on arbitrary user-supplied titles!
* On heavily-used templates it will max out the memory.
*
- * @param array $options may be FOR UPDATE
- * @return Array of Title the Title objects used here
+ * @param array $options May be FOR UPDATE
+ * @return array Array of Title the Title objects used here
*/
public function getTemplateLinksFrom( $options = array() ) {
return $this->getLinksFrom( $options, 'templatelinks', 'tl' );
* Get an array of Title objects referring to non-existent articles linked from this page
*
* @todo check if needed (used only in SpecialBrokenRedirects.php, and should use redirect table in this case)
- * @return Array of Title the Title objects
+ * @return array Array of Title the Title objects
*/
public function getBrokenLinksFrom() {
if ( $this->getArticleID() == 0 ) {
* Get a list of URLs to purge from the Squid cache when this
* page changes
*
- * @return Array of String the URLs
+ * @return array Array of String the URLs
*/
public function getSquidURLs() {
$urls = array(
/**
* Move this page without authentication
*
- * @param $nt Title the new page Title
- * @return Mixed true on success, getUserPermissionsErrors()-like array on failure
+ * @param Title $nt The new page Title
+ * @return array|bool True on success, getUserPermissionsErrors()-like array on failure
*/
public function moveNoAuth( &$nt ) {
return $this->moveTo( $nt, false );
* Check whether a given move operation would be valid.
* Returns true if ok, or a getUserPermissionsErrors()-like array otherwise
*
- * @param $nt Title the new title
- * @param bool $auth indicates whether $wgUser's permissions
+ * @param Title $nt The new title
+ * @param bool $auth Indicates whether $wgUser's permissions
* should be checked
- * @param string $reason is the log summary of the move, used for spam checking
- * @return Mixed True on success, getUserPermissionsErrors()-like array on failure
+ * @param string $reason Is the log summary of the move, used for spam checking
+ * @return array|bool True on success, getUserPermissionsErrors()-like array on failure
*/
public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) {
global $wgUser, $wgContentHandlerUseDB;
/**
* Move a title to a new location
*
- * @param $nt Title the new title
- * @param bool $auth indicates whether $wgUser's permissions
+ * @param Title $nt The new title
+ * @param bool $auth Indicates whether $wgUser's permissions
* should be checked
- * @param string $reason the reason for the move
+ * @param string $reason The reason for the move
* @param bool $createRedirect Whether to create a redirect from the old title to the new title.
* Ignored if the user doesn't have the suppressredirect right.
- * @return Mixed true on success, getUserPermissionsErrors()-like array on failure
+ * @return array|bool True on success, getUserPermissionsErrors()-like array on failure
*/
public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true ) {
global $wgUser;
* Move page to a title which is either a redirect to the
* source page or nonexistent
*
- * @param $nt Title the page to move to, which should be a redirect or nonexistent
+ * @param Title $nt The page to move to, which should be a redirect or nonexistent
* @param string $reason The reason for the move
* @param bool $createRedirect Whether to leave a redirect at the old title. Does not check
* if the user has the suppressredirect right
/**
* Move this page's subpages to be subpages of $nt
*
- * @param $nt Title Move target
+ * @param Title $nt Move target
* @param bool $auth Whether $wgUser's permissions should be checked
* @param string $reason The reason for the move
* @param bool $createRedirect Whether to create redirects from the old subpages to
* the new ones Ignored if the user doesn't have the 'suppressredirect' right
- * @return mixed array with old page titles as keys, and strings (new page titles) or
+ * @return array Array with old page titles as keys, and strings (new page titles) or
* arrays (errors) as values, or an error array with numeric indices if no pages
* were moved
*/
* Checks if this page is just a one-rev redirect.
* Adds lock, so don't use just for light purposes.
*
- * @return Bool
+ * @return bool
*/
public function isSingleRevRedirect() {
global $wgContentHandlerUseDB;
* Checks if $this can be moved to a given Title
* - Selects for update, so don't call it unless you mean business
*
- * @param $nt Title the new title to check
- * @return Bool
+ * @param Title $nt The new title to check
+ * @return bool
*/
public function isValidMoveTarget( $nt ) {
# Is it an existing file?
* Get categories to which this Title belongs and return an array of
* categories' names.
*
- * @return Array of parents in the form:
+ * @return array Array of parents in the form:
* $parent => $currentarticle
*/
public function getParentCategories() {
/**
* Get a tree of parent categories
*
- * @param array $children with the children in the keys, to check for circular refs
- * @return Array Tree of parent categories
+ * @param array $children Array with the children in the keys, to check for circular refs
+ * @return array Tree of parent categories
*/
public function getParentCategoryTree( $children = array() ) {
$stack = array();
* Get an associative array for selecting this title from
* the "page" table
*
- * @return Array suitable for the $where parameter of DB::select()
+ * @return array Array suitable for the $where parameter of DB::select()
*/
public function pageCond() {
if ( $this->mArticleID > 0 ) {
*
* @param int $revId Revision ID. Get the revision that was before this one.
* @param int $flags Title::GAID_FOR_UPDATE
- * @return Int|Bool Old revision ID, or FALSE if none exists
+ * @return int|bool Old revision ID, or FALSE if none exists
*/
public function getPreviousRevisionID( $revId, $flags = 0 ) {
$db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
*
* @param int $revId Revision ID. Get the revision that was after this one.
* @param int $flags Title::GAID_FOR_UPDATE
- * @return Int|Bool Next revision ID, or FALSE if none exists
+ * @return int|bool Next revision ID, or FALSE if none exists
*/
public function getNextRevisionID( $revId, $flags = 0 ) {
$db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
* Get the first revision of the page
*
* @param int $flags Title::GAID_FOR_UPDATE
- * @return Revision|Null if page doesn't exist
+ * @return Revision|null If page doesn't exist
*/
public function getFirstRevision( $flags = 0 ) {
$pageId = $this->getArticleID( $flags );
* Get the oldest revision timestamp of this page
*
* @param int $flags Title::GAID_FOR_UPDATE
- * @return String: MW timestamp
+ * @return string MW timestamp
*/
public function getEarliestRevTime( $flags = 0 ) {
$rev = $this->getFirstRevision( $flags );
* @param int|Revision $old Old revision or rev ID (first before range)
* @param int|Revision $new New revision or rev ID (first after range)
* @param int|null $max Limit of Revisions to count, will be incremented to detect truncations
- * @return Int Number of revisions between these revisions.
+ * @return int Number of revisions between these revisions.
*/
public function countRevisionsBetween( $old, $new, $max = null ) {
if ( !( $old instanceof Revision ) ) {
/**
* Compare with another title.
*
- * @param $title Title
- * @return Bool
+ * @param Title $title
+ * @return bool
*/
public function equals( Title $title ) {
// Note: === is necessary for proper matching of number-like titles.
/**
* Check if this title is a subpage of another title
*
- * @param $title Title
- * @return Bool
+ * @param Title $title
+ * @return bool
*/
public function isSubpageOf( Title $title ) {
return $this->getInterwiki() === $title->getInterwiki()
* If you want to know if a title can be meaningfully viewed, you should
* probably call the isKnown() method instead.
*
- * @return Bool
+ * @return bool
*/
public function exists() {
return $this->getArticleID() != 0;
* existing code, but we might want to add an optional parameter to skip
* it and any other expensive checks.)
*
- * @return Bool
+ * @return bool
*/
public function isAlwaysKnown() {
$isKnown = null;
* @since 1.20
*
* @param Title $title
- * @param boolean|null $isKnown
+ * @param bool|null $isKnown
*/
wfRunHooks( 'TitleIsAlwaysKnown', array( $this, &$isKnown ) );
* since LinkHolderArray calls isAlwaysKnown() and does its own
* page existence check.
*
- * @return Bool
+ * @return bool
*/
public function isKnown() {
return $this->isAlwaysKnown() || $this->exists();
/**
* Does this page have source text?
*
- * @return Boolean
+ * @return bool
*/
public function hasSourceText() {
if ( $this->exists() ) {
/**
* Get the default message text or false if the message doesn't exist
*
- * @return String or false
+ * @return string|bool
*/
public function getDefaultMessageText() {
global $wgContLang;
/**
* Updates page_touched for this page; called from LinksUpdate.php
*
- * @return Bool true if the update succeeded
+ * @return bool True if the update succeeded
*/
public function invalidateCache() {
if ( wfReadOnly() ) {
/**
* Get the last touched timestamp
*
- * @param $db DatabaseBase: optional db
- * @return String last-touched timestamp
+ * @param DatabaseBase $db Optional db
+ * @return string Last-touched timestamp
*/
public function getTouched( $db = null ) {
$db = isset( $db ) ? $db : wfGetDB( DB_SLAVE );
/**
* Get the timestamp when this page was updated since the user last saw it.
*
- * @param $user User
- * @return String|Null
+ * @param User $user
+ * @return string|null
*/
public function getNotificationTimestamp( $user = null ) {
global $wgUser, $wgShowUpdatedMarker;
/**
* Generate strings used for xml 'id' names in monobook tabs
*
- * @param string $prepend defaults to 'nstab-'
- * @return String XML 'id' name
+ * @param string $prepend Defaults to 'nstab-'
+ * @return string XML 'id' name
*/
public function getNamespaceKey( $prepend = 'nstab-' ) {
global $wgContLang;
/**
* Get all extant redirects to this Title
*
- * @param int|Null $ns Single namespace to consider; NULL to consider all namespaces
+ * @param int|null $ns Single namespace to consider; NULL to consider all namespaces
* @return Title[] Array of Title redirects to this title
*/
public function getRedirectsHere( $ns = null ) {
/**
* Check if this Title is a valid redirect target
*
- * @return Bool
+ * @return bool
*/
public function isValidRedirectTarget() {
global $wgInvalidRedirectTargets;
/**
* Whether the magic words __INDEX__ and __NOINDEX__ function for this page.
*
- * @return Boolean
+ * @return bool
*/
public function canUseNoindex() {
global $wgContentNamespaces, $wgExemptFromUserRobotsControl;
*
* @since 1.21
* @param int $oldid Revision ID that's being edited
- * @return Array
+ * @return array
*/
public function getEditNotices( $oldid = 0 ) {
$notices = array();
private $mBlockedFromCreateAccount = false;
/**
- * @var Array
+ * @var array
*/
private $mWatchedItems = array();
* Create a new user object using data from session or cookies. If the
* login credentials are invalid, the result is an anonymous user.
*
- * @param WebRequest $request Object to use; $wgRequest will be used if omitted.
- * @return User object
+ * @param WebRequest|null $request Object to use; $wgRequest will be used if omitted.
+ * @return User
*/
public static function newFromSession( WebRequest $request = null ) {
$user = new User;
* Additional blacklisting may be added here rather than in
* isValidUserName() to avoid disrupting existing accounts.
*
- * @param string $name to match
+ * @param string $name String to match
* @return bool
*/
public static function isCreatableName( $name ) {
* Given unvalidated password input, return error message on failure.
*
* @param string $password Desired password
- * @return mixed: true on success, string or array of error message on failure
+ * @return bool|string|array true on success, string or array of error message on failure
*/
public function getPasswordValidity( $password ) {
$result = $this->checkPasswordValidity( $password );
/**
* Expire a user's password
* @since 1.23
- * @param $ts Mixed: optional timestamp to convert, default 0 for the current time
+ * @param int $ts Optional timestamp to convert, default 0 for the current time
*/
public function expirePassword( $ts = 0 ) {
$this->load();
/**
* Clear the password expiration for a user
* @since 1.23
- * @param bool $load ensure user object is loaded first
+ * @param bool $load Ensure user object is loaded first
*/
public function resetPasswordExpiration( $load = true ) {
global $wgPasswordExpirationDays;
* the cached User object, we assume that whatever mechanism is setting
* the expiration date is also expiring the User cache.
* @since 1.23
- * @return string|false the datestamp of the expiration, or null if not set
+ * @return string|bool The datestamp of the expiration, or null if not set
*/
public function getPasswordExpireDate() {
$this->load();
* Given unvalidated user input, return a canonical username, or false if
* the username is invalid.
* @param string $name User input
- * @param string|bool $validate type of validation to use:
- * - false No validation
- * - 'valid' Valid for batch processes
- * - 'usable' Valid for batch processes and login
- * - 'creatable' Valid for batch processes, login and account creation
+ * @param string|bool $validate Type of validation to use:
+ * - false No validation
+ * - 'valid' Valid for batch processes
+ * - 'usable' Valid for batch processes and login
+ * - 'creatable' Valid for batch processes, login and account creation
*
* @throws MWException
* @return bool|string
* @note This no longer clears uncached lazy-initialised properties;
* the constructor does that instead.
*
- * @param $name string|bool
+ * @param string|bool $name
*/
public function loadDefaults( $name = false ) {
wfProfileIn( __METHOD__ );
/**
* Return whether an item has been loaded.
*
- * @param string $item item to check. Current possibilities:
- * - id
- * - name
- * - realname
+ * @param string $item Item to check. Current possibilities:
+ * - id
+ * - name
+ * - realname
* @param string $all 'all' to check if the whole object has been loaded
- * or any other string to check if only the item is available (e.g.
- * for optimisation)
- * @return boolean
+ * or any other string to check if only the item is available (e.g.
+ * for optimisation)
+ * @return bool
*/
public function isItemLoaded( $item, $all = 'all' ) {
return ( $this->mLoadedItems === true && $all === 'all' ) ||
/**
* A comparison of two strings, not vulnerable to timing attacks
- * @param string $answer the secret string that you are comparing against.
- * @param string $test compare this string to the $answer.
+ * @param string $answer The secret string that you are comparing against.
+ * @param string $test Compare this string to the $answer.
* @return bool True if the strings are the same, false otherwise
*/
protected function compareSecrets( $answer, $test ) {
/**
* Load the data for this user object from another user object.
*
- * @param $user User
+ * @param User $user
*/
protected function loadFromUserObject( $user ) {
$user->load();
* will not be re-added automatically. The user will also not lose the
* group if they no longer meet the criteria.
*
- * @param string $event key in $wgAutopromoteOnce (each one has groups/criteria)
+ * @param string $event Key in $wgAutopromoteOnce (each one has groups/criteria)
*
* @return array Array of groups the user has been promoted to.
*
* data (i.e. self::$mCacheVars) is not cleared unless $reloadFrom is given.
*
* @param bool|string $reloadFrom Reload user and user_groups table data from a
- * given source. May be "name", "id", "defaults", "session", or false for
- * no reload.
+ * given source. May be "name", "id", "defaults", "session", or false for no reload.
*/
public function clearInstanceCache( $reloadFrom = false ) {
$this->mNewtalk = -1;
* Combine the language default options with any site-specific options
* and add the default language variants.
*
- * @return Array of String options
+ * @return array Array of String options
*/
public static function getDefaultOptions() {
global $wgNamespacesToBeSearchedDefault, $wgDefaultUserOptions, $wgContLang, $wgDefaultSkin;
/**
* Get blocking information
- * @param bool $bFromSlave Whether to check the slave database first. To
- * improve performance, non-critical checks are done
- * against slaves. Check when actually saving should be
- * done against master.
+ * @param bool $bFromSlave Whether to check the slave database first.
+ * To improve performance, non-critical checks are done against slaves.
+ * Check when actually saving should be done against master.
*/
private function getBlockedStatus( $bFromSlave = true ) {
global $wgProxyWhitelist, $wgUser, $wgApplyIpBlocksToXff;
* Whether the given IP is in a DNS blacklist.
*
* @param string $ip IP to check
- * @param bool $checkWhitelist whether to check the whitelist first
+ * @param bool $checkWhitelist Whether to check the whitelist first
* @return bool True if blacklisted.
*/
public function isDnsBlacklisted( $ip, $checkWhitelist = false ) {
* Whether the given IP is in a given DNS blacklist.
*
* @param string $ip IP to check
- * @param string|array $bases of Strings: URL of the DNS blacklist
+ * @param string|array $bases Array of Strings: URL of the DNS blacklist
* @return bool True if blacklisted.
*/
public function inDnsBlacklist( $ip, $bases ) {
/**
* Check if an IP address is in the local proxy list
*
- * @param $ip string
+ * @param string $ip
*
* @return bool
*/
* last-hit counters will be shared across wikis.
*
* @param string $action Action to enforce; 'edit' if unspecified
- * @param integer $incrBy Positive amount to increment counter by [defaults to 1]
+ * @param int $incrBy Positive amount to increment counter by [defaults to 1]
* @return bool True if a rate limiter was tripped
*/
public function pingLimiter( $action = 'edit', $incrBy = 1 ) {
* Check if user is blocked from editing a particular article
*
* @param Title $title Title to check
- * @param bool $bFromSlave whether to check the slave database instead of the master
+ * @param bool $bFromSlave Whether to check the slave database instead of the master
* @return bool
*/
public function isBlockedFrom( $title, $bFromSlave = false ) {
* If there are no new messages, it returns an empty array.
* @note This function was designed to accomodate multiple talk pages, but
* currently only returns a single link and revision.
- * @return Array
+ * @return array
*/
public function getNewMessageLinks() {
$talks = array();
* Add or update the new messages flag
* @param string $field 'user_ip' for anonymous users, 'user_id' otherwise
* @param string|int $id User's IP address for anonymous users, User ID otherwise
- * @param $curRev Revision new, as yet unseen revision of the user talk page. Ignored if null.
+ * @param Revision|null $curRev New, as yet unseen revision of the user talk page. Ignored if null.
* @return bool True if successful, false otherwise
*/
protected function updateNewtalk( $field, $id, $curRev = null ) {
/**
* Update the 'You have new messages!' status.
* @param bool $val Whether the user has new messages
- * @param $curRev Revision new, as yet unseen revision of the user talk page. Ignored if null or !$val.
+ * @param Revision $curRev New, as yet unseen revision of the user talk page. Ignored if null or !$val.
*/
public function setNewtalk( $val, $curRev = null ) {
if ( wfReadOnly() ) {
/**
* Get the user touched timestamp
- * @return string timestamp
+ * @return string Timestamp
*/
public function getTouched() {
$this->load();
/**
* Set the password for a password reminder or new account email
*
- * @param $str New password to set or null to set an invalid
+ * @param string $str New password to set or null to set an invalid
* password hash meaning that the user will not be able to use it
* @param bool $throttle If true, reset the throttle timestamp to the present
*/
* See User::listOptionKinds for the list of valid option types that can be provided.
*
* @see User::listOptionKinds
- * @param $context IContextSource
- * @param array $options assoc. array with options keys to check as keys. Defaults to $this->mOptions.
+ * @param IContextSource $context
+ * @param array $options Assoc. array with options keys to check as keys. Defaults to $this->mOptions.
* @return array the key => kind mapping data
*/
public function getOptionKinds( IContextSource $context, $options = null ) {
* Supported values are everything that can be reported by getOptionKinds()
* and 'all', which forces a reset of *all* preferences and overrides everything else.
*
- * @param array|string $resetKinds which kinds of preferences to reset. Defaults to
+ * @param array|string $resetKinds Which kinds of preferences to reset. Defaults to
* array( 'registered', 'registered-multiselect', 'registered-checkmatrix', 'unused' )
* for backwards-compatibility.
- * @param $context IContextSource|null context source used when $resetKinds
+ * @param IContextSource|null $context Context source used when $resetKinds
* does not contain 'all', passed to getOptionKinds().
* Defaults to RequestContext::getMain() when null.
*/
/**
* Get the permissions this user has.
- * @return Array of String permission names
+ * @return array Array of String permission names
*/
public function getRights() {
if ( is_null( $this->mRights ) ) {
/**
* Get the list of explicit group memberships this user has.
* The implicit * and user groups are not included.
- * @return Array of String internal group names
+ * @return array Array of String internal group names
*/
public function getGroups() {
$this->load();
* This includes all explicit groups, plus 'user' if logged in,
* '*' for all accounts, and autopromoted groups
* @param bool $recache Whether to avoid the cache
- * @return Array of String internal group names
+ * @return array Array of String internal group names
*/
public function getEffectiveGroups( $recache = false ) {
if ( $recache || is_null( $this->mEffectiveGroups ) ) {
* This includes 'user' if logged in, '*' for all accounts,
* and autopromoted groups
* @param bool $recache Whether to avoid the cache
- * @return Array of String internal group names
+ * @return array Array of String internal group names
*/
public function getAutomaticGroups( $recache = false ) {
if ( $recache || is_null( $this->mImplicitGroups ) ) {
/**
* Get the user's edit count.
- * @return int, null for anonymous users
+ * @return int|null null for anonymous users
*/
public function getEditCount() {
if ( !$this->getId() ) {
* Check if user is allowed to access a feature / make an action
*
* @internal param \String $varargs permissions to test
- * @return boolean: True if user is allowed to perform *any* of the given actions
+ * @return bool True if user is allowed to perform *any* of the given actions
*
* @return bool
*/
/**
* Check whether to enable recent changes patrol features for this user
- * @return boolean: True or false
+ * @return bool True or false
*/
public function useRCPatrol() {
global $wgUseRCPatrol;
* Get a WatchedItem for this user and $title.
*
* @since 1.22 $checkRights parameter added
- * @param $title Title
- * @param $checkRights int Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
+ * @param Title $title
+ * @param int $checkRights Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
* Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS.
* @return WatchedItem
*/
/**
* Check the watched status of an article.
* @since 1.22 $checkRights parameter added
- * @param $title Title of the article to look at
- * @param $checkRights int Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
+ * @param Title $title Title of the article to look at
+ * @param int $checkRights Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
* Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS.
* @return bool
*/
/**
* Watch an article.
* @since 1.22 $checkRights parameter added
- * @param $title Title of the article to look at
- * @param $checkRights int Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
+ * @param Title $title Title of the article to look at
+ * @param int $checkRights Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
* Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS.
*/
public function addWatch( $title, $checkRights = WatchedItem::CHECK_USER_RIGHTS ) {
/**
* Stop watching an article.
* @since 1.22 $checkRights parameter added
- * @param $title Title of the article to look at
- * @param $checkRights int Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
+ * @param Title $title Title of the article to look at
+ * @param int $checkRights Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
* Pass WatchedItem::CHECK_USER_RIGHTS or WatchedItem::IGNORE_USER_RIGHTS.
*/
public function removeWatch( $title, $checkRights = WatchedItem::CHECK_USER_RIGHTS ) {
* If e-notif e-mails are on, they will receive notification mails on
* the next change of the page if it's watched etc.
* @note If the user doesn't have 'editmywatchlist', this will do nothing.
- * @param $title Title of the article to look at
+ * @param Title $title Title of the article to look at
* @param int $oldid The revision id being viewed. If not given or 0, latest revision is assumed.
*/
public function clearNotification( &$title, $oldid = 0 ) {
/**
* Set the default cookies for this session on the user's client.
*
- * @param $request WebRequest object to use; $wgRequest will be used if null
+ * @param WebRequest|null $request WebRequest object to use; $wgRequest will be used if null
* is passed.
* @param bool $secure Whether to force secure/insecure cookies or use default
* @param bool $rememberMe Whether to add a Token cookie for elongated sessions
* Add a user to the database, return the user object
*
* @param string $name Username to add
- * @param array $params of Strings Non-default parameters to save to the database as user_* fields:
+ * @param array $params Array of Strings Non-default parameters to save to the database as user_* fields:
* - password The user's password hash. Password logins will be disabled if this is omitted.
* - newpassword Hash for a temporary password that has been mailed to the user
* - email The user's email address
* - token Random authentication token. Do not set.
* - registration Registration timestamp. Do not set.
*
- * @return User object, or null if the username already exists
+ * @return User|null User object, or null if the username already exists
*/
public static function createNew( $name, $params = array() ) {
$user = new User;
/**
* Get this user's personal page title.
*
- * @return Title: User's personal page title
+ * @return Title User's personal page title
*/
public function getUserPage() {
return Title::makeTitle( NS_USER, $this->getName() );
/**
* Get this user's talk page title.
*
- * @return Title: User's talk page title
+ * @return Title User's talk page title
*/
public function getTalkPage() {
$title = $this->getUserPage();
/**
* Check to see if the given clear-text password is one of the accepted passwords
* @param string $password user password.
- * @return boolean: True if the given password is correct, otherwise False.
+ * @return bool True if the given password is correct, otherwise False.
*/
public function checkPassword( $password ) {
global $wgAuth, $wgLegacyEncoding;
* Check if the given clear-text password matches the temporary password
* sent by e-mail for password reset operations.
*
- * @param $plaintext string
+ * @param string $plaintext
*
- * @return boolean: True if matches, false otherwise
+ * @return bool True if matches, false otherwise
*/
public function checkTemporaryPassword( $plaintext ) {
global $wgNewPasswordExpiry;
* @deprecated since 1.19, use getEditToken instead.
*
* @param string|array $salt of Strings Optional function-specific data for hashing
- * @param $request WebRequest object to use or null to use $wgRequest
+ * @param WebRequest|null $request WebRequest object to use or null to use $wgRequest
* @return string The new edit token
*/
public function editToken( $salt = '', $request = null ) {
* @since 1.19
*
* @param string|array $salt of Strings Optional function-specific data for hashing
- * @param $request WebRequest object to use or null to use $wgRequest
+ * @param WebRequest|null $request WebRequest object to use or null to use $wgRequest
* @return string The new edit token
*/
public function getEditToken( $salt = '', $request = null ) {
*
* @param string $val Input value to compare
* @param string $salt Optional function-specific data for hashing
- * @param WebRequest $request Object to use or null to use $wgRequest
- * @return boolean: Whether the token matches
+ * @param WebRequest|null $request Object to use or null to use $wgRequest
+ * @return bool Whether the token matches
*/
public function matchEditToken( $val, $salt = '', $request = null ) {
$sessionToken = $this->getEditToken( $salt, $request );
*
* @param string $val Input value to compare
* @param string $salt Optional function-specific data for hashing
- * @param WebRequest $request object to use or null to use $wgRequest
- * @return boolean: Whether the token matches
+ * @param WebRequest|null $request object to use or null to use $wgRequest
+ * @return bool Whether the token matches
*/
public function matchEditTokenNoSuffix( $val, $salt = '', $request = null ) {
$sessionToken = $this->getEditToken( $salt, $request );
* Generate a new e-mail confirmation token and send a confirmation/invalidation
* mail to the user's given address.
*
- * @param string $type message to send, either "created", "changed" or "set"
- * @return Status object
+ * @param string $type Message to send, either "created", "changed" or "set"
+ * @return Status
*/
public function sendConfirmationMail( $type = 'created' ) {
global $wgLang;
* @note Call saveSettings() after calling this function to commit
* this change to the database.
*
- * @param &$expiration \mixed Accepts the expiration time
+ * @param string &$expiration Accepts the expiration time
* @return string New token
*/
protected function confirmationToken( &$expiration ) {
/**
* Get the permissions associated with a given list of groups
*
- * @param array $groups of Strings List of internal group names
- * @return Array of Strings List of permission key names for given groups combined
+ * @param array $groups Array of Strings List of internal group names
+ * @return array Array of Strings List of permission key names for given groups combined
*/
public static function getGroupPermissions( $groups ) {
global $wgGroupPermissions, $wgRevokePermissions;
* Get all the groups who have a given permission
*
* @param string $role Role to check
- * @return Array of Strings List of internal group names with the given permission
+ * @return array Array of Strings List of internal group names with the given permission
*/
public static function getGroupsWithPermission( $role ) {
global $wgGroupPermissions;
* Return the set of defined explicit groups.
* The implicit groups (by default *, 'user' and 'autoconfirmed')
* are not included, as they are defined automatically, not in the database.
- * @return Array of internal group names
+ * @return array Array of internal group names
*/
public static function getAllGroups() {
global $wgGroupPermissions, $wgRevokePermissions;
/**
* Get a list of all available permissions.
- * @return Array of permission names
+ * @return array Array of permission names
*/
public static function getAllRights() {
if ( self::$mAllRights === false ) {
/**
* Get a list of implicit groups
- * @return Array of Strings Array of internal group names
+ * @return array Array of Strings Array of internal group names
*/
public static function getImplicitGroups() {
global $wgImplicitGroups;
/**
* Returns an array of the groups that a particular group can add/remove.
*
- * @param string $group the group to check for whether it can add/remove
- * @return Array array( 'add' => array( addablegroups ),
+ * @param string $group The group to check for whether it can add/remove
+ * @return array array( 'add' => array( addablegroups ),
* 'remove' => array( removablegroups ),
* 'add-self' => array( addablegroups to self),
* 'remove-self' => array( removable groups from self) )
/**
* Returns an array of groups that this user can add and remove
- * @return Array array( 'add' => array( addablegroups ),
+ * @return array array( 'add' => array( addablegroups ),
* 'remove' => array( removablegroups ),
* 'add-self' => array( addablegroups to self),
* 'remove-self' => array( removable groups from self) )
/**
* Initialize user_editcount from data out of the revision table
*
- * @param $add Integer Edits to add to the count from the revision table
- * @return integer Number of edits
+ * @param int $add Edits to add to the count from the revision table
+ * @return int Number of edits
*/
protected function initEditCount( $add = 0 ) {
// Pull from a slave to be less cruel to servers
* @param string $password Plain-text password to compare
* @param string|bool $userId User ID for old-style password salt
*
- * @return boolean
+ * @return bool
*/
public static function comparePasswords( $hash, $password, $userId = false ) {
$type = substr( $hash, 0, 3 );
* Add a newuser log entry for this user.
* Before 1.19 the return value was always true.
*
- * @param string|bool $action account creation type.
+ * @param string|bool $action Account creation type.
* - String, one of the following values:
* - 'create' for an anonymous user creating an account for himself.
* This will force the action's performer to be the created user itself,
* - false will be converted to 'create' if this object is the same as
* $wgUser and to 'create2' otherwise
*
- * @param string $reason user supplied reason
+ * @param string $reason User supplied reason
*
* @return int|bool True if not $wgNewUserLog; otherwise ID of log item or 0 on failure
*/
"watchlist-details": "{{PLURAL:$1|$1 page|$1 pages}} on your watchlist, not separately counting talk pages.",
"wlheader-enotif": "Email notification is enabled.",
"wlheader-showupdated": "Pages that have been changed since you last visited them are shown in <strong>bold</strong>.",
- "watchmethod-recent": "checking recent edits for watched pages",
- "watchmethod-list": "checking watched pages for recent edits",
- "watchlistcontains": "Your watchlist contains $1 {{PLURAL:$1|page|pages}}.",
- "iteminvalidname": "Problem with item \"$1\", invalid name...",
"wlnote2": "Below are the changes in the last {{PLURAL:$1|hour|<strong>$1</strong> hours}}, as of $2, $3.",
"wlshowlast": "Show last $1 hours $2 days $3",
"watchlist-options": "Watchlist options",
"lag-warn-normal": "Changes newer than $1 {{PLURAL:$1|second|seconds}} may not be shown in this list.",
"lag-warn-high": "Due to high database server lag, changes newer than $1 {{PLURAL:$1|second|seconds}} may not be shown in this list.",
"editwatchlist-summary": "",
- "watchlistedit-numitems": "Your watchlist contains {{PLURAL:$1|1 title|$1 titles}}, excluding talk pages.",
- "watchlistedit-noitems": "Your watchlist contains no titles.",
"watchlistedit-normal-title": "Edit watchlist",
"watchlistedit-normal-legend": "Remove titles from watchlist",
"watchlistedit-normal-explain": "Titles on your watchlist are shown below.\nTo remove a title, check the box next to it, and click \"{{int:Watchlistedit-normal-submit}}\".\nYou can also [[Special:EditWatchlist/raw|edit the raw list]].",
$this->addOption( 'parser1', 'The first parser to compare.', true, true );
$this->addOption( 'parser2', 'The second parser to compare.', true, true );
$this->addOption( 'tidy', 'Run tidy on the articles.', false, false );
- $this->addOption( 'save-failed', 'Folder in which articles which differ will be stored.', false, true );
+ $this->addOption(
+ 'save-failed',
+ 'Folder in which articles which differ will be stored.',
+ false,
+ true
+ );
$this->addOption( 'show-diff', 'Show a diff of the two renderings.', false, false );
- $this->addOption( 'diff-bin', 'Binary to use for diffing (can also be provided by DIFF env var).', false, false );
- $this->addOption( 'strip-parameters', 'Remove parameters of html tags to increase readability.', false, false );
- $this->addOption( 'show-parsed-output', 'Show the parsed html if both Parsers give the same output.', false, false );
+ $this->addOption(
+ 'diff-bin',
+ 'Binary to use for diffing (can also be provided by DIFF env var).',
+ false,
+ false
+ );
+ $this->addOption(
+ 'strip-parameters',
+ 'Remove parameters of html tags to increase readability.',
+ false,
+ false
+ );
+ $this->addOption(
+ 'show-parsed-output',
+ 'Show the parsed html if both Parsers give the same output.',
+ false,
+ false
+ );
}
public function checkOptions() {
$content = $rev->getContent();
if ( $content->getModel() !== CONTENT_MODEL_WIKITEXT ) {
- $this->error( "Page {$title->getPrefixedText()} does not contain wikitext but {$content->getModel()}\n" );
+ $this->error( "Page {$title->getPrefixedText()} does not contain wikitext "
+ . "but {$content->getModel()}\n" );
+
return;
}
$this->error( "Parsing for {$title->getPrefixedText()} differs\n" );
if ( $this->saveFailed ) {
- file_put_contents( $this->saveFailed . '/' . rawurlencode( $title->getPrefixedText() ) . ".txt", $text );
+ file_put_contents(
+ $this->saveFailed . '/' . rawurlencode( $title->getPrefixedText() ) . ".txt",
+ $text
+ );
}
if ( $this->showDiff ) {
- $this->output( wfDiff( $this->stripParameters( $output1->getText() ), $this->stripParameters( $output2->getText() ), '' ) );
+ $this->output( wfDiff(
+ $this->stripParameters( $output1->getText() ),
+ $this->stripParameters( $output2->getText() ),
+ ''
+ ) );
}
} else {
$this->output( $title->getPrefixedText() . "\tOK\n" );
+
if ( $this->showParsedOutput ) {
$this->output( $this->stripParameters( $output1->getText() ) );
}
public function __construct() {
parent::__construct();
- $this->mDescription = "Convert from the old links schema (string->ID) to the new schema (ID->ID).
-The wiki should be put into read-only mode while this script executes";
+ $this->mDescription =
+ "Convert from the old links schema (string->ID) to the new schema (ID->ID)."
+ . "The wiki should be put into read-only mode while this script executes";
$this->addArg( 'logperformance', "Log performance to perfLogFilename.", false );
- $this->addArg( 'perfLogFilename', "Filename where performance is logged if --logperformance was set (defaults to 'convLinksPerf.txt').", false );
- $this->addArg( 'keep-links-table', "Don't overwrite the old links table with the new one, leave the new table at links_temp.", false );
- $this->addArg( 'nokeys', "Don't create keys, and so allow duplicates in the new links table.\n
-This gives a huge speed improvement for very large links tables which are MyISAM." /* (What about InnoDB?) */, false );
+ $this->addArg(
+ 'perfLogFilename',
+ "Filename where performance is logged if --logperformance was set "
+ . "(defaults to 'convLinksPerf.txt').",
+ false
+ );
+ $this->addArg(
+ 'keep-links-table',
+ "Don't overwrite the old links table with the new one, leave the new table at links_temp.",
+ false
+ );
+ $this->addArg(
+ 'nokeys',
+ /* (What about InnoDB?) */
+ "Don't create keys, and so allow duplicates in the new links table.\n"
+ . "This gives a huge speed improvement for very large links tables which are MyISAM.",
+ false
+ );
}
public function getDbType() {
global $wgContLang;
- $numBadLinks = $curRowsRead = 0; # counters etc
- $totalTuplesInserted = 0; # total tuples INSERTed into links_temp
+ # counters etc
+ $numBadLinks = $curRowsRead = 0;
- $reportCurReadProgress = true; # whether or not to give progress reports while reading IDs from cur table
- $curReadReportInterval = 1000; # number of rows between progress reports
+ # total tuples INSERTed into links_temp
+ $totalTuplesInserted = 0;
- $reportLinksConvProgress = true; # whether or not to give progress reports during conversion
- $linksConvInsertInterval = 1000; # number of rows per INSERT
+ # whether or not to give progress reports while reading IDs from cur table
+ $reportCurReadProgress = true;
+
+ # number of rows between progress reports
+ $curReadReportInterval = 1000;
+
+ # whether or not to give progress reports during conversion
+ $reportLinksConvProgress = true;
+
+ # number of rows per INSERT
+ $linksConvInsertInterval = 1000;
$initialRowOffset = 0;
- # $finalRowOffset = 0; # not used yet; highest row number from links table to process
+
+ # not used yet; highest row number from links table to process
+ # $finalRowOffset = 0;
$overwriteLinksTable = !$this->hasOption( 'keep-links-table' );
$noKeys = $this->hasOption( 'noKeys' );
# --------------------------------------------------------------------
- list( $cur, $links, $links_temp, $links_backup ) = $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
+ list( $cur, $links, $links_temp, $links_backup ) =
+ $dbw->tableNamesN( 'cur', 'links', 'links_temp', 'links_backup' );
if ( $dbw->tableExists( 'pagelinks' ) ) {
$this->output( "...have pagelinks; skipping old links table updates\n" );
$curRowsRead++;
if ( $reportCurReadProgress ) {
if ( ( $curRowsRead % $curReadReportInterval ) == 0 ) {
- $this->performanceLog( $fh, $curRowsRead . " " . ( $this->getMicroTime() - $baseTime ) . "\n" );
+ $this->performanceLog(
+ $fh,
+ $curRowsRead . " " . ( $this->getMicroTime() - $baseTime ) . "\n"
+ );
$this->output( "\t$curRowsRead rows of $cur table read.\n" );
}
}
$dbw->freeResult( $res );
$dbw->bufferResults( true );
$this->output( "Finished loading IDs.\n\n" );
- $this->performanceLog( $fh, "Took " . ( $this->getMicroTime() - $baseTime ) . " seconds to load IDs.\n\n" );
+ $this->performanceLog(
+ $fh,
+ "Took " . ( $this->getMicroTime() - $baseTime ) . " seconds to load IDs.\n\n"
+ );
# --------------------------------------------------------------------
$this->performanceLog( $fh, "Processing $numRows rows from $links table...\n" );
$this->performanceLog( $fh, "rows inserted vs seconds elapsed:\n" );
- for ( $rowOffset = $initialRowOffset; $rowOffset < $numRows; $rowOffset += $linksConvInsertInterval ) {
+ for ( $rowOffset = $initialRowOffset; $rowOffset < $numRows;
+ $rowOffset += $linksConvInsertInterval
+ ) {
$sqlRead = "SELECT * FROM $links ";
$sqlRead = $dbw->limitResult( $sqlRead, $linksConvInsertInterval, $rowOffset );
$res = $dbw->query( $sqlRead );
}
}
$dbw->freeResult( $res );
- # $this->output( "rowOffset: $rowOffset\ttuplesAdded: $tuplesAdded\tnumBadLinks: $numBadLinks\n" );
+ # $this->output( "rowOffset: $rowOffset\ttuplesAdded: "
+ # . "$tuplesAdded\tnumBadLinks: $numBadLinks\n" );
if ( $tuplesAdded != 0 ) {
if ( $reportLinksConvProgress ) {
$this->output( "Inserting $tuplesAdded tuples into $links_temp..." );
$totalTuplesInserted += $tuplesAdded;
if ( $reportLinksConvProgress ) {
$this->output( " done. Total $totalTuplesInserted tuples inserted.\n" );
- $this->performanceLog( $fh, $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n" );
+ $this->performanceLog(
+ $fh,
+ $totalTuplesInserted . " " . ( $this->getMicroTime() - $baseTime ) . "\n"
+ );
}
}
}
- $this->output( "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n\n" );
- $this->performanceLog( $fh, "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n" );
- $this->performanceLog( $fh, "Total execution time: " . ( $this->getMicroTime() - $startTime ) . " seconds.\n" );
+ $this->output( "$totalTuplesInserted valid titles and "
+ . "$numBadLinks invalid titles were processed.\n\n" );
+ $this->performanceLog(
+ $fh,
+ "$totalTuplesInserted valid titles and $numBadLinks invalid titles were processed.\n"
+ );
+ $this->performanceLog(
+ $fh,
+ "Total execution time: " . ( $this->getMicroTime() - $startTime ) . " seconds.\n"
+ );
if ( $this->logPerformance ) {
fclose ( $fh );
}
* @ingroup Maintenance
*/
class CreateAndPromote extends Maintenance {
-
- static $permitRoles = array( 'sysop', 'bureaucrat', 'bot' );
+ private static $permitRoles = array( 'sysop', 'bureaucrat', 'bot' );
public function __construct() {
parent::__construct();
$this->mDescription = "Create a new user account and/or grant it additional rights";
- $this->addOption( "force", "If acccount exists already, just grant it rights or change password." );
+ $this->addOption(
+ 'force',
+ 'If acccount exists already, just grant it rights or change password.'
+ );
foreach ( self::$permitRoles as $role ) {
$this->addOption( $role, "Add the account to the {$role} group" );
}
$inGroups = $user->getGroups();
}
- $promotions = array_diff( array_filter( self::$permitRoles, array( $this, 'hasOption' ) ), $inGroups );
+ $promotions = array_diff(
+ array_filter( self::$permitRoles, array( $this, 'hasOption' ) ),
+ $inGroups
+ );
if ( $exists && !$password && count( $promotions ) === 0 ) {
$this->output( "Account exists and nothing to do.\n" );
class DeleteArchivedRevisions extends Maintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Deletes all archived revisions\nThese revisions will no longer be restorable";
+ $this->mDescription =
+ "Deletes all archived revisions\nThese revisions will no longer be restorable";
$this->addOption( 'delete', 'Performs the deletion' );
}
$dbw = wfGetDB( DB_MASTER );
$res = $dbw->selectRow( 'archive', 'COUNT(*) as count', array(), __FUNCTION__ );
$this->output( "Found {$res->count} revisions to delete.\n" );
- $this->output( "Please run the script again with the --delete option to really delete the revisions.\n" );
+ $this->output( "Please run the script again with the --delete option "
+ . "to really delete the revisions.\n" );
}
}
}
$dbw = wfGetDB( DB_MASTER );
# Handle each entry
+ // @codingStandardsIgnoreStart Ignore Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
for ( $linenum = 1; !feof( $file ); $linenum++ ) {
+ // @codingStandardsIgnoreEnd
$line = trim( fgets( $file ) );
if ( $line == '' ) {
continue;
foreach ( $res as $row ) {
if ( $i % $this->report == 0 ) {
- $this->output( sprintf( "%s: %13s done (%s)\n", wfWikiID(), "$i/$total", wfPercent( $i / $total * 100 ) ) );
+ $this->output( sprintf(
+ "%s: %13s done (%s)\n",
+ wfWikiID(),
+ "$i/$total",
+ wfPercent( $i / $total * 100 )
+ ) );
}
$md5 = md5( $row->img_name );
$wgMemc->delete( wfMemcKey( 'Image', $md5 ) );
# Find all the orphaned revisions
$this->output( "Checking for orphaned revisions..." );
- $sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id WHERE page_namespace IS NULL";
+ $sql = "SELECT rev_id FROM {$revision} LEFT JOIN {$page} ON rev_page = page_id "
+ . "WHERE page_namespace IS NULL";
$res = $dbw->query( $sql, 'deleteOrphanedRevisions' );
# Stash 'em all up for deletion (if needed)
$this->output( "Revision $revID not found\n" );
} else {
$affected += $dbw->affectedRows();
- $pageID = $dbw->selectField( 'revision', 'rev_page', array( 'rev_id' => $revID ), __METHOD__ );
- $pageLatest = $dbw->selectField( 'page', 'page_latest', array( 'page_id' => $pageID ), __METHOD__ );
+ $pageID = $dbw->selectField(
+ 'revision',
+ 'rev_page',
+ array( 'rev_id' => $revID ),
+ __METHOD__
+ );
+ $pageLatest = $dbw->selectField(
+ 'page',
+ 'page_latest',
+ array( 'page_id' => $pageID ),
+ __METHOD__
+ );
$dbw->delete( 'revision', array( 'rev_id' => $revID ) );
if ( $pageLatest == $revID ) {
// Database integrity
- $newLatest = $dbw->selectField( 'revision', 'rev_id', array( 'rev_page' => $pageID ), __METHOD__, array( 'ORDER BY' => 'rev_timestamp DESC' ) );
- $dbw->update( 'page', array( 'page_latest' => $newLatest ), array( 'page_id' => $pageID ), __METHOD__ );
+ $newLatest = $dbw->selectField(
+ 'revision',
+ 'rev_id',
+ array( 'rev_page' => $pageID ),
+ __METHOD__,
+ array( 'ORDER BY' => 'rev_timestamp DESC' )
+ );
+ $dbw->update(
+ 'page',
+ array( 'page_latest' => $newLatest ),
+ array( 'page_id' => $pageID ),
+ __METHOD__
+ );
}
}
}
// @todo FIXME: Replace this hack with general farm-friendly code
# @todo FIXME: Wikimedia-specific stuff needs to go away to an ext
# Maybe a hook?
+ // @codingStandardsIgnoreStart MediaWiki.NamingConventions.ValidGlobalName.wgPrefix
global $cluster;
$cluster = 'pmtpa';
+ // @codingStandardsIgnoreEnd
require "$IP/../wmf-config/wgConf.php";
}
// Require the configuration (probably LocalSettings.php)
}
if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
- if ( $wgLocalisationCacheConf['storeClass'] === false && ( $wgLocalisationCacheConf['store'] == 'db' || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) ) ) {
+ if ( $wgLocalisationCacheConf['storeClass'] === false
+ && ( $wgLocalisationCacheConf['store'] == 'db'
+ || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) )
+ ) {
$wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
}
}
$revision = new WikiRevision;
$revision->setText( file_get_contents( $this->getOption( 'file' ) ) );
- $revision->setTitle( Title::newFromText( rawurldecode( basename( $this->getOption( 'file' ), '.txt' ) ) ) );
+ $revision->setTitle( Title::newFromText(
+ rawurldecode( basename( $this->getOption( 'file' ), '.txt' ) )
+ ) );
$this->handleRevision( $revision );
+
return;
}
if ( $this->getOption( 'dump' ) == '-' ) {
$source = new ImportStreamSource( $this->getStdin() );
} else {
- $this->error( "Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true );
+ $this->error( "Sorry, I don't support dump filenames yet. "
+ . "Use - and provide it on stdin on the meantime.", true );
}
$importer = new WikiImporter( $source );
$this->error( round( $this->count / $delta, 2 ) . " pages/sec" );
}
- # Perform the memory_get_peak_usage() when all the other data has been output so there's no damage if it dies.
- # It is only available since 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
+ # Perform the memory_get_peak_usage() when all the other data has been
+ # output so there's no damage if it dies. It is only available since
+ # 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
$this->error( "Memory peak usage of " . memory_get_peak_usage() . " bytes\n" );
}
*/
private function getHooksFromOnlineDoc() {
// All hooks
- $allhookdata = Http::get( 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php' );
+ $allhookdata = Http::get(
+ 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&'
+ . 'cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php'
+ );
$allhookdata = unserialize( $allhookdata );
$allhooks = array();
foreach ( $allhookdata['query']['categorymembers'] as $page ) {
}
}
// Removed hooks
- $oldhookdata = Http::get( 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Removed_hooks&cmlimit=500&format=php' );
+ $oldhookdata = Http::get(
+ 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&'
+ . 'cmtitle=Category:Removed_hooks&cmlimit=500&format=php'
+ );
$oldhookdata = unserialize( $oldhookdata );
$removed = array();
foreach ( $oldhookdata['query']['categorymembers'] as $page ) {
private function getHooksFromFile( $file ) {
$content = file_get_contents( $file );
$m = array();
- preg_match_all( '/(?:wfRunHooks|Hooks\:\:run|ContentHandler\:\:runLegacyHooks)\(\s*([\'"])(.*?)\1/', $content, $m );
+ preg_match_all(
+ '/(?:wfRunHooks|Hooks\:\:run|ContentHandler\:\:runLegacyHooks)\(\s*([\'"])(.*?)\1/',
+ $content,
+ $m
+ );
+
return $m[2];
}
if ( !$async ) {
$success = ( $dryrun ? true : $job->run() );
if ( !$success ) {
- $this->error( "Error fixing " . $titleA->getPrefixedText() . ": " . $job->getLastError() . "\n" );
+ $this->error( "Error fixing " . $titleA->getPrefixedText()
+ . ": " . $job->getLastError() . "\n" );
}
} else {
$jobs[] = $job;
class FixExtLinksProtocolRelative extends LoggedUpdateMaintenance {
public function __construct() {
parent::__construct();
- $this->mDescription = "Fixes any entries in the externallinks table containing protocol-relative URLs";
+ $this->mDescription =
+ "Fixes any entries in the externallinks table containing protocol-relative URLs";
}
protected function getUpdateKey() {
)
), __METHOD__, array( 'IGNORE' )
);
- $db->delete( 'externallinks', array( 'el_index' => $row->el_index, 'el_from' => $row->el_from, 'el_to' => $row->el_to ), __METHOD__ );
+ $db->delete(
+ 'externallinks',
+ array(
+ 'el_index' => $row->el_index,
+ 'el_from' => $row->el_from,
+ 'el_to' => $row->el_to
+ ),
+ __METHOD__
+ );
}
$this->output( "Done, $count rows updated.\n" );
return true;
* @ingroup Maintenance
*/
class FixSlaveDesync extends Maintenance {
+ /** @var array */
+ private $slaveIndexes;
+
public function __construct() {
parent::__construct();
$this->mDescription = "";
public function execute() {
$this->slaveIndexes = array();
- for ( $i = 1; $i < wfGetLB()->getServerCount(); $i++ ) {
+ $serverCount = wfGetLB()->getServerCount();
+ for ( $i = 1; $i < $serverCount; $i++ ) {
if ( wfGetLB()->isNonZeroLoad( $i ) ) {
$this->slaveIndexes[] = $i;
}
$n = 0;
$dbw = wfGetDB( DB_MASTER );
$masterIDs = array();
- $res = $dbw->select( 'page', array( 'page_id', 'page_latest' ), array( 'page_id<6054123' ), __METHOD__ );
+ $res = $dbw->select(
+ 'page',
+ array( 'page_id', 'page_latest' ),
+ array( 'page_id<6054123' ),
+ __METHOD__
+ );
$this->output( "Number of pages: " . $res->numRows() . "\n" );
foreach ( $res as $row ) {
$masterIDs[$row->page_id] = $row->page_latest;
foreach ( $this->slaveIndexes as $i ) {
$db = wfGetDB( $i );
- $res = $db->select( 'page', array( 'page_id', 'page_latest' ), array( 'page_id<6054123' ), __METHOD__ );
+ $res = $db->select(
+ 'page',
+ array( 'page_id', 'page_latest' ),
+ array( 'page_id<6054123' ),
+ __METHOD__
+ );
foreach ( $res as $row ) {
if ( isset( $masterIDs[$row->page_id] ) && $masterIDs[$row->page_id] != $row->page_latest ) {
$desync[$row->page_id] = true;
if ( count( $masterIDs ) < count( $slaveIDs ) ) {
$missingIDs = array_diff( $slaveIDs, $masterIDs );
if ( count( $missingIDs ) ) {
- $this->output( "Found " . count( $missingIDs ) . " lost in master, copying from slave... " );
+ $this->output( "Found " . count( $missingIDs )
+ . " lost in master, copying from slave... " );
$dbFrom = $dbw;
$found = true;
$toMaster = true;
} else {
$missingIDs = array_diff( $masterIDs, $slaveIDs );
if ( count( $missingIDs ) ) {
- $this->output( "Found " . count( $missingIDs ) . " missing revision(s), copying from master... " );
+ $this->output( "Found " . count( $missingIDs )
+ . " missing revision(s), copying from master... " );
$dbFrom = $dbw;
$found = true;
$toMaster = false;
if ( $found ) {
$this->output( "Fixing page_latest... " );
if ( $toMaster ) {
- # $dbw->update( 'page', array( 'page_latest' => $realLatest ), array( 'page_id' => $pageID ), __METHOD__ );
+ /*
+ $dbw->update(
+ 'page',
+ array( 'page_latest' => $realLatest ),
+ array( 'page_id' => $pageID ),
+ __METHOD__
+ );
+ */
} else {
foreach ( $this->slaveIndexes as $i ) {
$db = wfGetDB( $i );
- $db->update( 'page', array( 'page_latest' => $realLatest ), array( 'page_id' => $pageID ), __METHOD__ );
+ $db->update(
+ 'page',
+ array( 'page_latest' => $realLatest ),
+ array( 'page_id' => $pageID ),
+ __METHOD__
+ );
}
}
$this->output( "done\n" );
$fixup = -$offset;
$sql = "UPDATE $revisionTable " .
- "SET rev_timestamp=DATE_FORMAT(DATE_ADD(rev_timestamp, INTERVAL $fixup SECOND), '%Y%m%d%H%i%s') " .
+ "SET rev_timestamp="
+ . "DATE_FORMAT(DATE_ADD(rev_timestamp, INTERVAL $fixup SECOND), '%Y%m%d%H%i%s') " .
"WHERE rev_id IN (" . $dbw->makeList( $badRevs ) . ')';
$dbw->query( $sql, __METHOD__ );
$this->output( "Done\n" );
foreach ( $res as $row ) {
$id = $row->user_id;
// Get first edit time
- $timestamp = $dbr->selectField( 'revision', 'MIN(rev_timestamp)', array( 'rev_user' => $id ), __METHOD__ );
+ $timestamp = $dbr->selectField(
+ 'revision',
+ 'MIN(rev_timestamp)',
+ array( 'rev_user' => $id ),
+ __METHOD__
+ );
// Update
if ( !empty( $timestamp ) ) {
- $dbw->update( 'user', array( 'user_registration' => $timestamp ), array( 'user_id' => $id ), __METHOD__ );
+ $dbw->update(
+ 'user',
+ array( 'user_registration' => $timestamp ),
+ array( 'user_id' => $id ),
+ __METHOD__
+ );
$this->output( "$id $timestamp\n" );
} else {
$this->output( "$id NULL\n" );
public $fspath;
/**
- * The URL path to prepend to filenames in the index; should resolve to the same directory as $fspath
+ * The URL path to prepend to filenames in the index;
+ * should resolve to the same directory as $fspath.
*
* @var string
*/
public function __construct() {
parent::__construct();
$this->mDescription = "Creates a sitemap for the site";
- $this->addOption( 'fspath', 'The file system path to save to, e.g. /tmp/sitemap; defaults to current directory', false, true );
- $this->addOption( 'urlpath', 'The URL path corresponding to --fspath, prepended to filenames in the index; defaults to an empty string', false, true );
- $this->addOption( 'compress', 'Compress the sitemap files, can take value yes|no, default yes', false, true );
+ $this->addOption(
+ 'fspath',
+ 'The file system path to save to, e.g. /tmp/sitemap; defaults to current directory',
+ false,
+ true
+ );
+ $this->addOption(
+ 'urlpath',
+ 'The URL path corresponding to --fspath, prepended to filenames in the index; '
+ . 'defaults to an empty string',
+ false,
+ true
+ );
+ $this->addOption(
+ 'compress',
+ 'Compress the sitemap files, can take value yes|no, default yes',
+ false,
+ true
+ );
$this->addOption( 'skip-redirects', 'Do not include redirecting articles in the sitemap' );
- $this->addOption( 'identifier', 'What site identifier to use for the wiki, defaults to $wgDBname', false, true );
+ $this->addOption(
+ 'identifier',
+ 'What site identifier to use for the wiki, defaults to $wgDBname',
+ false,
+ true
+ );
}
/**
* @return string
*/
function priority( $namespace ) {
- return isset( $this->priorities[$namespace] ) ? $this->priorities[$namespace] : $this->guessPriority( $namespace );
+ return isset( $this->priorities[$namespace] )
+ ? $this->priorities[$namespace]
+ : $this->guessPriority( $namespace );
}
/**
* @return string
*/
function guessPriority( $namespace ) {
- return MWNamespace::isSubject( $namespace ) ? $this->priorities[self::GS_MAIN] : $this->priorities[self::GS_TALK];
+ return MWNamespace::isSubject( $namespace )
+ ? $this->priorities[self::GS_MAIN]
+ : $this->priorities[self::GS_TALK];
}
/**
continue;
}
- if ( $i++ === 0 || $i === $this->url_limit + 1 || $length + $this->limit[1] + $this->limit[2] > $this->size_limit ) {
+ if ( $i++ === 0
+ || $i === $this->url_limit + 1
+ || $length + $this->limit[1] + $this->limit[2] > $this->size_limit
+ ) {
if ( $this->file !== false ) {
$this->write( $this->file, $this->closeFile() );
$this->close( $this->file );
if ( $vCode == $wgContLang->getCode() ) {
continue; // we don't want default variant
}
- $entry = $this->fileEntry( $title->getCanonicalURL( '', $vCode ), $date, $this->priority( $namespace ) );
+ $entry = $this->fileEntry(
+ $title->getCanonicalURL( '', $vCode ),
+ $date,
+ $this->priority( $namespace )
+ );
$length += strlen( $entry );
$this->write( $this->file, $entry );
}
function open( $file, $flags ) {
$resource = $this->compress ? gzopen( $file, $flags ) : fopen( $file, $flags );
if ( $resource === false ) {
- throw new MWException( __METHOD__ . " error opening file $file with flags $flags. Check permissions?" );
+ throw new MWException( __METHOD__
+ . " error opening file $file with flags $flags. Check permissions?" );
}
return $resource;
}
$this->limit = array(
strlen( $this->openFile() ),
- strlen( $this->fileEntry( $title->getCanonicalURL(), wfTimestamp( TS_ISO_8601, wfTimestamp() ), $this->priority( $namespace ) ) ),
+ strlen( $this->fileEntry(
+ $title->getCanonicalURL(),
+ wfTimestamp( TS_ISO_8601, wfTimestamp() ),
+ $this->priority( $namespace )
+ ) ),
strlen( $this->closeFile() )
);
}
$titleText = $title->getPrefixedText();
$this->error( "Page $titleText does not exist.\n", true );
}
- $content = $rev->getContent( $this->hasOption( 'show-private' ) ? Revision::RAW : Revision::FOR_PUBLIC );
+ $content = $rev->getContent( $this->hasOption( 'show-private' )
+ ? Revision::RAW
+ : Revision::FOR_PUBLIC );
+
if ( $content === false ) {
$titleText = $title->getPrefixedText();
$this->error( "Couldn't extract the text from $titleText.\n", true );
function __construct() {
parent::__construct();
- $gz = in_array( 'compress.zlib', stream_get_wrappers() ) ? 'ok' : '(disabled; requires PHP zlib module)';
- $bz2 = in_array( 'compress.bzip2', stream_get_wrappers() ) ? 'ok' : '(disabled; requires PHP bzip2 module)';
+ $gz = in_array( 'compress.zlib', stream_get_wrappers() )
+ ? 'ok'
+ : '(disabled; requires PHP zlib module)';
+ $bz2 = in_array( 'compress.bzip2', stream_get_wrappers() )
+ ? 'ok'
+ : '(disabled; requires PHP bzip2 module)';
$this->mDescription = <<<TEXT
This script reads pages from an XML file as produced from Special:Export or
$this->addOption( 'dry-run', 'Parse dump without actually importing pages' );
$this->addOption( 'debug', 'Output extra verbose debug information' );
$this->addOption( 'uploads', 'Process file upload data if included (experimental)' );
- $this->addOption( 'no-updates', 'Disable link table updates. Is faster but leaves the wiki in an inconsistent state' );
+ $this->addOption(
+ 'no-updates',
+ 'Disable link table updates. Is faster but leaves the wiki in an inconsistent state'
+ );
$this->addOption( 'image-base-path', 'Import files from a specified path', false, true );
$this->addArg( 'file', 'Dump file to import [else use stdin]', false );
}
return false;
}
-# FIXME: Access the api in a saner way and performing just one query (preferably batching files too).
+# @todo FIXME: Access the api in a saner way and performing just one query
+# (preferably batching files too).
function getFileCommentFromSourceWiki( $wiki_host, $file ) {
- $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment';
+ $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:'
+ . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=comment';
$body = Http::get( $url );
if ( preg_match( '#<ii comment="([^"]*)" />#', $body, $matches ) == 0 ) {
return false;
}
function getFileUserFromSourceWiki( $wiki_host, $file ) {
- $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:' . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user';
+ $url = $wiki_host . '/api.php?action=query&format=xml&titles=File:'
+ . rawurlencode( $file ) . '&prop=imageinfo&&iiprop=user';
$body = Http::get( $url );
if ( preg_match( '#<ii user="([^"]*)" />#', $body, $matches ) == 0 ) {
return false;
* using the web-based interface.
*
* "Smart import" additions:
- * - aim: preserve the essential metadata (user, description) when importing medias from an existing wiki
+ * - aim: preserve the essential metadata (user, description) when importing media
+ * files from an existing wiki.
* - process:
* - interface with the source wiki, don't use bare files only (see --source-wiki-url).
* - fetch metadata from source wiki for each file to import.
}
# Get --from
-$from = @$options['from'];
+wfSuppressWarnings();
+$from = $options['from'];
+wfRestoreWarnings();
# Get sleep time.
-$sleep = @$options['sleep'];
+wfSuppressWarnings();
+$sleep = $options['sleep'];
+wfRestoreWarnings();
+
if ( $sleep ) {
$sleep = (int)$sleep;
}
# Get limit number
-$limit = @$options['limit'];
+wfSuppressWarnings();
+$limit = $options['limit'];
+wfRestoreWarnings();
+
if ( $limit ) {
$limit = (int)$limit;
}
} else {
if ( isset( $options['skip-dupes'] ) ) {
$repo = $image->getRepo();
- $sha1 = File::sha1Base36( $file ); # XXX: we end up calculating this again when actually uploading. that sucks.
+ # XXX: we end up calculating this again when actually uploading. that sucks.
+ $sha1 = File::sha1Base36( $file );
$dupes = $repo->findBySha1( $sha1 );
if ( $commentExt ) {
$f = findAuxFile( $file, $commentExt );
if ( !$f ) {
- echo " No comment file with extension {$commentExt} found for {$file}, using default comment. ";
+ echo " No comment file with extension {$commentExt} found "
+ . "for {$file}, using default comment. ";
} else {
$commentText = file_get_contents( $f );
if ( !$commentText ) {
if ( isset( $options['dry'] ) ) {
echo "done.\n";
- } elseif ( $image->recordUpload2( $archive->value, $summary, $commentText, $props, $timestamp ) ) {
+ } elseif ( $image->recordUpload2(
+ $archive->value,
+ $summary,
+ $commentText,
+ $props,
+ $timestamp
+ ) ) {
# We're done!
echo "done.\n";
<dir> : Path to the directory containing images to be imported
Options:
---extensions=<exts> Comma-separated list of allowable extensions, defaults to \$wgFileExtensions
---overwrite Overwrite existing images with the same name (default is to skip them)
---limit=<num> Limit the number of images to process. Ignored or skipped images are not counted.
---from=<name> Ignore all files until the one with the given name. Useful for resuming
- aborted imports. <name> should be the file's canonical database form.
---skip-dupes Skip images that were already uploaded under a different name (check SHA1)
---search-recursively Search recursively for files in subdirectories
+--extensions=<exts> Comma-separated list of allowable extensions, defaults
+ to \$wgFileExtensions.
+--overwrite Overwrite existing images with the same name (default
+ is to skip them).
+--limit=<num> Limit the number of images to process. Ignored or
+ skipped images are not counted.
+--from=<name> Ignore all files until the one with the given name.
+ Useful for resuming aborted imports. <name> should be
+ the file's canonical database form.
+--skip-dupes Skip images that were already uploaded under a different
+ name (check SHA1).
+--search-recursively Search recursively for files in subdirectories.
--sleep=<sec> Sleep between files. Useful mostly for debugging.
---user=<username> Set username of uploader, default 'Maintenance script'
+--user=<username> Set username of uploader, default 'Maintenance script'.
--check-userblock Check if the user got blocked during import.
--comment=<text> Set file description, default 'Importing file'.
--comment-file=<file> Set description to the content of <file>.
---comment-ext=<ext> Causes the description for each file to be loaded from a file with the same name
- but the extension <ext>. If a global description is also given, it is appended.
---license=<code> Use an optional license template
---dry Dry run, don't import anything
---protect=<protect> Specify the protect value (autoconfirmed,sysop)
---summary=<summary> Upload summary, description will be used if not provided
---timestamp=<timestamp> Override upload time/date, all MediaWiki timestamp formats are accepted
---unprotect Unprotects all uploaded images
---source-wiki-url If specified, take User and Comment data for each imported file from this URL.
- For example, --source-wiki-url="http://en.wikipedia.org/"
+--comment-ext=<ext> Causes the description for each file to be loaded from a
+ file with the same name, but the extension <ext>. If a
+ global description is also given, it is appended.
+--license=<code> Use an optional license template.
+--dry Dry run, don't import anything.
+--protect=<protect> Specify the protect value (autoconfirmed,sysop).
+--summary=<summary> Upload summary, description will be used if not
+ provided.
+--timestamp=<timestamp> Override upload time/date, all MediaWiki timestamp
+ formats are accepted.
+--unprotect Unprotects all uploaded images.
+--source-wiki-url If specified, take User and Comment data for each
+ imported file from this URL. For example,
+ --source-wiki-url="http://en.wikipedia.org/."
TEXT;
exit( 1 );
public function __construct() {
parent::__construct();
$this->mDescription = "Re-initialise the site statistics tables";
- $this->addOption( 'update', 'Update the existing statistics (preserves the ss_total_views field)' );
+ $this->addOption(
+ 'update',
+ 'Update the existing statistics (preserves the ss_total_views field)'
+ );
$this->addOption( 'noviews', "Don't update the page view counter" );
$this->addOption( 'active', 'Also update active users count' );
$this->addOption( 'use-master', 'Count using the master database' );
$this->addArg( 'admin', 'The username of the wiki administrator (WikiSysop)', true );
$this->addOption( 'pass', 'The password for the wiki administrator.', false, true );
- $this->addOption( 'passfile', 'An alternative way to provide pass option, as the contents of this file', false, true );
+ $this->addOption(
+ 'passfile',
+ 'An alternative way to provide pass option, as the contents of this file',
+ false,
+ true
+ );
/* $this->addOption( 'email', 'The email for the wiki administrator', false, true ); */
- $this->addOption( 'scriptpath', 'The relative path of the wiki in the web server (/wiki)', false, true );
+ $this->addOption(
+ 'scriptpath',
+ 'The relative path of the wiki in the web server (/wiki)',
+ false,
+ true
+ );
$this->addOption( 'lang', 'The language to use (en)', false, true );
/* $this->addOption( 'cont-lang', 'The content language (en)', false, true ); */
$this->addOption( 'installdbpass', 'The pasword for the DB user to install as.', false, true );
$this->addOption( 'dbuser', 'The user to use for normal operations (wikiuser)', false, true );
$this->addOption( 'dbpass', 'The pasword for the DB user for normal operations', false, true );
- $this->addOption( 'dbpassfile', 'An alternative way to provide dbpass option, as the contents of this file', false, true );
+ $this->addOption(
+ 'dbpassfile',
+ 'An alternative way to provide dbpass option, as the contents of this file',
+ false,
+ true
+ );
$this->addOption( 'confpath', "Path to write LocalSettings.php to, default $IP", false, true );
- /* $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true ); */
- /* $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true ); */
+ /*
+ $this->addOption( 'dbschema', 'The schema for the MediaWiki DB in pg (mediawiki)', false, true );
+ $this->addOption( 'namespace', 'The project namespace (same as the name)', false, true );
+ */
$this->addOption( 'env-checks', "Run environment checks only, don't change anything" );
}
function execute() {
global $IP;
- $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care"; // Will not be set if used with --env-checks
+
+ // Will not be set if used with --env-checks
+ $siteName = isset( $this->mArgs[0] ) ? $this->mArgs[0] : "Don't care";
$adminName = isset( $this->mArgs[1] ) ? $this->mArgs[1] : null;
$dbpassfile = $this->getOption( 'dbpassfile', false );
if ( $dbpassfile !== false ) {
if ( $this->getOption( 'dbpass', false ) !== false ) {
- $this->error( 'WARNING: You provide the options "dbpass" and "dbpassfile". The content of "dbpassfile" overwrites "dbpass".' );
+ $this->error( 'WARNING: You provide the options "dbpass" and "dbpassfile". '
+ . 'The content of "dbpassfile" overwrites "dbpass".' );
}
wfSuppressWarnings();
$dbpass = file_get_contents( $dbpassfile );
$passfile = $this->getOption( 'passfile', false );
if ( $passfile !== false ) {
if ( $this->getOption( 'pass', false ) !== false ) {
- $this->error( 'WARNING: You provide the options "pass" and "passfile". The content of "passfile" overwrites "pass".' );
+ $this->error( 'WARNING: You provide the options "pass" and "passfile". '
+ . 'The content of "passfile" overwrites "pass".' );
}
wfSuppressWarnings();
$pass = file_get_contents( $passfile );
if ( $this->hasOption( 'r' ) ) {
$lb = wfGetLB();
echo 'time ';
- for ( $i = 1; $i < $lb->getServerCount(); $i++ ) {
+
+ $serverCount = $lb->getServerCount();
+ for ( $i = 1; $i < $serverCount; $i++ ) {
$hostname = $lb->getServerName( $i );
printf( "%-12s ", $hostname );
}
function __construct() {
parent::__construct();
- $this->addOption( 'list-file', 'A file containing a list of extension setup files, one per line.', false, true );
+ $this->addOption(
+ 'list-file',
+ 'A file containing a list of extension setup files, one per line.',
+ false,
+ true
+ );
$this->addOption( 'extensions-dir', 'Path where extensions can be found.', false, true );
$this->addOption( 'output', 'Send output to this file (omit for stdout)', false, true );
$this->mDescription = 'Merge $wgExtensionMessagesFiles and $wgMessagesDirs from ' .
}
public function execute() {
- global $mmfl, $wgExtensionEntryPointListFiles;
+ // @codingStandardsIgnoreStart Ignore error: Global variable "$mmfl" is lacking 'wg' prefix
+ global $mmfl;
+ // @codingStandardsIgnoreEnd
+ global $wgExtensionEntryPointListFiles;
if ( !count( $wgExtensionEntryPointListFiles )
&& !$this->hasOption( 'list-file' )
# Setup complete, now start
$dbw = wfGetDB( DB_MASTER );
+ // @codingStandardsIgnoreStart Ignore avoid function calls in a FOR loop test part warning
for ( $linenum = 1; !feof( $file ); $linenum++ ) {
+ // @codingStandardsIgnoreEnd
$line = fgets( $file );
if ( $line === false ) {
break;
$this->lockTables( $dbw );
}
- $this->output( "Checking for orphan revision table entries... (this may take a while on a large wiki)\n" );
+ $this->output( "Checking for orphan revision table entries... "
+ . "(this may take a while on a large wiki)\n" );
$result = $dbw->query( "
SELECT *
FROM $revision LEFT OUTER JOIN $page ON rev_page=page_id
$orphans = $result->numRows();
if ( $orphans > 0 ) {
global $wgContLang;
+
$this->output( "$orphans orphan revisions...\n" );
- $this->output( sprintf( "%10s %10s %14s %20s %s\n", 'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment' ) );
+ $this->output( sprintf(
+ "%10s %10s %14s %20s %s\n",
+ 'rev_id', 'rev_page', 'rev_timestamp', 'rev_user_text', 'rev_comment'
+ ) );
+
foreach ( $result as $row ) {
$comment = ( $row->rev_comment == '' )
? ''
$this->lockTables( $dbw );
}
- $this->output( "\nChecking for childless page table entries... (this may take a while on a large wiki)\n" );
+ $this->output( "\nChecking for childless page table entries... "
+ . "(this may take a while on a large wiki)\n" );
$result = $dbw->query( "
SELECT *
FROM $page LEFT OUTER JOIN $revision ON page_latest=rev_id
$this->lockTables( $dbw, array( 'user', 'text' ) );
}
- $this->output( "\nChecking for pages whose page_latest links are incorrect... (this may take a while on a large wiki)\n" );
+ $this->output( "\nChecking for pages whose page_latest links are incorrect... "
+ . "(this may take a while on a large wiki)\n" );
$result = $dbw->query( "
SELECT *
FROM $page LEFT OUTER JOIN $revision ON page_latest=rev_id
public function __construct() {
parent::__construct();
$this->mDescription = "Parse a given wikitext";
- $this->addOption( 'title', 'Title name for the given wikitext (Default: \'CLIParser\')', false, true );
+ $this->addOption(
+ 'title',
+ 'Title name for the given wikitext (Default: \'CLIParser\')',
+ false,
+ true
+ );
$this->addArg( 'file', 'File containing wikitext (Default: stdin)', false );
}
if ( $input_file === $php_stdin ) {
$ctrl = wfIsWindows() ? 'CTRL+Z' : 'CTRL+D';
- $this->error( basename( __FILE__ ) . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
+ $this->error( basename( __FILE__ )
+ . ": warning: reading wikitext from STDIN. Press $ctrl to parse.\n" );
}
return file_get_contents( $input_file );
public function __construct() {
parent::__construct();
$this->mDescription = "Run an SQL file into the DB, replacing prefix and charset vars";
- $this->addArg( 'patch-name', 'Name of the patch file, either full path or in maintenance/archives' );
+ $this->addArg(
+ 'patch-name',
+ 'Name of the patch file, either full path or in maintenance/archives'
+ );
}
public function getDbType() {
will not run again without the --force option.
TEXT;
# '
- $this->addOption( 'begin', 'Only do categories whose names are alphabetically after the provided name', false, true );
- $this->addOption( 'max-slave-lag', 'If slave lag exceeds this many seconds, wait until it drops before continuing. Default: 10', false, true );
- $this->addOption( 'throttle', 'Wait this many milliseconds after each category. Default: 0', false, true );
+ $this->addOption(
+ 'begin',
+ 'Only do categories whose names are alphabetically after the provided name',
+ false,
+ true
+ );
+ $this->addOption(
+ 'max-slave-lag',
+ 'If slave lag exceeds this many seconds, wait until it drops before continuing. Default: 10',
+ false,
+ true
+ );
+ $this->addOption(
+ 'throttle',
+ 'Wait this many milliseconds after each category. Default: 0',
+ false,
+ true
+ );
$this->addOption( 'force', 'Run regardless of whether the database says it\'s been run already' );
}