Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/240966

Change subject: Made wfIsBadImage() use APC
......................................................................

Made wfIsBadImage() use APC

* Article 404s spend are large chunk of their time
  there and the method is also hit on page save

Change-Id: I26043f596195a8fe322bc154bf375a6c5d39c968
---
M includes/GlobalFunctions.php
1 file changed, 7 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/66/240966/1

diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index 404d2cf..624e8ff 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -4072,7 +4072,7 @@
  * @return bool
  */
 function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) {
-       static $badImageCache = null; // based on bad_image_list msg
+       $cache = ObjectCache::newAccelerator( 'hash' );
 
        # Handle redirects
        $redirectTitle = RepoGroup::singleton()->checkRedirect( 
Title::makeTitle( NS_FILE, $name ) );
@@ -4086,10 +4086,11 @@
                return $bad;
        }
 
+       $key = wfMemcKey( 'bad-image-list' );
        $cacheable = ( $blacklist === null );
-       if ( $cacheable && $badImageCache !== null ) {
-               $badImages = $badImageCache;
-       } else { // cache miss
+       $badImages = $cacheable ? $cache->get( $key ) : false;
+
+       if ( $badImages === false ) { // cache miss
                if ( $blacklist === null ) {
                        $blacklist = wfMessage( 'bad_image_list' 
)->inContentLanguage()->plain(); // site list
                }
@@ -4126,12 +4127,13 @@
                        }
                }
                if ( $cacheable ) {
-                       $badImageCache = $badImages;
+                       $cache->set( $key, $badImages, 15 );
                }
        }
 
        $contextKey = $contextTitle ? $contextTitle->getPrefixedDBkey() : false;
        $bad = isset( $badImages[$name] ) && !isset( 
$badImages[$name][$contextKey] );
+
        return $bad;
 }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/240966
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26043f596195a8fe322bc154bf375a6c5d39c968
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to