* justification for breaking compatibility with installations
* compiled with ./configure --disable-hash.
*
- * @param $array The array to sort
- * @param $key The string key
- * @param $separator A separator used to delimit the array elements and the
+ * @param array $array Array to sort
+ * @param string $key
+ * @param string $separator A separator used to delimit the array elements and the
* key. This can be chosen to provide backwards compatibility with
* various consistent hash implementations that existed before this
* function was introduced.
* Given an array of non-normalised probabilities, this function will select
* an element and return the appropriate key
*
- * @param $weights array
- *
+ * @param array $weights
* @return bool|int|string
*/
public static function pickRandom( $weights ) {
* someone logs in who can be authenticated externally.
*/
class AuthPlugin {
-
/**
* @var string
*/
* you might need to munge it (for instance, for lowercase initial
* letters).
*
- * @param string $username username.
+ * @param string $username Username.
* @return bool
*/
public function userExists( $username ) {
* you might need to munge it (for instance, for lowercase initial
* letters).
*
- * @param string $username username.
- * @param string $password user password.
+ * @param string $username Username.
+ * @param string $password User password.
* @return bool
*/
public function authenticate( $username, $password ) {
/**
* Modify options in the login template.
*
- * @param $template UserLoginTemplate object.
+ * @param UserLoginTemplate $template
* @param string $type 'signup' or 'login'. Added in 1.16.
*/
public function modifyUITemplate( &$template, &$type ) {
/**
* Set the domain this plugin is supposed to use when authenticating.
*
- * @param string $domain authentication domain.
+ * @param string $domain Authentication domain.
*/
public function setDomain( $domain ) {
$this->domain = $domain;
/**
* Check to see if the specific domain is a valid domain.
*
- * @param string $domain authentication domain.
+ * @param string $domain Authentication domain.
* @return bool
*/
public function validDomain( $domain ) {
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
- * @param $user User object
+ * @param User $user
* @return bool
*/
public function updateUser( &$user ) {
*
* This is just a question, and shouldn't perform any actions.
*
- * @return Boolean
+ * @return bool
*/
public function autoCreate() {
return false;
* and use the same keys. 'Realname' 'Emailaddress' and 'Nickname'
* all reference this.
*
- * @param $prop string
+ * @param string $prop
*
- * @return Boolean
+ * @return bool
*/
public function allowPropChange( $prop = '' ) {
if ( $prop == 'realname' && is_callable( array( $this, 'allowRealNameChange' ) ) ) {
*
* Return true if successful.
*
- * @param $user User object.
- * @param string $password password.
+ * @param User $user
+ * @param string $password Password.
* @return bool
*/
public function setPassword( $user, $password ) {
* Update user groups in the external authentication database.
* Return true if successful.
*
- * @param $user User object.
- * @param $addgroups Groups to add.
- * @param $delgroups Groups to remove.
- * @return Boolean
+ * @param User $user
+ * @param array $addgroups Groups to add.
+ * @param array $delgroups Groups to remove.
+ * @return bool
*/
public function updateExternalDBGroups( $user, $addgroups, $delgroups = array() ) {
return true;
/**
* Check to see if external accounts can be created.
* Return true if external accounts can be created.
- * @return Boolean
+ * @return bool
*/
public function canCreateAccounts() {
return false;
* Add a user to the external authentication database.
* Return true if successful.
*
- * @param $user User: only the name should be assumed valid at this point
- * @param $password String
- * @param $email String
- * @param $realname String
- * @return Boolean
+ * @param User $user Only the name should be assumed valid at this point
+ * @param string $password
+ * @param string $email
+ * @param string $realname
+ * @return bool
*/
public function addUser( $user, $password, $email = '', $realname = '' ) {
return true;
*
* This is just a question, and shouldn't perform any actions.
*
- * @return Boolean
+ * @return bool
*/
public function strict() {
return false;
* Check if a user should authenticate locally if the global authentication fails.
* If either this or strict() returns true, local authentication is not used.
*
- * @param string $username username.
- * @return Boolean
+ * @param string $username Username.
+ * @return bool
*/
public function strictUserAuth( $username ) {
return false;
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
- * @param $user User object.
- * @param $autocreate Boolean: True if user is being autocreated on login
+ * @param User $user
+ * @param bool $autocreate True if user is being autocreated on login
*/
public function initUser( &$user, $autocreate = false ) {
# Override this to do something.
/**
* If you want to munge the case of an account name before the final
* check, now is your chance.
- * @param $username string
+ * @param string $username
* @return string
*/
public function getCanonicalName( $username ) {
/**
* Get an instance of a User object
*
- * @param $user User
+ * @param User $user
*
* @return AuthPluginUser
*/
* @ingroup Exception
*/
class MWException extends Exception {
-
/**
* Should the exception use $wgOut to output the error?
*
return null; // Just silently ignore
}
- if ( !array_key_exists( $name, $wgExceptionHooks ) || !is_array( $wgExceptionHooks[$name] ) ) {
+ if ( !array_key_exists( $name, $wgExceptionHooks ) ||
+ !is_array( $wgExceptionHooks[$name] )
+ ) {
return null;
}
$callargs = array_merge( array( $this ), $args );
foreach ( $hooks as $hook ) {
- if ( is_string( $hook ) || ( is_array( $hook ) && count( $hook ) >= 2 && is_string( $hook[0] ) ) ) { // 'function' or array( 'class', hook' )
+ if (
+ is_string( $hook ) ||
+ ( is_array( $hook ) && count( $hook ) >= 2 && is_string( $hook[0] ) )
+ ) {
+ // 'function' or array( 'class', hook' )
$result = call_user_func_array( $hook, $callargs );
} else {
$result = null;
if ( $wgShowExceptionDetails ) {
return '<p>' . nl2br( htmlspecialchars( $this->getMessage() ) ) .
- '</p><p>Backtrace:</p><p>' . nl2br( htmlspecialchars( MWExceptionHandler::formatRedactedTrace( $this ) ) ) .
+ '</p><p>Backtrace:</p><p>' .
+ nl2br( htmlspecialchars( MWExceptionHandler::formatRedactedTrace( $this ) ) ) .
"</p>\n";
} else {
return "<div class=\"errorbox\">" .
class UserNotLoggedIn extends ErrorPageError {
/**
- * @param $reasonMsg A message key containing the reason for the error.
+ * @param string $reasonMsg A message key containing the reason for the error.
* Optional, default: 'exception-nologin-text'
- * @param $titleMsg A message key to set the page title.
+ * @param string $titleMsg A message key to set the page title.
* Optional, default: 'exception-nologin'
- * @param $params Parameters to wfMessage().
+ * @param array $params Parameters to wfMessage().
* Optional, default: null
*/
public function __construct(
}
}
} else {
- $message = "Unexpected non-MediaWiki exception encountered, of type \"" . get_class( $e ) . "\"";
+ $message = "Unexpected non-MediaWiki exception encountered, of type \"" .
+ get_class( $e ) . "\"";
if ( $wgShowExceptionDetails ) {
- $message .= "\nexception '" . get_class( $e ) . "' in " . $e->getFile() . ":" . $e->getLine() . "\nStack trace:\n" . self::formatRedactedTrace( $e ) . "\n";
+ $message .= "\nexception '" . get_class( $e ) . "' in " .
+ $e->getFile() . ":" . $e->getLine() . "\nStack trace:\n" .
+ self::formatRedactedTrace( $e ) . "\n";
}
if ( $cmdLine ) {
* @param string $message Failure text
*/
public static function printError( $message ) {
- # NOTE: STDERR may not be available, especially if php-cgi is used from the command line (bug #15602).
- # Try to produce meaningful output anyway. Using echo may corrupt output to STDOUT though.
+ # NOTE: STDERR may not be available, especially if php-cgi is used from the
+ # command line (bug #15602). Try to produce meaningful output anyway. Using
+ # echo may corrupt output to STDOUT though.
if ( defined( 'STDERR' ) ) {
fwrite( STDERR, $message );
} else {
}
/**
- * Get the stack trace from the exception as a string, redacting certain function arguments in the process
+ * Get the stack trace from the exception as a string, redacting certain
+ * function arguments in the process.
* @param Exception $e The exception
* @return string The stack trace as a string
*/
}
}
}
- $finalExceptionText .= '(' . implode( ', ', $args ) . ")\n";
+ $finalExceptionText .= '(' . implode( ', ', $args ) . ")\n";
}
return $finalExceptionText . '#' . ( $i + 1 ) . ' {main}';
}
-
/**
* Get the ID for this error.
*
function mb_strpos( $haystack, $needle, $offset = 0, $encoding = '' ) {
return Fallback::mb_strpos( $haystack, $needle, $offset, $encoding );
}
-
}
if ( !function_exists( 'mb_strrpos' ) ) {
# The maximum random value is "only" 2^31-1, so get two random
# values to reduce the chance of dupes
$max = mt_getrandmax() + 1;
- $rand = number_format( ( mt_rand() * $max + mt_rand() )
- / $max / $max, 12, '.', '' );
+ $rand = number_format( ( mt_rand() * $max + mt_rand() ) / $max / $max, 12, '.', '' );
+
return $rand;
}
*/
function wfUrlencode( $s ) {
static $needle;
+
if ( is_null( $s ) ) {
$needle = null;
return '';
if ( is_null( $needle ) ) {
$needle = array( '%3B', '%40', '%24', '%21', '%2A', '%28', '%29', '%2C', '%2F' );
- if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) || ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false ) ) {
+ if ( !isset( $_SERVER['SERVER_SOFTWARE'] ) ||
+ ( strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7' ) === false )
+ ) {
$needle[] = '%3A';
}
}
}
/**
- * Expand a potentially local URL to a fully-qualified URL. Assumes $wgServer
+ * Expand a potentially local URL to a fully-qualified URL. Assumes $wgServer
* is correct.
*
* The meaning of the PROTO_* constants is as follows:
* PROTO_HTTP: Output a URL starting with http://
* PROTO_HTTPS: Output a URL starting with https://
* PROTO_RELATIVE: Output a URL starting with // (protocol-relative URL)
- * PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending on which protocol was used for the current incoming request
- * PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer. For protocol-relative URLs, use the protocol of $wgCanonicalServer
+ * PROTO_CURRENT: Output a URL starting with either http:// or https:// , depending
+ * on which protocol was used for the current incoming request
+ * PROTO_CANONICAL: For URLs without a domain, like /w/index.php , use $wgCanonicalServer.
+ * For protocol-relative URLs, use the protocol of $wgCanonicalServer
* PROTO_INTERNAL: Like PROTO_CANONICAL, but uses $wgInternalServer instead of $wgCanonicalServer
*
* @todo this won't work with current-path-relative URLs
*
* @param string $url either fully-qualified or a local path + query
* @param $defaultProto Mixed: one of the PROTO_* constants. Determines the
- * protocol to use if $url or $wgServer is
- * protocol-relative
+ * 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
+ * no valid URL can be constructed
*/
function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) {
global $wgServer, $wgCanonicalServer, $wgInternalServer;
if ( $serverHasProto ) {
$defaultProto = $bits['scheme'] . '://';
} else {
- // $wgCanonicalServer or $wgInternalServer doesn't have a protocol. This really isn't supposed to happen
- // Fall back to HTTP in this ridiculous case
+ // $wgCanonicalServer or $wgInternalServer doesn't have a protocol.
+ // This really isn't supposed to happen. Fall back to HTTP in this
+ // ridiculous case.
$defaultProto = PROTO_HTTP;
}
}
if ( substr( $url, 0, 2 ) == '//' ) {
$url = $defaultProtoWithoutSlashes . $url;
} elseif ( substr( $url, 0, 1 ) == '/' ) {
- // If $serverUrl is protocol-relative, prepend $defaultProtoWithoutSlashes, otherwise leave it alone
+ // If $serverUrl is protocol-relative, prepend $defaultProtoWithoutSlashes,
+ // otherwise leave it alone.
$url = ( $serverHasProto ? '' : $defaultProtoWithoutSlashes ) . $serverUrl . $url;
}
/**
* parse_url() work-alike, but non-broken. Differences:
*
- * 1) Does not raise warnings on bad URLs (just returns false)
- * 2) Handles protocols that don't use :// (e.g., mailto: and news: , as well as protocol-relative URLs) correctly
- * 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2))
+ * 1) Does not raise warnings on bad URLs (just returns false).
+ * 2) Handles protocols that don't use :// (e.g., mailto: and news:, as well as
+ * protocol-relative URLs) correctly.
+ * 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2)).
*
* @param string $url a URL to parse
* @return Array: bits of the URL in an associative array, per PHP docs
function wfParseUrl( $url ) {
global $wgUrlProtocols; // Allow all protocols defined in DefaultSettings/LocalSettings.php
- // Protocol-relative URLs are handled really badly by parse_url(). It's so bad that the easiest
- // way to handle them is to just prepend 'http:' and strip the protocol out later
+ // Protocol-relative URLs are handled really badly by parse_url(). It's so
+ // bad that the easiest way to handle them is to just prepend 'http:' and
+ // strip the protocol out later.
$wasRelative = substr( $url, 0, 2 ) == '//';
if ( $wasRelative ) {
$url = "http:$url";
* @return string
*/
function wfExpandIRI( $url ) {
- return preg_replace_callback( '/((?:%[89A-F][0-9A-F])+)/i', 'wfExpandIRI_callback', wfExpandUrl( $url ) );
+ return preg_replace_callback(
+ '/((?:%[89A-F][0-9A-F])+)/i',
+ 'wfExpandIRI_callback',
+ wfExpandUrl( $url )
+ );
}
/**
* Throws a warning that $function is deprecated
*
* @param $function String
- * @param string|bool $version Version of MediaWiki that the function was deprecated in (Added in 1.19).
+ * @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
* caller. 2 = function that called the function that called
}
} else {
if ( !$suppressCount ) {
- $originalLevel = error_reporting( E_ALL & ~( E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT ) );
+ $originalLevel = error_reporting( E_ALL & ~(
+ E_WARNING |
+ E_NOTICE |
+ E_USER_WARNING |
+ E_USER_NOTICE |
+ E_DEPRECATED |
+ E_USER_DEPRECATED |
+ E_STRICT
+ ) );
}
++$suppressCount;
}
if ( wfIsWindows() ) {
// Escaping for an MSVC-style command line parser and CMD.EXE
+ // @codingStandardsIgnoreStart For long URLs
// Refs:
// * http://web.archive.org/web/20020708081031/http://mailman.lyra.org/pipermail/scite-interest/2002-March/000436.html
// * http://technet.microsoft.com/en-us/library/cc723564.aspx
// * Bug #13518
// * CR r63214
// Double the backslashes before any double quotes. Escape the double quotes.
+ // @codingStandardsIgnoreEnd
$tokens = preg_split( '/(\\\\*")/', $arg, -1, PREG_SPLIT_DELIM_CAPTURE );
$arg = '';
$iteration = 0;
*
* @return string collected stdout as a string
*/
-function wfShellExec( $cmd, &$retval = null, $environ = array(), $limits = array(), $options = array() ) {
+function wfShellExec( $cmd, &$retval = null, $environ = array(),
+ $limits = array(), $options = array()
+) {
global $IP, $wgMaxShellMemory, $wgMaxShellFileSize, $wgMaxShellTime,
$wgMaxShellWallClockTime, $wgShellCgroup;
* @return String
*/
function wfBaseName( $path, $suffix = '' ) {
- $encSuffix = ( $suffix == '' )
- ? ''
- : ( '(?:' . preg_quote( $suffix, '#' ) . ')?' );
+ if ( $suffix == '' ) {
+ $encSuffix = '';
+ } else {
+ $encSuffix = '(?:' . preg_quote( $suffix, '#' ) . ')?';
+ }
+
$matches = array();
if ( preg_match( "#([^/\\\\]*?){$encSuffix}[/\\\\]*$#", $path, $matches ) ) {
return $matches[1];
* @param string $engine Either "gmp", "bcmath", or "php"
* @return string|bool The output number as a string, or false on error
*/
-function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1, $lowercase = true, $engine = 'auto' ) {
+function wfBaseConvert( $input, $sourceBase, $destBase, $pad = 1,
+ $lowercase = true, $engine = 'auto'
+) {
$input = (string)$input;
if (
$sourceBase < 2 ||
$sourceBase != (int)$sourceBase ||
$destBase != (int)$destBase ||
$pad != (int)$pad ||
- !preg_match( "/^[" . substr( '0123456789abcdefghijklmnopqrstuvwxyz', 0, $sourceBase ) . "]+$/i", $input )
+ !preg_match(
+ "/^[" . substr( '0123456789abcdefghijklmnopqrstuvwxyz', 0, $sourceBase ) . "]+$/i",
+ $input
+ )
) {
return false;
}
// We treat it as disabled if it doesn't have an entropy length of at least 32
$entropyEnabled = wfCheckEntropy();
- // If built-in entropy is not enabled or not sufficient override php's built in session id generation code
+ // If built-in entropy is not enabled or not sufficient override PHP's
+ // built in session id generation code
if ( !$entropyEnabled ) {
- wfDebug( __METHOD__ . ": PHP's built in entropy is disabled or not sufficient, overriding session id generation using our cryptrand source.\n" );
+ wfDebug( __METHOD__ . ": PHP's built in entropy is disabled or not sufficient, " .
+ "overriding session id generation using our cryptrand source.\n" );
session_id( MWCryptRand::generateHex( 32 ) );
}
}
* @return string
*/
function wfGetNull() {
- return wfIsWindows()
- ? 'NUL'
- : '/dev/null';
+ return wfIsWindows() ? 'NUL' : '/dev/null';
}
/**
* in maintenance scripts, to avoid causing too much lag. Of course, this is
* a no-op if there are no slaves.
*
- * @param $maxLag Integer (deprecated)
- * @param $wiki mixed Wiki identifier accepted by wfGetLB
- * @param $cluster string cluster name accepted by LBFactory
+ * @param int|bool $maxLag (deprecated)
+ * @param mixed $wiki Wiki identifier accepted by wfGetLB
+ * @param string|bool $cluster Cluster name accepted by LBFactory. Default: false.
*/
function wfWaitForSlaves( $maxLag = false, $wiki = false, $cluster = false ) {
- $lb = ( $cluster !== false )
- ? wfGetLBFactory()->getExternalLB( $cluster )
- : wfGetLB( $wiki );
+ if( $cluster !== false ) {
+ $lb = wfGetLBFactory()->getExternalLB( $cluster );
+ } else {
+ $lb = wfGetLB( $wiki );
+ }
+
// bug 27975 - Don't try to wait for slaves if there are none
// Prevents permission error when getting master position
if ( $lb->getServerCount() > 1 ) {
* characters before hashing.
* @return string
* @codeCoverageIgnore
- * @deprecated since 1.20; Please use MWCryptRand for security purposes and wfRandomString for pseudo-random strings
- * @warning This method is NOT secure. Additionally it has many callers that use it for pseudo-random purposes.
+ * @deprecated since 1.20; Please use MWCryptRand for security purposes and
+ * wfRandomString for pseudo-random strings
+ * @warning This method is NOT secure. Additionally it has many callers that
+ * use it for pseudo-random purposes.
*/
function wfGenerateToken( $salt = '' ) {
wfDeprecated( __METHOD__, '1.20' );
/**
* Constructor
- * @param $article Article object
+ * @param Page $page
*/
- public function __construct( Page $article ) {
- $this->mArticle = $article;
+ public function __construct( Page $page ) {
+ $this->mArticle = $page;
}
abstract public function show();
global $wgOut, $wgRequest;
$httpaccept = isset( $_SERVER['HTTP_ACCEPT'] ) ? $_SERVER['HTTP_ACCEPT'] : null;
- $rdftype = wfNegotiateType( wfAcceptToPrefs( $httpaccept ), wfAcceptToPrefs( self::RDF_TYPE_PREFS ) );
+ $rdftype = wfNegotiateType(
+ wfAcceptToPrefs( $httpaccept ),
+ wfAcceptToPrefs( self::RDF_TYPE_PREFS )
+ );
if ( !$rdftype ) {
throw new HttpError( 406, wfMessage( 'notacceptable' ) );
}
/**
- * @param $name string
- * @param $title Title
+ * @param string $name
+ * @param Title $title
*/
protected function page( $name, $title ) {
$this->url( $name, $title->getFullURL() );
* so that a lack of error-handling will be explicit.
*/
class Status {
- var $ok = true;
- var $value;
+ public $ok = true;
+ public $value;
/** Counters for batch operations */
- public $successCount = 0, $failCount = 0;
+ public $successCount = 0;
+ public $failCount = 0;
+
/** Array to indicate which items of the batch operations were successful */
public $success = array();
- /*semi-private*/ var $errors = array();
- /*semi-private*/ var $cleanCallback = false;
+ public $errors = array();
+ public $cleanCallback = false;
/**
* Factory function for fatal errors
/**
* Returns a list of status messages of the given type
* @param $type String
- *
* @return Array
*/
protected function getStatusArray( $type ) {
foreach ( $this->errors as $error ) {
if ( $error['type'] === $type ) {
if ( $error['message'] instanceof Message ) {
- $result[] = array_merge( array( $error['message']->getKey() ), $error['message']->getParams() );
+ $result[] = array_merge(
+ array( $error['message']->getKey() ),
+ $error['message']->getParams()
+ );
} elseif ( $error['params'] ) {
$result[] = array_merge( array( $error['message'] ), $error['params'] );
} else {
}
}
}
+
return $result;
}
/**
* @param $titleTo
* @param $table
- * @param $start bool
- * @param $end bool
*/
function __construct( Title $titleTo, $table ) {
$this->mTitle = $titleTo;
/**
* Perform pre-connection load ratio adjustment.
- * @param $loads array
- * @param string $group the selected query group
- * @param $wiki String
+ * @param array $loads
+ * @param string|bool $group the selected query group. Default: false
+ * @param string|bool $wiki Default: false
*/
function scaleLoads( &$loads, $group = false, $wiki = false );
function getLagTimes( $serverIndexes, $wiki );
}
+/**
+ * @todo FIXME: Should be LoadMonitorNull per naming conventions.
+ * PHP CodeSniffer Squiz.Classes.ValidClassName.NotCamelCaps
+ */
class LoadMonitor_Null implements LoadMonitor {
function __construct( $parent ) {
}
* Uses memcached to cache the replication lag for a short time
*
* @ingroup Database
+ * @todo FIXME: Should be LoadMonitorMySQL per naming conventions.
+ * PHP CodeSniffer Squiz.Classes.ValidClassName.NotCamelCaps
*/
class LoadMonitor_MySQL implements LoadMonitor {
-
/**
* @var LoadBalancer
*/
- var $parent;
+ public $parent;
/**
* @param LoadBalancer $parent
* @ingroup DifferenceEngine
*/
class DifferenceEngine extends ContextSource {
- /**#@+
- * @private
- */
- var $mOldid, $mNewid;
- var $mOldTags, $mNewTags;
+ public $mOldid;
+ public $mNewid;
+ private $mOldTags;
+ private $mNewTags;
+
/**
* @var Content
*/
- var $mOldContent, $mNewContent;
+ public $mOldContent;
+ public $mNewContent;
protected $mDiffLang;
/**
* @var Title
*/
- var $mOldPage, $mNewPage;
+ public $mOldPage;
+ public $mNewPage;
/**
* @var Revision
*/
- var $mOldRev, $mNewRev;
+ public $mOldRev;
+ public $mNewRev;
private $mRevisionsIdsLoaded = false; // Have the revisions IDs been loaded
- var $mRevisionsLoaded = false; // Have the revisions been loaded
- var $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1 or 2?
- var $mCacheHit = false; // Was the diff fetched from cache?
+ public $mRevisionsLoaded = false; // Have the revisions been loaded
+ public $mTextLoaded = 0; // How many text blobs have been loaded, 0, 1 or 2?
+ public $mCacheHit = false; // Was the diff fetched from cache?
/**
* Set this to true to add debug info to the HTML output.
* Warning: this may cause RSS readers to spuriously mark articles as "new"
* (bug 20601)
*/
- var $enableDebugComment = false;
+ public $enableDebugComment = false;
// If true, line X is not displayed when X is 1, for example to increase
// readability and conserve space with many small diffs.
* Constructor
* @param $context IContextSource context to use, anything else will be ignored
* @param $old Integer old ID we want to show and diff with.
- * @param $new String either 'prev' or 'next'.
+ * @param $new String|int either 'prev' or 'next'. Default: 0.
* @param $rcid Integer Deprecated, no longer used!
* @param $refreshCache boolean If set, refreshes the diff cache
* @param $unhide boolean If set, allow viewing deleted revs
*/
function __construct( $context = null, $old = 0, $new = 0, $rcid = 0,
- $refreshCache = false, $unhide = false )
- {
+ $refreshCache = false, $unhide = false
+ ) {
if ( $context instanceof IContextSource ) {
$this->setContext( $context );
}
$out->setPageTitle( $this->msg( 'difference-title', $this->mNewPage->getPrefixedText() ) );
$samePage = true;
} else {
- $out->setPageTitle( $this->msg( 'difference-title-multipage', $this->mOldPage->getPrefixedText(),
- $this->mNewPage->getPrefixedText() ) );
+ $out->setPageTitle( $this->msg( 'difference-title-multipage',
+ $this->mOldPage->getPrefixedText(), $this->mNewPage->getPrefixedText() ) );
$out->addSubtitle( $this->msg( 'difference-multipage' ) );
$samePage = false;
}
$rollback = '   ' . $rollbackLink;
}
}
- if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) && !$this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
+
+ if ( !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) &&
+ !$this->mNewRev->isDeleted( Revision::DELETED_TEXT )
+ ) {
$undoLink = Html::element( 'a', array(
'href' => $this->mNewPage->getLocalURL( array(
'action' => 'edit',
foreach ( $revisionTools as $tool ) {
$formattedRevisionTools[] = $this->msg( 'parentheses' )->rawParams( $tool )->escaped();
}
- $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) . ' ' . implode( ' ', $formattedRevisionTools );
+ $newRevisionHeader = $this->getRevisionHeader( $this->mNewRev, 'complete' ) .
+ ' ' . implode( ' ', $formattedRevisionTools );
$newChangeTags = ChangeTags::formatSummaryRow( $this->mNewTags, 'diff' );
$newHeader = '<div id="mw-diff-ntitle1"><strong>' . $newRevisionHeader . '</strong></div>' .
array( $msg ) );
} else {
# Give explanation and add a link to view the diff...
- $link = $this->getTitle()->getFullURL( $this->getRequest()->appendQueryValue( 'unhide', '1', true ) );
+ $query = $this->getRequest()->appendQueryValue( 'unhide', '1', true );
+ $link = $this->getTitle()->getFullURL( $query );
$msg = $suppressed ? 'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff';
- $out->wrapWikiMsg( "<div id='mw-$msg' class='mw-warning plainlinks'>\n$1\n</div>\n", array( $msg, $link ) );
+ $out->wrapWikiMsg(
+ "<div id='mw-$msg' class='mw-warning plainlinks'>\n$1\n</div>\n",
+ array( $msg, $link )
+ );
}
# Otherwise, output a regular diff...
} else {
$notice = '';
if ( $deleted ) {
$msg = $suppressed ? 'rev-suppressed-diff-view' : 'rev-deleted-diff-view';
- $notice = "<div id='mw-$msg' class='mw-warning plainlinks'>\n" . $this->msg( $msg )->parse() . "</div>\n";
+ $notice = "<div id='mw-$msg' class='mw-warning plainlinks'>\n" .
+ $this->msg( $msg )->parse() .
+ "</div>\n";
}
$this->showDiff( $oldHeader, $newHeader, $notice );
if ( !$diffOnly ) {
$out->addHTML( "<hr class='diff-hr' />
<h2 class='diff-currentversion-title'>{$revHeader}</h2>\n" );
# Page content may be handled by a hooked call instead...
+ # @codingStandardsIgnoreStart Ignoring long lines.
if ( wfRunHooks( 'ArticleContentOnDiff', array( $this, $out ) ) ) {
$this->loadNewText();
$out->setRevisionId( $this->mNewid );
}
}
}
+ # @codingStandardsIgnoreEnd
+
# Add redundant patrol link on bottom...
$out->addHTML( $this->markPatrolledLink() );
* Get the diff text, send it to the OutputPage object
* Returns false if the diff could not be generated, otherwise returns true
*
+ * @param string|bool $otitle Header for old text or false
+ * @param string|bool $ntitle Header for new text or false
+ * @param string $notice
* @return bool
*/
function showDiff( $otitle, $ntitle, $notice = '' ) {
$body = $this->getDiffBody();
if ( $body === false ) {
return false;
- } else {
- $multi = $this->getMultiNotice();
- // Display a message when the diff is empty
- if ( $body === '' ) {
- $notice .= '<div class="mw-diff-empty">' . $this->msg( 'diff-empty' )->parse() . "</div>\n";
- }
- return $this->addHeader( $body, $otitle, $ntitle, $multi, $notice );
}
+
+ $multi = $this->getMultiNotice();
+ // Display a message when the diff is empty
+ if ( $body === '' ) {
+ $notice .= '<div class="mw-diff-empty">' .
+ $this->msg( 'diff-empty' )->parse() .
+ "</div>\n";
+ }
+
+ return $this->addHeader( $body, $otitle, $ntitle, $multi, $notice );
}
/**
if ( !$this->loadRevisionData() ) {
wfProfileOut( __METHOD__ );
return false;
- } elseif ( $this->mOldRev && !$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
+ } elseif ( $this->mOldRev &&
+ !$this->mOldRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
+ ) {
wfProfileOut( __METHOD__ );
return false;
- } elseif ( $this->mNewRev && !$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
+ } elseif ( $this->mNewRev &&
+ !$this->mNewRev->userCan( Revision::DELETED_TEXT, $this->getUser() )
+ ) {
wfProfileOut( __METHOD__ );
return false;
}
$editQuery['oldid'] = $rev->getID();
}
- $msg = $this->msg( $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold' )->escaped();
+ $key = $title->quickUserCan( 'edit', $user ) ? 'editold' : 'viewsourceold';
+ $msg = $this->msg( $key )->escaped();
$header .= ' ' . $this->msg( 'parentheses' )->rawParams(
Linker::linkKnown( $title, $msg, array(), $editQuery ) )->plain();
if ( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
- $header = Html::rawElement( 'span', array( 'class' => 'history-deleted' ), $header );
+ $header = Html::rawElement(
+ 'span',
+ array( 'class' => 'history-deleted' ),
+ $header
+ );
}
} else {
$header = Html::rawElement( 'span', array( 'class' => 'history-deleted' ), $header );
}
if ( $multi != '' ) {
- $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' class='diff-multi'>{$multi}</td></tr>";
+ $header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;' " .
+ "class='diff-multi'>{$multi}</td></tr>";
}
if ( $notice != '' ) {
$header .= "<tr><td colspan='{$multiColspan}' style='text-align: center;'>{$notice}</td></tr>";
$this->loadRevisionIds();
// Load the new revision object
- $this->mNewRev = $this->mNewid
- ? Revision::newFromId( $this->mNewid )
- : Revision::newFromTitle( $this->getTitle(), false, Revision::READ_NORMAL );
+ if ( $this->mNewid ) {
+ $this->mNewRev = Revision::newFromId( $this->mNewid );
+ } else {
+ $this->mNewRev = Revision::newFromTitle(
+ $this->getTitle(),
+ false,
+ Revision::READ_NORMAL
+ );
+ }
if ( !$this->mNewRev instanceof Revision ) {
return false;
/**
* Factory function for fatal errors
*
- * @param $repo FileRepo
- *
+ * @param FileRepo $repo
* @return FileRepoStatus
*/
static function newFatal( $repo /*, parameters...*/ ) {
}
/**
- * @param $repo FileRepo
+ * @param FileRepo|bool $repo Default: false
* @param $value
* @return FileRepoStatus
*/
* @ingroup Pager
*/
class LogPager extends ReverseChronologicalPager {
- private $types = array(), $performer = '', $title = '', $pattern = '';
+ private $types = array();
+ private $performer = '';
+ private $title = '';
+ private $pattern = '';
private $typeCGI = '';
public $mLogEventsList;
* Constructor
*
* @param LogEventsList $list
- * @param string $types or Array: log types to show
+ * @param string|array $types Log types to show
* @param string $performer the user who made the log entries
* @param string|Title $title the page title the log entries are for
* @param string $pattern do a prefix search rather than an exact title match
* @param array $conds extra conditions for the query
- * @param int $year The year to start from
- * @param int $month The month to start from
+ * @param int|bool $year The year to start from. Default: false
+ * @param int|bool $month The month to start from. Default: false
* @param string $tagFilter tag
*/
public function __construct( $list, $types = array(), $performer = '', $title = '', $pattern = '',
} else {
/**
* @ignore
+ * @param string $string
* @return string
*/
function pretty( $string ) {
* @author Michael Dale
*/
class UploadFromChunks extends UploadFromFile {
- protected $mOffset, $mChunkIndex, $mFileKey, $mVirtualTempPath;
+ protected $mOffset;
+ protected $mChunkIndex;
+ protected $mFileKey;
+ protected $mVirtualTempPath;
/**
* Setup local pointers to stash, repo and user (similar to UploadFromStash)
*
- * @param $user User
- * @param $stash UploadStash
- * @param $repo FileRepo
+ * @param $user User|null Default: null
+ * @param $stash UploadStash|bool Default: false
+ * @param $repo FileRepo|bool Default: false
*/
public function __construct( $user = null, $stash = false, $repo = false ) {
// user object. sometimes this won't exist, as when running from cron.
* @return FileRepoStatus
*/
public function concatenateChunks() {
+ $chunkIndex = $this->getChunkIndex();
wfDebug( __METHOD__ . " concatenate {$this->mChunkIndex} chunks:" .
- $this->getOffset() . ' inx:' . $this->getChunkIndex() . "\n" );
+ $this->getOffset() . ' inx:' . $chunkIndex . "\n" );
// Concatenate all the chunks to mVirtualTempPath
- $fileList = Array();
+ $fileList = array();
// The first chunk is stored at the mVirtualTempPath path so we start on "chunk 1"
- for ( $i = 0; $i <= $this->getChunkIndex(); $i++ ) {
+ for ( $i = 0; $i <= $chunkIndex; $i++ ) {
$fileList[] = $this->getVirtualChunkLocation( $i );
}
$ext = FileBackend::extensionFromPath( $this->mVirtualTempPath );
// Get a 0-byte temp file to perform the concatenation at
$tmpFile = TempFSFile::factory( 'chunkedupload_', $ext );
- $tmpPath = $tmpFile
- ? $tmpFile->bind( $this )->getPath() // keep alive with $this
- : false; // fail in concatenate()
+ $tmpPath = false; // fail in concatenate()
+ if( $tmpFile ) {
+ // keep alive with $this
+ $tmpPath = $tmpFile->bind( $this )->getPath();
+ }
+
// Concatenate the chunks at the temp file
$tStart = microtime( true );
$status = $this->repo->concatenate( $fileList, $tmpPath, FileRepo::DELETE_SOURCE );
}
wfDebugLog( 'fileconcatenate', "Combined $i chunks in $tAmount seconds.\n" );
- $this->mTempPath = $tmpPath; // file system path
- $this->mFileSize = filesize( $this->mTempPath ); //Since this was set for the last chunk previously
+ // File system path
+ $this->mTempPath = $tmpPath;
+ // Since this was set for the last chunk previously
+ $this->mFileSize = filesize( $this->mTempPath );
$ret = $this->verifyUpload();
if ( $ret['status'] !== UploadBase::OK ) {
wfDebugLog( 'fileconcatenate', "Verification failed for chunked upload" );
$error = array( 'unknown', 'no error recorded' );
}
}
- throw new UploadChunkFileException( "error storing file in '$chunkPath': " . implode( '; ', $error ) );
+ throw new UploadChunkFileException( "Error storing file in '$chunkPath': " .
+ implode( '; ', $error ) );
}
return $storeStatus;
}
}
}
-class UploadChunkZeroLengthFileException extends MWException {};
-class UploadChunkFileException extends MWException {};
-class UploadChunkVerificationException extends MWException {};
+class UploadChunkZeroLengthFileException extends MWException {
+}
+
+class UploadChunkFileException extends MWException {
+}
+
+class UploadChunkVerificationException extends MWException {
+}
* @author Bryan Tong Minh
*/
class UploadFromStash extends UploadBase {
- protected $mFileKey, $mVirtualTempPath, $mFileProps, $mSourceType;
+ protected $mFileKey;
+ protected $mVirtualTempPath;
+ protected $mFileProps;
+ protected $mSourceType;
// an instance of UploadStash
private $stash;
private $repo;
/**
- * @param $user User
- * @param $stash UploadStash
- * @param $repo FileRepo
+ * @param User|bool $user Default: false
+ * @param UploadStash|bool $stash Default: false
+ * @param FileRepo|bool $repo Default: false
*/
public function __construct( $user = false, $stash = false, $repo = false ) {
// user object. sometimes this won't exist, as when running from cron.
}
/**
- * @param $key string
+ * @param string $key
* @return bool
*/
public static function isValidKey( $key ) {
}
/**
- * @param $request WebRequest
- *
- * @return Boolean
+ * @param WebRequest $request
+ * @return bool
*/
public static function isValidRequest( $request ) {
// this passes wpSessionKey to getText() as a default when wpFileKey isn't set.
}
/**
- * @param $key string
- * @param $name string
+ * @param string $key
+ * @param string $name
+ * @param bool $initTempFile
*/
public function initialize( $key, $name = 'upload_file', $initTempFile = true ) {
/**
}
/**
- * @param $request WebRequest
+ * @param WebRequest $request
*/
public function initializeFromRequest( &$request ) {
// sends wpSessionKey as a default when wpFileKey is missing
$fileKey = $request->getText( 'wpFileKey', $request->getText( 'wpSessionKey' ) );
// chooses one of wpDestFile, wpUploadFile, filename in that order.
- $desiredDestName = $request->getText( 'wpDestFile', $request->getText( 'wpUploadFile', $request->getText( 'filename' ) ) );
+ $desiredDestName = $request->getText(
+ 'wpDestFile',
+ $request->getText( 'wpUploadFile', $request->getText( 'filename' ) )
+ );
$this->initialize( $fileKey, $desiredDestName );
}
/**
* Stash the file.
*
- * @param $user User
+ * @param User $user
* @return UploadStashFile
*/
public function stashFile( User $user = null ) {
/**
* This should return the key instead of the UploadStashFile instance, for backward compatibility.
- * @return String
+ * @return string
*/
public function stashSession() {
return $this->stashFile()->getFileKey();
/**
* Remove a temporarily kept file stashed by saveTempUploadedFile().
- * @return bool success
+ * @return bool Success
*/
public function unsaveUploadedFile() {
return $this->stash->removeFile( $this->mFileKey );
/**
* Perform the upload, then remove the database record afterward.
- * @param $comment string
- * @param $pageText string
- * @param $watch bool
- * @param $user User
+ * @param string $comment
+ * @param string $pageText
+ * @param bool $watch
+ * @param User $user
* @return Status
*/
public function performUpload( $comment, $pageText, $watch, $user ) {