r112876 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112875‎ | r112876 | r112877 >
Date:10:03, 2 March 2012
Author:nikerabbit
Status:resolved (Comments)
Tags:
Comment:
Clear cache on writes
Modified paths:
  • /trunk/extensions/Translate/utils/TranslateMetadata.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/utils/TranslateMetadata.php
@@ -11,6 +11,8 @@
1212 */
1313
1414 class TranslateMetadata {
 15+ protected static $cache = null;
 16+
1517 /**
1618 * Get a metadata value for the given group and key.
1719 * @param $group The group name
@@ -18,13 +20,12 @@
1921 * @return String
2022 */
2123 public static function get( $group, $key ) {
22 - static $cache = null;
23 - if ( $cache === null ) {
 24+ if ( self::$cache === null ) {
2425 $dbr = wfGetDB( DB_SLAVE );
2526 $cache = $dbr->select( 'translate_metadata', '*', array(), __METHOD__ );
2627 }
2728
28 - foreach ( $cache as $row ) {
 29+ foreach ( self::$cache as $row ) {
2930 if ( $row->tmd_group === $group && $row->tmd_key === $key ) {
3031 return $row->tmd_value;
3132 }
@@ -48,6 +49,8 @@
4950 } else {
5051 $dbw->replace( 'translate_metadata', array( array( 'tmd_group', 'tmd_key' ) ), $data, __METHOD__ );
5152 }
 53+
 54+ $this->cache = null;
5255 }
5356
5457 }

Comments

#Comment by Siebrand (talk | contribs)   12:17, 2 March 2012

Throws bunches of the following:

PHP Warning: Invalid argument supplied for foreach() in /www/w/extensions/Translate/utils/TranslateMetadata.php on line 28

#Comment by Santhosh.thottingal (talk | contribs)   14:29, 2 March 2012

r112893 fixed this

Status & tagging log