From: Aaron Schulz Date: Fri, 19 Dec 2008 14:51:42 +0000 (+0000) Subject: Store negative results in cache X-Git-Tag: 1.31.0-rc.0~43879 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=474a6bb80417baab499cf4f0531f423a04e3b63e;p=lhc%2Fweb%2Fwiklou.git Store negative results in cache --- diff --git a/includes/Interwiki.php b/includes/Interwiki.php index a98e46804f..abcef1f950 100644 --- a/includes/Interwiki.php +++ b/includes/Interwiki.php @@ -143,24 +143,27 @@ class Interwiki { $key = wfMemcKey( 'interwiki', $prefix ); $mc = $wgMemc->get( $key ); $iw = false; - if( $mc && is_array( $mc ) ){ // is_array is hack for old keys + if( $mc && is_array( $mc ) ) { // is_array is hack for old keys $iw = Interwiki::loadFromArray( $mc ); if( $iw ){ return $iw; } + } else if( $mc === 0 ) { + return false; // negative result cached } - $db = wfGetDB( DB_SLAVE ); - $row = $db->fetchRow( $db->select( 'interwiki', '*', array( 'iw_prefix' => $prefix ), __METHOD__ ) ); $iw = Interwiki::loadFromArray( $row ); - if ( $iw ) { + if( $iw ) { $mc = array( 'iw_url' => $iw->mURL, 'iw_local' => $iw->mLocal, 'iw_trans' => $iw->mTrans ); $wgMemc->add( $key, $mc ); return $iw; + } else { + # Pages like "Command & Conquer 3: Kane's Wrath" may keep checking + # the prefix. Cache the negative result to avoid extra db hits. + $wgMemc->add( $key, 0 ); } - return false; }