From 1da33a49a0a95ad7066926ca1a1a771411074946 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Tue, 11 Dec 2012 11:24:12 -0800 Subject: [PATCH] Removed references to DB ignoreErrors() function. Change-Id: I9441d897d45bca189c17b8bcca4ea7b3469af8b0 --- includes/LocalisationCache.php | 1 - includes/QueryPage.php | 78 ++++++++++++++++------------------ includes/ViewCountUpdate.php | 17 +++----- includes/profiler/Profiler.php | 76 ++++++++++++++++----------------- 4 files changed, 81 insertions(+), 91 deletions(-) diff --git a/includes/LocalisationCache.php b/includes/LocalisationCache.php index f6f5a76fe7..cc726d71ca 100644 --- a/includes/LocalisationCache.php +++ b/includes/LocalisationCache.php @@ -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; diff --git a/includes/QueryPage.php b/includes/QueryPage.php index 31df316881..a01ac68ebb 100644 --- a/includes/QueryPage.php +++ b/includes/QueryPage.php @@ -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; } diff --git a/includes/ViewCountUpdate.php b/includes/ViewCountUpdate.php index 28ba34146b..22a4649364 100644 --- a/includes/ViewCountUpdate.php +++ b/includes/ViewCountUpdate.php @@ -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() { diff --git a/includes/profiler/Profiler.php b/includes/profiler/Profiler.php index 62be39e497..f6f2117c78 100644 --- a/includes/profiler/Profiler.php +++ b/includes/profiler/Profiler.php @@ -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 ) {} } /** -- 2.20.1