r59762 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59761‎ | r59762 | r59763 >
Date:21:59, 5 December 2009
Author:btongminh
Status:ok
Tags:
Comment:
Per comments on r56201:
* Use Title::makeTitleSafe instead of newFromText
* Limit cache size to 100 items
Modified paths:
  • /trunk/extensions/GlobalUsage/SpecialGlobalUsage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalUsage/SpecialGlobalUsage.php
@@ -17,7 +17,7 @@
1818 global $wgOut, $wgRequest;
1919
2020 $target = $par ? $par : $wgRequest->getVal( 'target' );
21 - $this->target = Title::newFromText( $target, NS_FILE );
 21+ $this->target = Title::makeTitleSafe( NS_FILE, $target );
2222
2323 $this->filterLocal = $wgRequest->getCheck( 'filterlocal' );
2424
@@ -127,7 +127,8 @@
128128 str_replace( '_', ' ', $page ) );
129129 }
130130
131 -
 131+
 132+ private static $queryCache = array();
132133 /**
133134 * Get an executed query for use on image pages
134135 *
@@ -135,18 +136,20 @@
136137 * @return GlobalUsageQuery Query object, already executed
137138 */
138139 private static function getImagePageQuery( $title ) {
139 - static $queryCache = array();
140 -
141140 $name = $title->getDBkey();
142 - if ( !isset( $queryCache[$name] ) ) {
 141+ if ( !isset( self::$queryCache[$name] ) ) {
143142 $query = new GlobalUsageQuery( $title );
144 - $query->filterLocal();
 143+ //$query->filterLocal();
145144 $query->execute();
146145
147 - $queryCache[$name] = $query;
 146+ self::$queryCache[$name] = $query;
 147+
 148+ // Limit cache size to 100
 149+ if ( count( self::$queryCache ) > 100 )
 150+ array_shift( self::$queryCache );
148151 }
149152
150 - return $queryCache[$name];
 153+ return self::$queryCache[$name];
151154 }
152155
153156 public static function onImagePageAfterImageLinks( $imagePage, &$html ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r60485Remove debugging comment accidentily left in in r59762btongminh22:11, 29 December 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56201Rewrote this globalusage extension. Still needs a population script and a lot...btongminh18:28, 11 September 2009

Status & tagging log