* Moved the logic of whether or not to use the querycache into a isCached() function
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 16 Sep 2005 15:05:07 +0000 (15:05 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 16 Sep 2005 15:05:07 +0000 (15:05 +0000)
includes/QueryPage.php

index 558b733..41515cc 100644 (file)
@@ -96,6 +96,18 @@ class QueryPage {
                return $wgDisableQueryPages;
        }
 
+       /**
+        * Whether or not the output of the page in question is retrived from
+        * the database cache.
+        *
+        * @return bool
+        */
+       function isCached() {
+               global $wgMiserMode;
+               
+               return $this->isExpensive() && $wgMiserMode;
+       }
+
        /**
         * Sometime we dont want to build rss / atom feeds.
         */
@@ -218,8 +230,7 @@ class QueryPage {
         */
        function doQuery( $offset, $limit, $shownavigation=true ) {
                global $wgUser, $wgOut, $wgLang, $wgRequest, $wgContLang;
-               global $wgMiserMode;
-
+               
                $sname = $this->getName();
                $fname = get_class($this) . '::doQuery';
                $sql = $this->getSQL();
@@ -229,15 +240,12 @@ class QueryPage {
 
                $wgOut->setSyndicated( $this->isSyndicated() );
 
-               if ( $this->isExpensive() ) {
-                       // Disabled recache parameter due to retry problems -- TS
-                       if( $wgMiserMode ) {
-                               $type = $dbr->strencode( $sname );
-                               $sql =
-                                       "SELECT qc_type as type, qc_namespace as namespace,qc_title as title, qc_value as value
-                                        FROM $querycache WHERE qc_type='$type'";
-                               $wgOut->addWikiText( wfMsg( 'perfcached' ) );
-                       }
+               if ( $this->isCached() ) {
+                       $type = $dbr->strencode( $sname );
+                       $sql =
+                               "SELECT qc_type as type, qc_namespace as namespace,qc_title as title, qc_value as value
+                                FROM $querycache WHERE qc_type='$type'";
+                       $wgOut->addWikiText( wfMsg( 'perfcached' ) );
                }
 
                $sql .= $this->getOrder();