Chad has uploaded a new change for review.
https://gerrit.wikimedia.org/r/97847
Change subject: Improved CdbException handling in Interwiki
......................................................................
Improved CdbException handling in Interwiki
Change-Id: I6461b64dc77b3ecc641db39da1e9be306100fda3
---
M includes/interwiki/Interwiki.php
1 file changed, 72 insertions(+), 62 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/47/97847/1
diff --git a/includes/interwiki/Interwiki.php b/includes/interwiki/Interwiki.php
index 4003fa8..0bb6382 100644
--- a/includes/interwiki/Interwiki.php
+++ b/includes/interwiki/Interwiki.php
@@ -123,28 +123,34 @@
static $db, $site;
wfDebug( __METHOD__ . "( $prefix )\n" );
- if ( !$db ) {
- $db = CdbReader::open( $wgInterwikiCache );
- }
- /* Resolve site name */
- if ( $wgInterwikiScopes >= 3 && !$site ) {
- $site = $db->get( '__sites:' . wfWikiID() );
- if ( $site == '' ) {
- $site = $wgInterwikiFallbackSite;
+ try {
+ if ( !$db ) {
+ $db = CdbReader::open( $wgInterwikiCache );
}
- }
+ /* Resolve site name */
+ if ( $wgInterwikiScopes >= 3 && !$site ) {
+ $site = $db->get( '__sites:' . wfWikiID() );
+ if ( $site == '' ) {
+ $site = $wgInterwikiFallbackSite;
+ }
+ }
- $value = $db->get( wfMemcKey( $prefix ) );
- // Site level
- if ( $value == '' && $wgInterwikiScopes >= 3 ) {
- $value = $db->get( "_{$site}:{$prefix}" );
- }
- // Global Level
- if ( $value == '' && $wgInterwikiScopes >= 2 ) {
- $value = $db->get( "__global:{$prefix}" );
- }
- if ( $value == 'undef' ) {
+ $value = $db->get( wfMemcKey( $prefix ) );
+ // Site level
+ if ( $value == '' && $wgInterwikiScopes >= 3 ) {
+ $value = $db->get( "_{$site}:{$prefix}" );
+ }
+ // Global Level
+ if ( $value == '' && $wgInterwikiScopes >= 2 ) {
+ $value = $db->get( "__global:{$prefix}" );
+ }
+ if ( $value == 'undef' ) {
+ $value = '';
+ }
+ } catch ( CdbException $e ) {
$value = '';
+ wfDebug( __METHOD__ . ": CdbException caught, error
message was "
+ . $e->getMessage() );
}
return $value;
@@ -232,51 +238,55 @@
static $db, $site;
wfDebug( __METHOD__ . "()\n" );
- if ( !$db ) {
- $db = CdbReader::open( $wgInterwikiCache );
- }
- /* Resolve site name */
- if ( $wgInterwikiScopes >= 3 && !$site ) {
- $site = $db->get( '__sites:' . wfWikiID() );
- if ( $site == '' ) {
- $site = $wgInterwikiFallbackSite;
- }
- }
-
- // List of interwiki sources
- $sources = array();
- // Global Level
- if ( $wgInterwikiScopes >= 2 ) {
- $sources[] = '__global';
- }
- // Site level
- if ( $wgInterwikiScopes >= 3 ) {
- $sources[] = '_' . $site;
- }
- $sources[] = wfWikiID();
-
$data = array();
-
- foreach ( $sources as $source ) {
- $list = $db->get( "__list:{$source}" );
- foreach ( explode( ' ', $list ) as $iw_prefix ) {
- $row = $db->get( "{$source}:{$iw_prefix}" );
- if ( !$row ) {
- continue;
- }
-
- list( $iw_local, $iw_url ) = explode( ' ', $row
);
-
- if ( $local !== null && $local != $iw_local ) {
- continue;
- }
-
- $data[$iw_prefix] = array(
- 'iw_prefix' => $iw_prefix,
- 'iw_url' => $iw_url,
- 'iw_local' => $iw_local,
- );
+ try {
+ if ( !$db ) {
+ $db = CdbReader::open( $wgInterwikiCache );
}
+ /* Resolve site name */
+ if ( $wgInterwikiScopes >= 3 && !$site ) {
+ $site = $db->get( '__sites:' . wfWikiID() );
+ if ( $site == '' ) {
+ $site = $wgInterwikiFallbackSite;
+ }
+ }
+
+ // List of interwiki sources
+ $sources = array();
+ // Global Level
+ if ( $wgInterwikiScopes >= 2 ) {
+ $sources[] = '__global';
+ }
+ // Site level
+ if ( $wgInterwikiScopes >= 3 ) {
+ $sources[] = '_' . $site;
+ }
+ $sources[] = wfWikiID();
+
+ foreach ( $sources as $source ) {
+ $list = $db->get( "__list:{$source}" );
+ foreach ( explode( ' ', $list ) as $iw_prefix )
{
+ $row = $db->get(
"{$source}:{$iw_prefix}" );
+ if ( !$row ) {
+ continue;
+ }
+
+ list( $iw_local, $iw_url ) = explode( '
', $row );
+
+ if ( $local !== null && $local !=
$iw_local ) {
+ continue;
+ }
+
+ $data[$iw_prefix] = array(
+ 'iw_prefix' => $iw_prefix,
+ 'iw_url' => $iw_url,
+ 'iw_local' => $iw_local,
+ );
+ }
+ }
+ } catch ( CdbException $e ) {
+ wfDebug( __METHOD__ . ": CdbException caught, error
message was "
+ . $e->getMessage() );
}
ksort( $data );
--
To view, visit https://gerrit.wikimedia.org/r/97847
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6461b64dc77b3ecc641db39da1e9be306100fda3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Chad <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits