From: Aaron Schulz Date: Tue, 18 Nov 2014 20:06:05 +0000 (-0800) Subject: Use upsert() in ProfilerOutputDb X-Git-Tag: 1.31.0-rc.0~13260^2 X-Git-Url: http://git.cyclocoop.org/%24image?a=commitdiff_plain;h=b5cadaa66993e0eff72e12eb3ac0fb119133e6ff;p=lhc%2Fweb%2Fwiklou.git Use upsert() in ProfilerOutputDb Change-Id: I807ee78c602b67c99530ecaab90af74410106fc7 --- diff --git a/includes/profiler/output/ProfilerOutputDb.php b/includes/profiler/output/ProfilerOutputDb.php index 3c2912eef4..64bfc3bf7b 100644 --- a/includes/profiler/output/ProfilerOutputDb.php +++ b/includes/profiler/output/ProfilerOutputDb.php @@ -61,37 +61,22 @@ class ProfilerOutputDb extends ProfilerOutput { $timeSum = $timeSum >= 0 ? $timeSum : 0; $memorySum = $memorySum >= 0 ? $memorySum : 0; - $dbw->update( 'profiling', + $dbw->upsert( 'profiling', + array( + 'pf_name' => $name, + 'pf_count' => $eventCount, + 'pf_time' => $timeSum, + 'pf_memory' => $memorySum, + 'pf_server' => $pfhost + ), + array( array( 'pf_name', 'pf_server' ) ), 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)"; + __METHOD__ + ); } if ( $useTrx ) { $dbw->endAtomic( __METHOD__ );