Removed isQueueDeprioritized()
[lhc/web/wiklou.git] / includes / QueryPage.php
index b8e4e60..a904c24 100644 (file)
@@ -295,14 +295,11 @@ abstract class QueryPage extends SpecialPage {
 
                $fname = get_class( $this ) . '::recache';
                $dbw = wfGetDB( DB_MASTER );
-               $dbr = wfGetDB( DB_SLAVE, array( $this->getName(), __METHOD__, 'vslow' ) );
-               if ( !$dbw || !$dbr ) {
+               if ( !$dbw ) {
                        return false;
                }
 
                try {
-                       # Clear out any old cached data
-                       $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname );
                        # Do query
                        $res = $this->reallyDoQuery( $limit, false );
                        $num = false;
@@ -310,7 +307,7 @@ abstract class QueryPage extends SpecialPage {
                                $num = $res->numRows();
                                # Fetch results
                                $vals = array();
-                               while ( $res && $row = $dbr->fetchObject( $res ) ) {
+                               foreach ( $res as $row ) {
                                        if ( isset( $row->value ) ) {
                                                if ( $this->usesTimestamps() ) {
                                                        $value = wfTimestamp( TS_UNIX,
@@ -328,6 +325,9 @@ abstract class QueryPage extends SpecialPage {
                                                        'qc_value' => $value );
                                }
 
+                               $dbw->begin( __METHOD__ );
+                               # Clear out any old cached data
+                               $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname );
                                # Save results into the querycache table on the master
                                if ( count( $vals ) ) {
                                        $dbw->insert( 'querycache', $vals, __METHOD__ );
@@ -337,6 +337,7 @@ abstract class QueryPage extends SpecialPage {
                                $dbw->insert( 'querycache_info',
                                        array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ),
                                        $fname );
+                               $dbw->commit( __METHOD__ );
                        }
                } catch ( DBError $e ) {
                        if ( !$ignoreErrors ) {
@@ -348,6 +349,13 @@ abstract class QueryPage extends SpecialPage {
                return $num;
        }
 
+       /**
+        * Get a DB connection to be used for slow recache queries
+        */
+       function getRecacheDB() {
+               return wfGetDB( DB_SLAVE, array( $this->getName(), 'QueryPage::recache', 'vslow' ) );
+       }
+
        /**
         * Run the query and return the result
         * @param int|bool $limit Numerical limit or false for no limit
@@ -357,7 +365,7 @@ abstract class QueryPage extends SpecialPage {
         */
        function reallyDoQuery( $limit, $offset = false ) {
                $fname = get_class( $this ) . "::reallyDoQuery";
-               $dbr = wfGetDB( DB_SLAVE );
+               $dbr = $this->getRecacheDB();
                $query = $this->getQueryInfo();
                $order = $this->getOrderFields();