Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/174230

Change subject: Use upsert() in ProfilerOutputDb
......................................................................

Use upsert() in ProfilerOutputDb

Change-Id: I807ee78c602b67c99530ecaab90af74410106fc7
---
M includes/profiler/output/ProfilerOutputDb.php
1 file changed, 11 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/30/174230/1

diff --git a/includes/profiler/output/ProfilerOutputDb.php 
b/includes/profiler/output/ProfilerOutputDb.php
index 3c2912e..64bfc3b 100644
--- a/includes/profiler/output/ProfilerOutputDb.php
+++ b/includes/profiler/output/ProfilerOutputDb.php
@@ -61,37 +61,22 @@
                                $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__ );

-- 
To view, visit https://gerrit.wikimedia.org/r/174230
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I807ee78c602b67c99530ecaab90af74410106fc7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <asch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to