* constituent messages or the resource itself is changed.
*/
class MessageBlobStore {
-
/**
* Get the message blobs for a set of modules
*
* @param string $name Module name
* @param ResourceLoaderModule $module
* @param string $lang Language code
- * @return string Regenerated message blob, or null if there was no blob for the given module/language pair
+ * @return string Regenerated message blob, or null if there was no blob for
+ * the given module/language pair.
*/
public static function updateModule( $name, ResourceLoaderModule $module, $lang ) {
$dbw = wfGetDB( DB_MASTER );
*/
private static function getFromDB( ResourceLoader $resourceLoader, $modules, $lang ) {
global $wgCacheEpoch;
+
$retval = array();
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'msg_resource',
// This shouldn't be possible
throw new MWException( __METHOD__ . ' passed an invalid module name' );
}
+
// Update the module's blobs if the set of messages changed or if the blob is
// older than $wgCacheEpoch
- if ( array_keys( FormatJson::decode( $row->mr_blob, true ) ) !== array_values( array_unique( $module->getMessages() ) ) ||
- wfTimestamp( TS_MW, $row->mr_timestamp ) <= $wgCacheEpoch ) {
+ $keys = array_keys( FormatJson::decode( $row->mr_blob, true ) );
+ $values = array_values( array_unique( $module->getMessages() ) );
+ if ( $keys !== $values
+ || wfTimestamp( TS_MW, $row->mr_timestamp ) <= $wgCacheEpoch
+ ) {
$retval[$row->mr_resource] = self::updateModule( $row->mr_resource, $module, $lang );
} else {
$retval[$row->mr_resource] = $row->mr_blob;
* @param int $length
*/
function wfDoContentLength( $length ) {
- if ( !headers_sent() && isset( $_SERVER['SERVER_PROTOCOL'] ) && $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0' ) {
+ if ( !headers_sent()
+ && isset( $_SERVER['SERVER_PROTOCOL'] )
+ && $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0'
+ ) {
header( "Content-Length: $length" );
}
}
$phpVersion = phpversion();
$protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0';
- $message = "MediaWiki $mwVersion requires at least PHP version $minimumVersionPHP, you are using PHP $phpVersion.";
+ $message = "MediaWiki $mwVersion requires at least "
+ . "PHP version $minimumVersionPHP, you are using PHP $phpVersion.";
+
if ( $type == 'cli' ) {
- $finalOutput = "You are using PHP version $phpVersion but MediaWiki $mwVersion needs PHP $minimumVersionPHP or higher. ABORTING.\n" .
- "Check if you have a newer php executable with a different name, such as php5.\n";
+ $finalOutput = "You are using PHP version $phpVersion "
+ . "but MediaWiki $mwVersion needs PHP $minimumVersionPHP or higher. ABORTING.\n"
+ . "Check if you have a newer php executable with a different name, such as php5.\n";
} elseif ( $type == 'index.php' ) {
$pathinfo = pathinfo( $_SERVER['SCRIPT_NAME'] );
$encLogo = htmlspecialchars(
* @return ResultWrapper
*/
public function reallyDoQuery( $offset, $limit, $descending ) {
- list( $tables, $fields, $conds, $fname, $options, $join_conds ) = $this->buildQueryInfo( $offset, $limit, $descending );
+ list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
+ $this->buildQueryInfo( $offset, $limit, $descending );
+
return $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
}
*
* @param ResultWrapper $result
*/
- protected function preprocessResults( $result ) {}
+ protected function preprocessResults( $result ) {
+ }
/**
* Get the formatted result list. Calls getStartBody(), formatRow() and
*
* @return void
*/
- protected function doBatchLookups() {}
+ protected function doBatchLookups() {
+ }
/**
* Hook into getBody(), allows text to be inserted at the start. This
* @ingroup Pager
*/
abstract class TablePager extends IndexPager {
- var $mSort;
- var $mCurrentRow;
+ protected $mSort;
+
+ protected $mCurrentRow;
public function __construct( IContextSource $context = null ) {
if ( $context ) {
}
$tableClass = $this->getTableClass();
- $ret = Html::openElement( 'table', array( 'style' => 'border:1px;', 'class' => "mw-datatable $tableClass" ) );
+ $ret = Html::openElement( 'table', array(
+ 'style' => 'border:1px;',
+ 'class' => "mw-datatable $tableClass" )
+ );
$ret .= Html::rawElement( 'thead', array(), Html::rawElement( 'tr', array(), "\n" . $s . "\n" ) );
$ret .= Html::openElement( 'tbody' ) . "\n";
* over to the tryUISubmit static method of this class.
*/
class Preferences {
- static $defaultPreferences = null;
- static $saveFilters = array(
- 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
- 'cols' => array( 'Preferences', 'filterIntval' ),
- 'rows' => array( 'Preferences', 'filterIntval' ),
- 'rclimit' => array( 'Preferences', 'filterIntval' ),
- 'wllimit' => array( 'Preferences', 'filterIntval' ),
- 'searchlimit' => array( 'Preferences', 'filterIntval' ),
+ /** @var array */
+ protected static $defaultPreferences = null;
+
+ /** @var array */
+ protected static $saveFilters = array(
+ 'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
+ 'cols' => array( 'Preferences', 'filterIntval' ),
+ 'rows' => array( 'Preferences', 'filterIntval' ),
+ 'rclimit' => array( 'Preferences', 'filterIntval' ),
+ 'wllimit' => array( 'Preferences', 'filterIntval' ),
+ 'searchlimit' => array( 'Preferences', 'filterIntval' ),
);
// Stuff that shouldn't be saved as a preference.
// Fortunately, the realname field is MUCH simpler
// (not really "private", but still shouldn't be edited without permission)
- if ( !in_array( 'realname', $wgHiddenPrefs ) && $user->isAllowed( 'editmyprivateinfo' ) && array_key_exists( 'realname', $formData ) ) {
+ if ( !in_array( 'realname', $wgHiddenPrefs )
+ && $user->isAllowed( 'editmyprivateinfo' )
+ && array_key_exists( 'realname', $formData )
+ ) {
$realName = $formData['realname'];
$user->setRealName( $realName );
}
* @param array $titles
* @return array
*/
- protected abstract function titles( array $titles );
+ abstract protected function titles( array $titles );
/**
* When implemented in a descendant class, receives an array of titles as strings and returns
*
* @return array
*/
- protected abstract function strings( array $strings );
+ abstract protected function strings( array $strings );
/**
* Do a prefix search of titles and return a list of matching page names.
class StringPrefixSearch extends PrefixSearch {
protected function titles( array $titles ) {
- return array_map( function( Title $t ) { return $t->getPrefixedText(); }, $titles );
+ return array_map( function ( Title $t ) {
+ return $t->getPrefixedText();
+ }, $titles );
}
protected function strings( array $strings ) {
$badtag = true;
} elseif ( $slash ) {
# Closing a tag... is it the one we just opened?
- $ot = @array_pop( $tagstack );
+ wfSuppressWarnings();
+ $ot = array_pop( $tagstack );
+ wfRestoreWarnings();
+
if ( $ot != $t ) {
if ( isset( $htmlsingleallowed[$ot] ) ) {
# Pop all elements with an optional close tag
}
}
} else {
- @array_push( $tagstack, $ot );
+ wfSuppressWarnings();
+ array_push( $tagstack, $ot );
+ wfRestoreWarnings();
+
# <li> can be nested in <ul> or <ol>, skip those cases:
if ( !isset( $htmllist[$ot] ) || !isset( $listtags[$t] ) ) {
$badtag = true;
} else {
# this might be possible using tidy itself
foreach ( $bits as $x ) {
- preg_match( '/^(\\/?)(\\w+)([^>]*?)(\\/{0,1}>)([^<]*)$/',
- $x, $regs );
- @list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs;
+ preg_match(
+ '/^(\\/?)(\\w+)([^>]*?)(\\/{0,1}>)([^<]*)$/',
+ $x,
+ $regs
+ );
+
+ wfSuppressWarnings();
+ list( /* $qbar */, $slash, $t, $params, $brace, $rest ) = $regs;
+ wfRestoreWarnings();
+
$badtag = false;
if ( isset( $htmlelements[$t = strtolower( $t )] ) ) {
if ( is_callable( $processCallback ) ) {
&& isset( $wgFooterIcons['poweredby']['mediawiki'] )
&& $wgFooterIcons['poweredby']['mediawiki']['src'] === null
) {
- $wgFooterIcons['poweredby']['mediawiki']['src'] = "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
+ $wgFooterIcons['poweredby']['mediawiki']['src'] =
+ "$wgStylePath/common/images/poweredby_mediawiki_88x31.png";
}
/**
// as determined by $wgRCMaxAge.
// Note that we allow 1 link higher than the max for things like 56 days but a 60 day link.
sort( $wgRCLinkDays );
+
+ // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
for ( $i = 0; $i < count( $wgRCLinkDays ); $i++ ) {
+ // @codingStandardsIgnoreEnd
if ( $wgRCLinkDays[$i] >= $wgRCMaxAge / ( 3600 * 24 ) ) {
$wgRCLinkDays = array_slice( $wgRCLinkDays, 0, $i + 1, false );
break;
}
if ( $wgInvalidateCacheOnLocalSettingsChange ) {
+ // @codingStandardsIgnoreStart Generic.PHP.NoSilencedErrors.Discouraged - No GlobalFunction here yet.
$wgCacheEpoch = max( $wgCacheEpoch, gmdate( 'YmdHis', @filemtime( "$IP/LocalSettings.php" ) ) );
+ // @codingStandardsIgnoreEnd
}
if ( $wgNewUserLog ) {
// Set server name
$serverParts = wfParseUrl( $wgCanonicalServer );
if ( $wgServerName !== false ) {
- wfWarn( '$wgServerName should be derived from $wgCanonicalServer, not customized. Overwriting $wgServerName.' );
+ wfWarn( '$wgServerName should be derived from $wgCanonicalServer, '
+ . 'not customized. Overwriting $wgServerName.' );
}
$wgServerName = $serverParts['host'];
unset( $serverParts );
if ( $wgSecureLogin && substr( $wgServer, 0, 2 ) !== '//' ) {
$wgSecureLogin = false;
- wfWarn( 'Secure login was enabled on a server that only supports HTTP or HTTPS. Disabling secure login.' );
+ wfWarn( 'Secure login was enabled on a server that only supports '
+ . 'HTTP or HTTPS. Disabling secure login.' );
}
// Now that GlobalFunctions is loaded, set defaults that depend
* extract( $globals );
* @endcode
*
- * TODO: give examples for,
+ * @todo Give examples for,
* suffixes:
* $conf->suffixes = array( 'wiki' );
* localVHosts
* @param array $wikiTags The tags assigned to the wiki.
* @return mixed The value of the setting requested.
*/
- public function get( $settingName, $wiki, $suffix = null, $params = array(), $wikiTags = array() ) {
+ public function get( $settingName, $wiki, $suffix = null, $params = array(),
+ $wikiTags = array()
+ ) {
$params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags );
return $this->getSetting( $settingName, $wiki, $params );
}
$retval = $thisSetting[$suffix];
}
break;
- } elseif ( array_key_exists( "+$suffix", $thisSetting ) && is_array( $thisSetting["+$suffix"] ) ) {
+ } elseif ( array_key_exists( "+$suffix", $thisSetting )
+ && is_array( $thisSetting["+$suffix"] )
+ ) {
if ( !isset( $retval ) ) {
$retval = array();
}
* @param array $params List of parameters. $.'key' is replaced by $value in all returned data.
* @param array $wikiTags The tags assigned to the wiki.
*/
- public function extractVar( $setting, $wiki, $suffix, &$var, $params = array(), $wikiTags = array() ) {
+ public function extractVar( $setting, $wiki, $suffix, &$var,
+ $params = array(), $wikiTags = array()
+ ) {
$value = $this->get( $setting, $wiki, $suffix, $params, $wikiTags );
if ( !is_null( $value ) ) {
$var = $value;
* @param array $params List of parameters. $.'key' is replaced by $value in all returned data.
* @param array $wikiTags The tags assigned to the wiki.
*/
- public function extractGlobal( $setting, $wiki, $suffix = null, $params = array(), $wikiTags = array() ) {
+ public function extractGlobal( $setting, $wiki, $suffix = null,
+ $params = array(), $wikiTags = array()
+ ) {
$params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags );
$this->extractGlobalSetting( $setting, $wiki, $params );
}
* @param array $params List of parameters. $.'key' is replaced by $value in all returned data.
* @param array $wikiTags The tags assigned to the wiki.
*/
- public function extractAllGlobals( $wiki, $suffix = null, $params = array(), $wikiTags = array() ) {
+ public function extractAllGlobals( $wiki, $suffix = null, $params = array(),
+ $wikiTags = array()
+ ) {
$params = $this->mergeParams( $wiki, $suffix, $params, $wikiTags );
foreach ( $this->settings as $varName => $setting ) {
$this->extractGlobalSetting( $varName, $wiki, $params );
*/
static function arrayMerge( $array1/* ... */ ) {
$out = $array1;
- for ( $i = 1; $i < func_num_args(); $i++ ) {
+ $argsCount = func_num_args();
+ for ( $i = 1; $i < $argsCount; $i++ ) {
foreach ( func_get_arg( $i ) as $key => $value ) {
if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) {
$out[$key] = self::arrayMerge( $out[$key], $value );
} elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) {
- // Values that evaluate to true given precedence, for the primary purpose of merging permissions arrays.
+ // Values that evaluate to true given precedence, for the
+ // primary purpose of merging permissions arrays.
$out[$key] = $value;
} elseif ( is_numeric( $key ) ) {
$out[] = $value;
function printSource() {
$oldid = $this->getRevisionId();
if ( $oldid ) {
- $url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid ) ) );
+ $canonicalUrl = $this->getTitle()->getCanonicalURL( 'oldid=' . $oldid );
+ $url = htmlspecialchars( wfExpandIRI( $canonicalUrl ) );
} else {
// oldid not available for non existing pages
$url = htmlspecialchars( wfExpandIRI( $this->getTitle()->getCanonicalURL() ) );
}
- return $this->msg( 'retrievedfrom', '<a dir="ltr" href="' . $url . '">' . $url . '</a>' )->text();
+
+ return $this->msg( 'retrievedfrom', '<a dir="ltr" href="' . $url
+ . '">' . $url . '</a>' )->text();
}
/**
global $wgRightsPage, $wgRightsUrl, $wgRightsText, $wgContLang;
if ( $type == 'detect' ) {
- if ( !$this->isRevisionCurrent() && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled() ) {
+ if ( !$this->isRevisionCurrent()
+ && !$this->msg( 'history_copyright' )->inContentLanguage()->isDisabled()
+ ) {
$type = 'history';
} else {
$type = 'normal';
// Allow for site and per-namespace customization of copyright notice.
$forContent = true;
- wfRunHooks( 'SkinCopyrightFooter', array( $this->getTitle(), $type, &$msg, &$link, &$forContent ) );
+ wfRunHooks(
+ 'SkinCopyrightFooter',
+ array( $this->getTitle(), $type, &$msg, &$link, &$forContent )
+ );
$msgObj = $this->msg( $msg )->rawParams( $link );
if ( $forContent ) {
$msg = $msgObj->inContentLanguage()->text();
if ( $this->getLanguage()->getCode() !== $wgContLang->getCode() ) {
- $msg = Html::rawElement( 'span', array( 'lang' => $wgContLang->getHtmlCode(), 'dir' => $wgContLang->getDir() ), $msg );
+ $msg = Html::rawElement( 'span', array(
+ 'lang' => $wgContLang->getHtmlCode(),
+ 'dir' => $wgContLang->getDir()
+ ), $msg );
}
+
return $msg;
} else {
return $msgObj->text();
global $wgStylePath;
$url = htmlspecialchars( "$wgStylePath/common/images/poweredby_mediawiki_88x31.png" );
- $text = '<a href="//www.mediawiki.org/"><img src="' . $url . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
+ $text = '<a href="//www.mediawiki.org/"><img src="' . $url
+ . '" height="31" width="88" alt="Powered by MediaWiki" /></a>';
wfRunHooks( 'SkinGetPoweredBy', array( &$text, $this ) );
return $text;
}
/**
* Renders a $wgFooterIcons icon according to the method's arguments
- * @param array $icon The icon to build the html for, see $wgFooterIcons for the format of this array
- * @param bool|string $withImage Whether to use the icon's image or output a text-only footericon
+ * @param array $icon The icon to build the html for, see $wgFooterIcons
+ * for the format of this array.
+ * @param bool|string $withImage Whether to use the icon's image or output
+ * a text-only footericon.
* @return string HTML
*/
function makeFooterIcon( $icon, $withImage = 'withImage' ) {
$url = isset( $icon["url"] ) ? $icon["url"] : null;
unset( $icon["url"] );
if ( isset( $icon["src"] ) && $withImage === 'withImage' ) {
- $html = Html::element( 'img', $icon ); // do this the lazy way, just pass icon data as an attribute array
+ // do this the lazy way, just pass icon data as an attribute array
+ $html = Html::element( 'img', $icon );
} else {
$html = htmlspecialchars( $icon["alt"] );
}
} else {
$targetUser = User::newFromId( $id );
}
- return $this->getUser()->canSendEmail() && # the sending user must have a confirmed email address
- $targetUser->canReceiveEmail(); # the target user must have a confirmed email address and allow emails from users
+
+ # The sending user must have a confirmed email address and the target
+ # user must have a confirmed email address and allow emails from users.
+ return $this->getUser()->canSendEmail() &&
+ $targetUser->canReceiveEmail();
}
/**