Siebrand has uploaded a new change for review.
https://gerrit.wikimedia.org/r/95944
Change subject: Update formatting
......................................................................
Update formatting
Change-Id: I9aa56cbe0989d6f302ee0f47c4a6154101f73e90
---
M includes/cache/BacklinkCache.php
M includes/cache/CacheDependency.php
M includes/cache/FileCacheBase.php
M includes/cache/GenderCache.php
M includes/cache/HTMLFileCache.php
M includes/cache/LinkBatch.php
M includes/cache/LinkCache.php
M includes/cache/LocalisationCache.php
M includes/cache/MessageCache.php
M includes/cache/ProcessCacheLRU.php
M includes/cache/ResourceFileCache.php
M includes/cache/UserCache.php
12 files changed, 106 insertions(+), 15 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/44/95944/1
diff --git a/includes/cache/BacklinkCache.php b/includes/cache/BacklinkCache.php
index 4775b96..dcd8191 100644
--- a/includes/cache/BacklinkCache.php
+++ b/includes/cache/BacklinkCache.php
@@ -108,6 +108,7 @@
if ( !self::$cache->has( $dbKey, 'obj', 3600 ) ) {
self::$cache->set( $dbKey, 'obj', new self( $title ) );
}
+
return self::$cache->get( $dbKey, 'obj' );
}
@@ -149,6 +150,7 @@
if ( !isset( $this->db ) ) {
$this->db = wfGetDB( DB_SLAVE );
}
+
return $this->db;
}
@@ -179,8 +181,8 @@
$fromField = $this->getPrefix( $table ) . '_from';
if ( !$startId && !$endId && is_infinite( $max )
- && isset( $this->fullResultCache[$table] ) )
- {
+ && isset( $this->fullResultCache[$table] )
+ ) {
wfDebug( __METHOD__ . ": got results from cache\n" );
$res = $this->fullResultCache[$table];
} else {
@@ -204,7 +206,7 @@
$res = $this->getDB()->select(
$table,
array( $this->getPrefix( $table ) .
'_from AS page_id' ),
- array_filter( $conds, function( $clause
) { // kind of janky
+ array_filter( $conds, function (
$clause ) { // kind of janky
return !preg_match(
'/(\b|=)page_id(\b|=)/', $clause );
} ),
__METHOD__,
@@ -230,6 +232,7 @@
}
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -337,6 +340,7 @@
// 1) try partition cache ...
if ( isset( $this->partitionCache[$table] ) ) {
$entry = reset( $this->partitionCache[$table] );
+
return min( $max, $entry['numRows'] );
}
@@ -385,6 +389,7 @@
// 1) try partition cache ...
if ( isset( $this->partitionCache[$table][$batchSize] ) ) {
wfDebug( __METHOD__ . ": got from partition cache\n" );
+
return
$this->partitionCache[$table][$batchSize]['batches'];
}
@@ -395,6 +400,7 @@
if ( isset( $this->fullResultCache[$table] ) ) {
$cacheEntry = $this->partitionResult(
$this->fullResultCache[$table], $batchSize );
wfDebug( __METHOD__ . ": got from full result cache\n"
);
+
return $cacheEntry['batches'];
}
@@ -410,6 +416,7 @@
if ( is_array( $memcValue ) ) {
$cacheEntry = $memcValue;
wfDebug( __METHOD__ . ": got from memcached $memcKey\n"
);
+
return $cacheEntry['batches'];
}
@@ -444,6 +451,7 @@
$wgMemc->set( $memcKey, $cacheEntry['numRows'],
self::CACHE_EXPIRY );
wfDebug( __METHOD__ . ": got from database\n" );
+
return $cacheEntry['batches'];
}
diff --git a/includes/cache/CacheDependency.php
b/includes/cache/CacheDependency.php
index 32bcdf7..15b58b8 100644
--- a/includes/cache/CacheDependency.php
+++ b/includes/cache/CacheDependency.php
@@ -110,8 +110,8 @@
* callback was defined.
*/
static function getValueFromCache( $cache, $key, $expiry = 0, $callback
= false,
- $callbackParams = array(), $deps = array() )
- {
+ $callbackParams = array(), $deps = array()
+ ) {
$obj = $cache->get( $key );
if ( is_object( $obj ) && $obj instanceof DependencyWrapper &&
!$obj->isExpired() ) {
@@ -141,7 +141,8 @@
/**
* Hook to perform any expensive pre-serialize loading of dependency
values.
*/
- function loadDependencyValues() { }
+ function loadDependencyValues() {
+ }
}
/**
@@ -172,6 +173,7 @@
*/
function __sleep() {
$this->loadDependencyValues();
+
return array( 'filename', 'timestamp' );
}
@@ -198,6 +200,7 @@
} else {
# Deleted
wfDebug( "Dependency triggered:
{$this->filename} deleted.\n" );
+
return true;
}
} else {
@@ -205,6 +208,7 @@
if ( $lastmod > $this->timestamp ) {
# Modified or created
wfDebug( "Dependency triggered:
{$this->filename} changed.\n" );
+
return true;
} else {
# Not modified
@@ -353,6 +357,7 @@
$this->linkBatch = new LinkBatch;
$this->linkBatch->setArray( $this->timestamps );
}
+
return $this->linkBatch;
}
@@ -407,6 +412,7 @@
if ( !isset( $GLOBALS[$this->name] ) ) {
return true;
}
+
return $GLOBALS[$this->name] != $this->value;
}
}
diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php
index d4bf5ee..d5195c5 100644
--- a/includes/cache/FileCacheBase.php
+++ b/includes/cache/FileCacheBase.php
@@ -51,6 +51,7 @@
*/
final protected function baseCacheDirectory() {
global $wgFileCacheDirectory;
+
return $wgFileCacheDirectory;
}
@@ -91,6 +92,7 @@
if ( $this->mCached === null ) {
$this->mCached = file_exists( $this->cachePath() );
}
+
return $this->mCached;
}
@@ -100,6 +102,7 @@
*/
public function cacheTimestamp() {
$timestamp = filemtime( $this->cachePath() );
+
return ( $timestamp !== false )
? wfTimestamp( TS_MW, $timestamp )
: false;
@@ -140,6 +143,7 @@
public function fetchText() {
if ( $this->useGzip() ) {
$fh = gzopen( $this->cachePath(), 'rb' );
+
return stream_get_contents( $fh );
} else {
return file_get_contents( $this->cachePath() );
@@ -165,10 +169,12 @@
if ( !file_put_contents( $this->cachePath(), $text, LOCK_EX ) )
{
wfDebug( __METHOD__ . "() failed saving " .
$this->cachePath() . "\n" );
$this->mCached = null;
+
return false;
}
$this->mCached = true;
+
return $text;
}
@@ -262,6 +268,7 @@
*/
public function getMissesRecent() {
global $wgMemc;
+
return self::MISS_FACTOR * $wgMemc->get( $this->cacheMissKey()
);
}
diff --git a/includes/cache/GenderCache.php b/includes/cache/GenderCache.php
index a933527..285675d 100644
--- a/includes/cache/GenderCache.php
+++ b/includes/cache/GenderCache.php
@@ -41,10 +41,12 @@
if ( $that === null ) {
$that = new self();
}
+
return $that;
}
- protected function __construct() {}
+ protected function __construct() {
+ }
/**
* Returns the default gender option in this wiki.
@@ -54,6 +56,7 @@
if ( $this->default === null ) {
$this->default = User::getDefaultOption( 'gender' );
}
+
return $this->default;
}
@@ -77,8 +80,8 @@
$this->misses++;
wfDebug( __METHOD__ . ": too many
misses, returning default onwards\n" );
}
- return $this->getDefault();
+ return $this->getDefault();
} else {
$this->misses++;
$this->doQuery( $username, $caller );
@@ -184,6 +187,7 @@
if ( $indexSlash !== false ) {
$username = substr( $username, 0, $indexSlash );
}
+
// normalize underscore/spaces
return strtr( $username, '_', ' ' );
}
diff --git a/includes/cache/HTMLFileCache.php b/includes/cache/HTMLFileCache.php
index ab37911..2629995 100644
--- a/includes/cache/HTMLFileCache.php
+++ b/includes/cache/HTMLFileCache.php
@@ -94,6 +94,7 @@
}
if ( $wgShowIPinHeader || $wgDebugToolbar ) {
wfDebug( "HTML file cache skipped. Either
\$wgShowIPinHeader and/or \$wgDebugToolbar on\n" );
+
return false;
}
@@ -109,6 +110,7 @@
} elseif ( $query === 'maxage' || $query === 'smaxage'
) {
continue;
}
+
return false;
}
$user = $context->getUser();
@@ -116,6 +118,7 @@
// and extensions for auto-detecting user language.
$ulang = $context->getLanguage()->getCode();
$clang = $wgContLang->getCode();
+
// Check that there are no other sources of variation
return !$user->getId() && !$user->getNewtalk() && $ulang ==
$clang;
}
@@ -185,6 +188,7 @@
// @todo Ugly wfClientAcceptsGzip() function - use
context!
if ( wfClientAcceptsGzip() ) {
header( 'Content-Encoding: gzip' );
+
return $compressed;
} else {
return $text;
diff --git a/includes/cache/LinkBatch.php b/includes/cache/LinkBatch.php
index 48b60aa..7bb41ac 100644
--- a/includes/cache/LinkBatch.php
+++ b/includes/cache/LinkBatch.php
@@ -117,6 +117,7 @@
*/
public function execute() {
$linkCache = LinkCache::singleton();
+
return $this->executeInto( $linkCache );
}
@@ -133,6 +134,7 @@
$this->doGenderQuery();
$ids = $this->addResultToCache( $cache, $res );
wfProfileOut( __METHOD__ );
+
return $ids;
}
@@ -170,6 +172,7 @@
$ids[$title->getPrefixedDBkey()] = 0;
}
}
+
return $ids;
}
@@ -197,6 +200,7 @@
}
$res = $dbr->select( $table, $fields, $conds, $caller );
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -217,6 +221,7 @@
$genderCache = GenderCache::singleton();
$genderCache->doLinkBatch( $this->data, $this->caller );
+
return true;
}
diff --git a/includes/cache/LinkCache.php b/includes/cache/LinkCache.php
index 6ac7e7a..31d79f4 100644
--- a/includes/cache/LinkCache.php
+++ b/includes/cache/LinkCache.php
@@ -51,6 +51,7 @@
return self::$instance;
}
self::$instance = new LinkCache;
+
return self::$instance;
}
@@ -218,16 +219,19 @@
$key = $nt->getPrefixedDBkey();
if ( $this->isBadLink( $key ) || $nt->isExternal() ) {
wfProfileOut( __METHOD__ );
+
return 0;
}
$id = $this->getGoodLinkID( $key );
if ( $id != 0 ) {
wfProfileOut( __METHOD__ );
+
return $id;
}
if ( $key === '' ) {
wfProfileOut( __METHOD__ );
+
return 0;
}
@@ -262,6 +266,7 @@
}
wfProfileOut( __METHOD__ );
+
return $id;
}
diff --git a/includes/cache/LocalisationCache.php
b/includes/cache/LocalisationCache.php
index c5a153a..0b52cc4 100644
--- a/includes/cache/LocalisationCache.php
+++ b/includes/cache/LocalisationCache.php
@@ -241,6 +241,7 @@
self::$magicWordKeys
) );
}
+
return isset( $this->mergeableKeys[$key] );
}
@@ -276,7 +277,8 @@
*/
public function getSubitem( $code, $key, $subkey ) {
if ( !isset( $this->loadedSubitems[$code][$key][$subkey] ) &&
- !isset( $this->loadedItems[$code][$key] ) ) {
+ !isset( $this->loadedItems[$code][$key] )
+ ) {
wfProfileIn( __METHOD__ . '-load' );
$this->loadSubitem( $code, $key, $subkey );
wfProfileOut( __METHOD__ . '-load' );
@@ -331,6 +333,7 @@
if ( isset( $this->shallowFallbacks[$code] ) ) {
$this->loadItem( $this->shallowFallbacks[$code], $key );
+
return;
}
@@ -358,6 +361,7 @@
protected function loadSubitem( $code, $key, $subkey ) {
if ( !in_array( $key, self::$splitKeys ) ) {
$this->loadItem( $code, $key );
+
return;
}
@@ -367,12 +371,14 @@
// Check to see if initLanguage() loaded it for us
if ( isset( $this->loadedItems[$code][$key] ) ||
- isset( $this->loadedSubitems[$code][$key][$subkey] ) )
{
+ isset( $this->loadedSubitems[$code][$key][$subkey] )
+ ) {
return;
}
if ( isset( $this->shallowFallbacks[$code] ) ) {
$this->loadSubitem( $this->shallowFallbacks[$code],
$key, $subkey );
+
return;
}
@@ -391,6 +397,7 @@
public function isExpired( $code ) {
if ( $this->forceRecache && !isset( $this->recachedLangs[$code]
) ) {
wfDebug( __METHOD__ . "($code): forced reload\n" );
+
return true;
}
@@ -400,6 +407,7 @@
// Different keys may expire separately, at least in
LCStore_Accel
if ( $deps === null || $keys === null || $preload === null ) {
wfDebug( __METHOD__ . "($code): cache missing, need to
make one\n" );
+
return true;
}
@@ -411,6 +419,7 @@
if ( !$dep instanceof CacheDependency ||
$dep->isExpired() ) {
wfDebug( __METHOD__ . "($code): cache for $code
expired due to " .
get_class( $dep ) . "\n" );
+
return true;
}
}
@@ -433,6 +442,7 @@
# If the code is of the wrong form for a Messages*.php file, do
a shallow fallback
if ( !Language::isValidBuiltInCode( $code ) ) {
$this->initShallowFallback( $code, 'en' );
+
return;
}
@@ -445,6 +455,7 @@
} else {
$this->initShallowFallback( $code, 'en' );
}
+
return;
}
@@ -458,6 +469,7 @@
'Please run
maintenance/rebuildLocalisationCache.php.' );
}
$this->initShallowFallback( $code, 'en' );
+
return;
} else {
throw new MWException( 'Invalid or missing
localisation cache.' );
@@ -511,6 +523,7 @@
throw new MWException( __METHOD__ . ": Invalid file
type: $_fileType" );
}
wfProfileOut( __METHOD__ );
+
return $data;
}
@@ -527,8 +540,10 @@
$compiledRules = CLDRPluralRuleEvaluator::compile(
$rules );
} catch ( CLDRPluralRuleError $e ) {
wfDebugLog( 'l10n', $e->getMessage() . "\n" );
+
return array();
}
+
return $compiledRules;
}
@@ -616,6 +631,7 @@
$fileName = Language::getMessagesFileName( $code );
if ( !file_exists( $fileName ) ) {
wfProfileOut( __METHOD__ );
+
return false;
}
@@ -633,6 +649,7 @@
$deps['plurals-mw'] = new FileDependency(
"$IP/languages/data/plurals-mediawiki.xml" );
wfProfileOut( __METHOD__ );
+
return $data;
}
@@ -747,7 +764,6 @@
foreach ( $data as $key => $value ) {
$this->mergeItem( $key, $coreData[$key], $value
);
}
-
}
# Fill in the fallback if it's not there already
@@ -1016,6 +1032,7 @@
public function get( $code, $key ) {
$k = wfMemcKey( 'l10n', $code, 'k', $key );
$r = $this->cache->get( $k );
+
return $r === false ? null : $r;
}
@@ -1096,6 +1113,7 @@
if ( $this->dbw->wasReadOnlyError() ) {
$this->readOnly = true;
$this->dbw->rollback( __METHOD__ );
+
return;
} else {
throw $e;
@@ -1187,6 +1205,7 @@
if ( $value === false ) {
return null;
}
+
return unserialize( $value );
}
}
@@ -1227,6 +1246,7 @@
if ( strval( $code ) === '' || strpos( $code, '/' ) !== false )
{
throw new MWException( __METHOD__ . ": Invalid language
\"$code\"" );
}
+
return "{$this->directory}/l10n_cache-$code.cdb";
}
}
@@ -1239,9 +1259,14 @@
return null;
}
- public function startWrite( $code ) {}
- public function finishWrite() {}
- public function set( $key, $value ) {}
+ public function startWrite( $code ) {
+ }
+
+ public function finishWrite() {
+ }
+
+ public function set( $key, $value ) {
+ }
}
/**
@@ -1301,6 +1326,7 @@
public function getItem( $code, $key ) {
unset( $this->mruLangs[$code] );
$this->mruLangs[$code] = true;
+
return parent::getItem( $code, $key );
}
@@ -1313,6 +1339,7 @@
public function getSubitem( $code, $key, $subkey ) {
unset( $this->mruLangs[$code] );
$this->mruLangs[$code] = true;
+
return parent::getSubitem( $code, $key, $subkey );
}
diff --git a/includes/cache/MessageCache.php b/includes/cache/MessageCache.php
index a92c87f..eff3ea7 100644
--- a/includes/cache/MessageCache.php
+++ b/includes/cache/MessageCache.php
@@ -110,6 +110,7 @@
$wgMsgCacheExpiry
);
}
+
return self::$instance;
}
@@ -147,6 +148,7 @@
$this->mParserOptions = new ParserOptions;
$this->mParserOptions->setEditSection( false );
}
+
return $this->mParserOptions;
}
@@ -179,9 +181,11 @@
$serialized .= fread( $file, 100000 );
}
fclose( $file );
+
return unserialize( $serialized );
} else {
fclose( $file );
+
return false; // Wrong hash
}
}
@@ -201,6 +205,7 @@
if ( !$file ) {
wfDebug( "Unable to open local cache file for
writing\n" );
+
return;
}
@@ -253,6 +258,7 @@
wfDebug( __METHOD__ . ": disabled\n" );
$shownDisabled = true;
}
+
return true;
}
@@ -415,6 +421,7 @@
$info = implode( ', ', $where );
wfDebug( __METHOD__ . ": Loading $code... $info\n" );
wfProfileOut( __METHOD__ );
+
return $success;
}
@@ -502,6 +509,7 @@
$cache['VERSION'] = MSG_CACHE_VERSION;
$cache['EXPIRY'] = wfTimestamp( TS_MW, time() + $this->mExpiry
);
wfProfileOut( __METHOD__ );
+
return $cache;
}
@@ -517,6 +525,7 @@
if ( $this->mDisable ) {
wfProfileOut( __METHOD__ );
+
return;
}
@@ -584,6 +593,7 @@
if ( wfTimestampNow() >= $cache['EXPIRY'] ) {
return true;
}
+
return false;
}
@@ -617,6 +627,7 @@
}
wfProfileOut( __METHOD__ );
+
return $success;
}
@@ -897,11 +908,13 @@
if ( $entry ) {
if ( substr( $entry, 0, 1 ) === ' ' ) {
$this->mCache[$code][$title] = $entry;
+
// The message exists, so make sure a string
// is returned.
return (string)substr( $entry, 1 );
} elseif ( $entry === '!NONEXISTENT' ) {
$this->mCache[$code][$title] = '!NONEXISTENT';
+
return false;
} else {
# Corrupt/obsolete entry, delete it
@@ -983,6 +996,7 @@
$this->mInParser = false;
$popts->setUserLang( $userlang );
}
+
return $message;
}
@@ -1003,6 +1017,7 @@
$this->mParser = clone $wgParser;
}
}
+
return $this->mParser;
}
@@ -1043,6 +1058,7 @@
$this->mInParser = false;
wfProfileOut( __METHOD__ );
+
return $res;
}
@@ -1085,6 +1101,7 @@
}
$message = implode( '/', $pieces );
+
return array( $message, $lang );
}
@@ -1109,6 +1126,7 @@
unset( $cache['EXPIRY'] );
// Remove any !NONEXISTENT keys
$cache = array_diff( $cache, array( '!NONEXISTENT' ) );
+
// Keys may appear with a capital first letter. lcfirst them.
return array_map( array( $wgContLang, 'lcfirst' ), array_keys(
$cache ) );
}
diff --git a/includes/cache/ProcessCacheLRU.php
b/includes/cache/ProcessCacheLRU.php
index 76c76f3..786d74a 100644
--- a/includes/cache/ProcessCacheLRU.php
+++ b/includes/cache/ProcessCacheLRU.php
@@ -79,6 +79,7 @@
if ( isset( $this->cache[$key][$prop] ) ) {
return ( $maxAge <= 0 || ( time() -
$this->cacheTimes[$key][$prop] ) <= $maxAge );
}
+
return false;
}
diff --git a/includes/cache/ResourceFileCache.php
b/includes/cache/ResourceFileCache.php
index 2ad7b85..3ace396 100644
--- a/includes/cache/ResourceFileCache.php
+++ b/includes/cache/ResourceFileCache.php
@@ -80,8 +80,10 @@
} elseif ( $query === 'debug' && $val === 'false' ) {
continue;
}
+
return false;
}
+
return true; // cacheable
}
@@ -104,6 +106,7 @@
$this->getMissesRecent() >=
self::MISS_THRESHOLD // many misses
);
}
+
return $this->mCacheWorthy;
}
}
diff --git a/includes/cache/UserCache.php b/includes/cache/UserCache.php
index 6085f58..2e4c1e9 100644
--- a/includes/cache/UserCache.php
+++ b/includes/cache/UserCache.php
@@ -36,10 +36,12 @@
if ( $instance === null ) {
$instance = new self();
}
+
return $instance;
}
- protected function __construct() {}
+ protected function __construct() {
+ }
/**
* Get a property of a user based on their user ID
@@ -53,6 +55,7 @@
wfDebug( __METHOD__ . ": querying DB for prop '$prop'
for user ID '$userId'.\n" );
$this->doQuery( array( $userId ) ); // cache miss
}
+
return isset( $this->cache[$userId][$prop] )
? $this->cache[$userId][$prop]
: false; // user does not exist?
--
To view, visit https://gerrit.wikimedia.org/r/95944
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9aa56cbe0989d6f302ee0f47c4a6154101f73e90
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits