Ori.livneh has uploaded a new change for review.
https://gerrit.wikimedia.org/r/250301
Change subject: Allow $wgInterwikiCache to be an associative array
......................................................................
Allow $wgInterwikiCache to be an associative array
For the same reasons wikiversions.cdb was converted to a PHP file -- viz., that
static arrays in PHP files get cached in HHVM's bytecode cache and are
therefore faster to use with HHVM than CDB files.
Change-Id: I5a979f047031ef211622f399df9b3b388797f53a
---
M includes/DefaultSettings.php
M includes/interwiki/Interwiki.php
2 files changed, 11 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/01/250301/1
diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index d20b931..ae95f40 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -3871,10 +3871,12 @@
*/
/**
- *$wgInterwikiCache specifies path to constant database file.
+ * Interwiki cache, either as an associative array or a path to a constant
+ * database (.cdb) file.
*
- * This cdb database is generated by dumpInterwiki from maintenance and has
- * such key formats:
+ * This data structure database is generated by the `dumpInterwiki` maintenance
+ * script and has key formats such as the following:
+ *
* - dbname:key - a simple key (e.g. enwiki:meta)
* - _sitename:key - site-scope key (e.g. wiktionary:meta)
* - __global:key - global-scope key (e.g. __global:meta)
diff --git a/includes/interwiki/Interwiki.php b/includes/interwiki/Interwiki.php
index bd8291f..9ba2917 100644
--- a/includes/interwiki/Interwiki.php
+++ b/includes/interwiki/Interwiki.php
@@ -137,7 +137,7 @@
$value = self::getInterwikiCacheEntry( $prefix );
$s = new Interwiki( $prefix );
- if ( $value != '' ) {
+ if ( $value ) {
// Split values
list( $local, $url ) = explode( ' ', $value, 2 );
$s->mURL = $url;
@@ -165,7 +165,9 @@
$value = false;
try {
if ( !$db ) {
- $db = CdbReader::open( $wgInterwikiCache );
+ $db = is_array( $wgInterwikiCache )
+ ? MapCache( $wgInterwikiCache )
+ : CdbReader::open( $wgInterwikiCache );
}
/* Resolve site name */
if ( $wgInterwikiScopes >= 3 && !$site ) {
@@ -177,15 +179,12 @@
$value = $db->get( wfMemcKey( $prefix ) );
// Site level
- if ( $value == '' && $wgInterwikiScopes >= 3 ) {
+ if ( !$value && $wgInterwikiScopes >= 3 ) {
$value = $db->get( "_{$site}:{$prefix}" );
}
// Global Level
- if ( $value == '' && $wgInterwikiScopes >= 2 ) {
+ if ( !$value && $wgInterwikiScopes >= 2 ) {
$value = $db->get( "__global:{$prefix}" );
- }
- if ( $value == 'undef' ) {
- $value = '';
}
} catch ( CdbException $e ) {
wfDebug( __METHOD__ . ": CdbException caught, error
message was "
--
To view, visit https://gerrit.wikimedia.org/r/250301
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a979f047031ef211622f399df9b3b388797f53a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits