From: Liangent Date: Mon, 4 Jun 2012 06:46:36 +0000 (+0800) Subject: setSquidMaxage() globally if we can purge it, instead of in actions. X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=6eac0a40cf8b0922f89697ad038346e0a68a0eda;p=lhc%2Fweb%2Fwiklou.git setSquidMaxage() globally if we can purge it, instead of in actions. Change-Id: I404c994616eab0902a9e3650c97028e9bcfb22db --- diff --git a/includes/Wiki.php b/includes/Wiki.php index b20cb95837..08e06eae31 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -462,6 +462,8 @@ class MediaWiki { * @param $page Page */ private function performAction( Page $page ) { + global $wgUseSquid, $wgSquidMaxage; + wfProfileIn( __METHOD__ ); $request = $this->context->getRequest(); @@ -480,6 +482,15 @@ class MediaWiki { $action = Action::factory( $act, $page ); if ( $action instanceof Action ) { + # When it's a known action, let Squid cache things if we can purge them. + # If the action is unknown, we don't know what may happen in an extension, + # but not caching can be always safe. + if ( $wgUseSquid && + in_array( $request->getFullRequestURL(), $title->getSquidURLs() ) + ) { + $output->setSquidMaxage( $wgSquidMaxage ); + } + $action->show(); wfProfileOut( __METHOD__ ); return; diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index 8e6bcd9529..94bf50ce94 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -87,7 +87,7 @@ class HistoryAction extends FormlessAction { * Print the history page for an article. */ function onView() { - global $wgScript, $wgUseFileCache, $wgSquidMaxage; + global $wgScript, $wgUseFileCache; $out = $this->getOutput(); $request = $this->getRequest(); @@ -101,10 +101,6 @@ class HistoryAction extends FormlessAction { wfProfileIn( __METHOD__ ); - if ( $request->getFullRequestURL() == $this->getTitle()->getInternalURL( 'action=history' ) ) { - $out->setSquidMaxage( $wgSquidMaxage ); - } - $this->preCacheMessages(); # Fill in the file cache if not set already diff --git a/includes/actions/ViewAction.php b/includes/actions/ViewAction.php index d43e5fb3bb..d57585ee1f 100644 --- a/includes/actions/ViewAction.php +++ b/includes/actions/ViewAction.php @@ -34,13 +34,6 @@ class ViewAction extends FormlessAction { } public function show(){ - global $wgSquidMaxage; - - $request = $this->getRequest(); - if ( $request->getFullRequestURL() == $this->getTitle()->getInternalURL() ) { - $this->getOutput()->setSquidMaxage( $wgSquidMaxage ); - } - $this->page->view(); }