Fixed the caching of redirects in Squid
authorTim Starling <tstarling@wikimedia.org>
Wed, 17 Oct 2012 00:00:07 +0000 (11:00 +1100)
committerTim Starling <tstarling@wikimedia.org>
Wed, 17 Oct 2012 00:00:07 +0000 (11:00 +1100)
Was accidentally broken in Ie38ae198, where the request URL was compared
against the final target title, not the title of the redirect. Also
tested squid purges of redirects, since that code presumably hasn't been
tested for a while, and committed my very advanced testing framework.

Change-Id: Ib2ffe8e109bcc4859e22df5470bddfdb09e67afa

includes/Wiki.php
includes/cache/SquidUpdate.php

index ed02a3d..7a6b37d 100644 (file)
@@ -178,7 +178,7 @@ class MediaWiki {
                wfProfileIn( __METHOD__ );
 
                $request = $this->context->getRequest();
-               $title = $this->context->getTitle();
+               $requestTitle = $title = $this->context->getTitle();
                $output = $this->context->getOutput();
                $user = $this->context->getUser();
 
@@ -302,7 +302,7 @@ class MediaWiki {
                                global $wgArticle;
                                $wgArticle = new DeprecatedGlobal( 'wgArticle', $article, '1.18' );
 
-                               $this->performAction( $article );
+                               $this->performAction( $article, $requestTitle );
                        } elseif ( is_string( $article ) ) {
                                $output->redirect( $article );
                        } else {
@@ -396,8 +396,9 @@ class MediaWiki {
         * Perform one of the "standard" actions
         *
         * @param $page Page
+        * @param $requestTitle The original title, before any redirects were applied
         */
-       private function performAction( Page $page ) {
+       private function performAction( Page $page, Title $requestTitle ) {
                global $wgUseSquid, $wgSquidMaxage;
 
                wfProfileIn( __METHOD__ );
@@ -420,7 +421,7 @@ class MediaWiki {
                if ( $action instanceof Action ) {
                        # Let Squid cache things if we can purge them.
                        if ( $wgUseSquid &&
-                               in_array( $request->getFullRequestURL(), $title->getSquidURLs() )
+                               in_array( $request->getFullRequestURL(), $requestTitle->getSquidURLs() )
                        ) {
                                $output->setSquidMaxage( $wgSquidMaxage );
                        }
index a4b2002..6b48fa4 100644 (file)
@@ -129,6 +129,8 @@ class SquidUpdate {
                        return;
                }
 
+               wfDebug( "Squid purge: " . implode( ' ', $urlArr ) . "\n" );
+
                if ( $wgHTCPMulticastRouting ) {
                        SquidUpdate::HTCPPurge( $urlArr );
                }