jenkins-bot has submitted this change and it was merged.

Change subject: Optimized wfIsBadImage() redirect check
......................................................................


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
---
M includes/GlobalFunctions.php
1 file changed, 4 insertions(+), 5 deletions(-)

Approvals:
  Reedy: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php
index c524948..6fbc11d 100644
--- a/includes/GlobalFunctions.php
+++ b/includes/GlobalFunctions.php
@@ -4072,11 +4072,10 @@
  * @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;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7e2a1c6acf853629fcca3a8b3c2c810ebacd2acb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to