Ori.livneh has uploaded a new change for review.

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

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
(cherry picked from commit a607f11f9446ae06e067334877c6a47d9bce1bcb)
---
M includes/GlobalFunctions.php
1 file changed, 7 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/52/241252/1

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

-- 
To view, visit https://gerrit.wikimedia.org/r/241252
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: wmf/1.26wmf24
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Aaron Schulz <[email protected]>

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

Reply via email to