Wikia code/includes/QueryPage.php

--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\QueryPage.php	2011-07-18 22:31:28.314453100 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\QueryPage.php	2011-08-17 15:28:46.649414100 +0100
@@ -481,11 +481,24 @@
 			$feed = new $wgFeedClasses[$class](
 				$this->feedTitle(),
 				$this->feedDesc(),
-				$this->feedUrl() );
+				$this->feedUrl() 
+			);
 			$feed->outHeader();
 
 			$dbr = wfGetDB( DB_SLAVE );
-			$sql = $this->getSQL() . $this->getOrder();
+
+			$fname = get_class($this) . '::doQuery';
+			$sname = $this->getName();
+			if ( !$this->isCached() ) {
+				$sql = $this->getSQL();
+			} else {
+				# Get the cached result
+				$querycache = $dbr->tableName( 'querycache' );
+				$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'";
+			}
+			
+			$sql = $sql . " " . $this->getOrder();
 			$sql = $dbr->limitResult( $sql, $limit, 0 );
 			$res = $dbr->query( $sql, 'QueryPage::doFeed' );
 			while( $obj = $dbr->fetchObject( $res ) ) {