Removed references to DB ignoreErrors() function.
authorAaron Schulz <aschulz@wikimedia.org>
Tue, 11 Dec 2012 19:24:12 +0000 (11:24 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Tue, 11 Dec 2012 19:24:12 +0000 (11:24 -0800)
Change-Id: I9441d897d45bca189c17b8bcca4ea7b3469af8b0

includes/LocalisationCache.php
includes/QueryPage.php
includes/ViewCountUpdate.php
includes/profiler/Profiler.php

index f6f5a76..cc726d7 100644 (file)
@@ -1031,7 +1031,6 @@ class LCStore_DB implements LCStore {
                        if ( $this->dbw->wasReadOnlyError() ) {
                                $this->readOnly = true;
                                $this->dbw->rollback( __METHOD__ );
-                               $this->dbw->ignoreErrors( false );
                                return;
                        } else {
                                throw $e;
index 31df316..a01ac68 100644 (file)
@@ -302,55 +302,51 @@ abstract class QueryPage extends SpecialPage {
                        return false;
                }
 
-               if ( $ignoreErrors ) {
-                       $ignoreW = $dbw->ignoreErrors( true );
-                       $ignoreR = $dbr->ignoreErrors( true );
-               }
-
-               # Clear out any old cached data
-               $dbw->delete( 'querycache', array( 'qc_type' => $this->getName() ), $fname );
-               # Do query
-               $res = $this->reallyDoQuery( $limit, false );
-               $num = false;
-               if ( $res ) {
-                       $num = $res->numRows();
-                       # Fetch results
-                       $vals = array();
-                       while ( $res && $row = $dbr->fetchObject( $res ) ) {
-                               if ( isset( $row->value ) ) {
-                                       if ( $this->usesTimestamps() ) {
-                                               $value = wfTimestamp( TS_UNIX,
-                                                       $row->value );
+               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;
+                       if ( $res ) {
+                               $num = $res->numRows();
+                               # Fetch results
+                               $vals = array();
+                               while ( $res && $row = $dbr->fetchObject( $res ) ) {
+                                       if ( isset( $row->value ) ) {
+                                               if ( $this->usesTimestamps() ) {
+                                                       $value = wfTimestamp( TS_UNIX,
+                                                               $row->value );
+                                               } else {
+                                                       $value = intval( $row->value ); // @bug 14414
+                                               }
                                        } else {
-                                               $value = intval( $row->value ); // @bug 14414
+                                               $value = 0;
                                        }
-                               } else {
-                                       $value = 0;
-                               }
 
-                               $vals[] = array( 'qc_type' => $this->getName(),
-                                               'qc_namespace' => $row->namespace,
-                                               'qc_title' => $row->title,
-                                               'qc_value' => $value );
-                       }
+                                       $vals[] = array( 'qc_type' => $this->getName(),
+                                                       'qc_namespace' => $row->namespace,
+                                                       'qc_title' => $row->title,
+                                                       'qc_value' => $value );
+                               }
 
-                       # Save results into the querycache table on the master
-                       if ( count( $vals ) ) {
-                               if ( !$dbw->insert( 'querycache', $vals, __METHOD__ ) ) {
-                                       // Set result to false to indicate error
-                                       $num = false;
+                               # Save results into the querycache table on the master
+                               if ( count( $vals ) ) {
+                                       $dbw->insert( 'querycache', $vals, __METHOD__ );
                                }
+                               # Update the querycache_info record for the page
+                               $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
+                               $dbw->insert( 'querycache_info',
+                                       array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ),
+                                       $fname );
                        }
-                       if ( $ignoreErrors ) {
-                               $dbw->ignoreErrors( $ignoreW );
-                               $dbr->ignoreErrors( $ignoreR );
+               } catch ( DBError $e ) {
+                       if ( !$ignoreErrors ) {
+                               throw $e; // report query error
                        }
-
-                       # Update the querycache_info record for the page
-                       $dbw->delete( 'querycache_info', array( 'qci_type' => $this->getName() ), $fname );
-                       $dbw->insert( 'querycache_info', array( 'qci_type' => $this->getName(), 'qci_timestamp' => $dbw->timestamp() ), $fname );
-
+                       $num = false; // set result to false to indicate error
                }
+
                return $num;
        }
 
index 28ba341..22a4649 100644 (file)
@@ -53,16 +53,13 @@ class ViewCountUpdate implements DeferrableUpdate {
                }
 
                # Not important enough to warrant an error page in case of failure
-               $oldignore = $dbw->ignoreErrors( true );
-
-               $dbw->insert( 'hitcounter', array( 'hc_id' => $this->id ), __METHOD__ );
-
-               $checkfreq = intval( $wgHitcounterUpdateFreq / 25 + 1 );
-               if ( rand() % $checkfreq == 0 && $dbw->lastErrno() == 0 ) {
-                       $this->collect();
-               }
-
-               $dbw->ignoreErrors( $oldignore );
+               try {
+                       $dbw->insert( 'hitcounter', array( 'hc_id' => $this->id ), __METHOD__ );
+                       $checkfreq = intval( $wgHitcounterUpdateFreq / 25 + 1 );
+                       if ( rand() % $checkfreq == 0 && $dbw->lastErrno() == 0 ) {
+                               $this->collect();
+                       }
+               } catch ( DBError $e ) {}
        }
 
        protected function collect() {
index 62be39e..f6f2117 100644 (file)
@@ -524,52 +524,50 @@ class Profiler {
                        return;
                }
 
-               $errorState = $dbw->ignoreErrors( true );
-
                if( $wgProfilePerHost ){
                        $pfhost = wfHostname();
                } else {
                        $pfhost = '';
                }
 
-               $this->collateData();
-
-               foreach( $this->mCollated as $name => $elapsed ){
-                       $eventCount = $this->mCalls[$name];
-                       $timeSum = (float) ($elapsed * 1000);
-                       $memorySum = (float)$this->mMemory[$name];
-                       $name = substr($name, 0, 255);
-
-                       // Kludge
-                       $timeSum = ($timeSum >= 0) ? $timeSum : 0;
-                       $memorySum = ($memorySum >= 0) ? $memorySum : 0;
-
-                       $dbw->update( 'profiling',
-                               array(
-                                       "pf_count=pf_count+{$eventCount}",
-                                       "pf_time=pf_time+{$timeSum}",
-                                       "pf_memory=pf_memory+{$memorySum}",
-                               ),
-                               array(
-                                       'pf_name' => $name,
-                                       'pf_server' => $pfhost,
-                               ),
-                               __METHOD__ );
-
-                       $rc = $dbw->affectedRows();
-                       if ( $rc == 0 ) {
-                               $dbw->insert('profiling', array ('pf_name' => $name, 'pf_count' => $eventCount,
-                                       'pf_time' => $timeSum, 'pf_memory' => $memorySum, 'pf_server' => $pfhost ),
-                                       __METHOD__, array ('IGNORE'));
+               try {
+                       $this->collateData();
+
+                       foreach( $this->mCollated as $name => $elapsed ){
+                               $eventCount = $this->mCalls[$name];
+                               $timeSum = (float) ($elapsed * 1000);
+                               $memorySum = (float)$this->mMemory[$name];
+                               $name = substr($name, 0, 255);
+
+                               // Kludge
+                               $timeSum = ($timeSum >= 0) ? $timeSum : 0;
+                               $memorySum = ($memorySum >= 0) ? $memorySum : 0;
+
+                               $dbw->update( 'profiling',
+                                       array(
+                                               "pf_count=pf_count+{$eventCount}",
+                                               "pf_time=pf_time+{$timeSum}",
+                                               "pf_memory=pf_memory+{$memorySum}",
+                                       ),
+                                       array(
+                                               'pf_name' => $name,
+                                               'pf_server' => $pfhost,
+                                       ),
+                                       __METHOD__ );
+
+                               $rc = $dbw->affectedRows();
+                               if ( $rc == 0 ) {
+                                       $dbw->insert('profiling', array ('pf_name' => $name, 'pf_count' => $eventCount,
+                                               'pf_time' => $timeSum, 'pf_memory' => $memorySum, 'pf_server' => $pfhost ),
+                                               __METHOD__, array ('IGNORE'));
+                               }
+                               // When we upgrade to mysql 4.1, the insert+update
+                               // can be merged into just a insert with this construct added:
+                               //     "ON DUPLICATE KEY UPDATE ".
+                               //     "pf_count=pf_count + VALUES(pf_count), ".
+                               //     "pf_time=pf_time + VALUES(pf_time)";
                        }
-                       // When we upgrade to mysql 4.1, the insert+update
-                       // can be merged into just a insert with this construct added:
-                       //     "ON DUPLICATE KEY UPDATE ".
-                       //     "pf_count=pf_count + VALUES(pf_count), ".
-                       //     "pf_time=pf_time + VALUES(pf_time)";
-               }
-
-               $dbw->ignoreErrors( $errorState );
+               } catch ( DBError $e ) {}
        }
 
        /**