From: Aaron Schulz Date: Sun, 27 Sep 2015 05:14:41 +0000 (-0700) Subject: Optimized wfIsBadImage() redirect check X-Git-Tag: 1.31.0-rc.0~9756^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24ze_article%22%29%20.%20%22?a=commitdiff_plain;h=6e115a7cc1475832a240f0c263f4ff8ff8186792;p=lhc%2Fweb%2Fwiklou.git Optimized wfIsBadImage() redirect check * Callers end up hitting wfFindFile() anyway, so we may as well use/prime the process cache. By trying to call checkRedirect() manually, it actually just caused an extra memcached query. * 404 pages are often customized to show various icons file from sister sites, so this was taking up a significant portion of rendering time. Change-Id: I7e2a1c6acf853629fcca3a8b3c2c810ebacd2acb --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index c524948402..6fbc11d0d8 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -4072,11 +4072,10 @@ function wfUnpack( $format, $data, $length = false ) { * @return bool */ function wfIsBadImage( $name, $contextTitle = false, $blacklist = null ) { - # Handle redirects - $redirectTitle = RepoGroup::singleton()->checkRedirect( Title::makeTitle( NS_FILE, $name ) ); - if ( $redirectTitle ) { - $name = $redirectTitle->getDBkey(); - } + # Handle redirects; callers almost always hit wfFindFile() anyway, + # so just use that method because it has a fast process cache. + $file = wfFindFile( $name ); // get the final name + $name = $file ? $file->getTitle()->getDBkey() : $name; # Run the extension hook $bad = false;