r23108 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23107‎ | r23108 | r23109 >
Date:23:30, 19 June 2007
Author:aaron
Status:old
Tags:
Comment:
*Clean up profiling!
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -189,7 +189,6 @@
190190 */
191191 public static function getFlaggedRevText( $rev_id ) {
192192 wfProfileIn( __METHOD__ );
193 -
194193 $db = wfGetDB( DB_SLAVE );
195194 // Get the text from the flagged revisions table
196195 $result = $db->select(
@@ -201,6 +200,8 @@
202201 if( $row = $db->fetchObject($result) ) {
203202 return $row->fr_text;
204203 }
 204+ wfProfileOut( __METHOD__ );
 205+
205206 return NULL;
206207 }
207208
@@ -211,7 +212,6 @@
212213 */
213214 public static function getFlaggedRev( $rev_id ) {
214215 wfProfileIn( __METHOD__ );
215 -
216216 $db = wfGetDB( DB_SLAVE );
217217 // Skip deleted revisions
218218 $result = $db->select(
@@ -223,6 +223,8 @@
224224 if( $row = $db->fetchObject($result) ) {
225225 return $row;
226226 }
 227+ wfProfileOut( __METHOD__ );
 228+
227229 return NULL;
228230 }
229231
@@ -232,10 +234,10 @@
233235 * Will include deleted revs here
234236 */
235237 public static function getReviewedRevs( $page ) {
236 - wfProfileIn( __METHOD__ );
237 -
 238+ $rows = array();
 239+
 240+ wfProfileIn( __METHOD__ );
238241 $db = wfGetDB( DB_SLAVE );
239 - $rows = array();
240242
241243 $result = $db->select(
242244 array('flaggedrevs'),
@@ -246,6 +248,8 @@
247249 while ( $row = $db->fetchObject($result) ) {
248250 $rows[$row->fr_rev_id] = $row->fr_quality;
249251 }
 252+ wfProfileOut( __METHOD__ );
 253+
250254 return $rows;
251255 }
252256
@@ -256,11 +260,11 @@
257261 */
258262 public static function getRevCountSince( $page_id, $from_rev ) {
259263 wfProfileIn( __METHOD__ );
260 -
261264 $db = wfGetDB( DB_SLAVE );
262265 $count = $db->selectField('revision', 'COUNT(*)',
263266 array('rev_page' => $page_id, "rev_id > $from_rev"),
264267 __METHOD__ );
 268+ wfProfileOut( __METHOD__ );
265269
266270 return $count;
267271 }
@@ -301,12 +305,13 @@
302306 public static function getFlagsForPageRev( $rev_id ) {
303307 global $wgFlaggedRevTags;
304308
305 - wfProfileIn( __METHOD__ );
306309 // Set all flags to zero
307310 $flags = array();
308311 foreach( array_keys($wgFlaggedRevTags) as $tag ) {
309312 $flags[$tag] = 0;
310313 }
 314+
 315+ wfProfileIn( __METHOD__ );
311316 $db = wfGetDB( DB_SLAVE );
312317 // Grab all the tags for this revision
313318 $result = $db->select(
@@ -318,6 +323,7 @@
319324 while ( $row = $db->fetchObject($result) ) {
320325 $flags[$row->frt_dimension] = $row->frt_value;
321326 }
 327+ wfProfileOut( __METHOD__ );
322328
323329 return $flags;
324330 }
@@ -1141,14 +1147,14 @@
11421148 function getLatestQualityRev( $article=NULL ) {
11431149 global $wgArticle;
11441150
1145 - wfProfileIn( __METHOD__ );
1146 -
11471151 $article = $article ? $article : $wgArticle;
11481152 $title = $article->getTitle();
11491153 // Cached results available?
11501154 if( isset($this->stablefound) ) {
11511155 return ( $this->stablefound ) ? $this->stablerev : null;
11521156 }
 1157+
 1158+ wfProfileIn( __METHOD__ );
11531159 $dbr = wfGetDB( DB_SLAVE );
11541160 // Skip deleted revisions
11551161 $result = $dbr->select(
@@ -1158,6 +1164,7 @@
11591165 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted = 0'),
11601166 __METHOD__,
11611167 array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) );
 1168+ wfProfileOut( __METHOD__ );
11621169 // Do we have one?
11631170 if( $row = $dbr->fetchObject($result) ) {
11641171 $this->stablefound = true;
@@ -1182,14 +1189,13 @@
11831190 function getLatestStableRev( $article=NULL ) {
11841191 global $wgArticle;
11851192
1186 - wfProfileIn( __METHOD__ );
1187 -
11881193 $article = $article ? $article : $wgArticle;
11891194 $title = $article->getTitle();
11901195 // Cached results available?
11911196 if( isset($this->latestfound) ) {
11921197 return ( $this->latestfound ) ? $this->latestrev : NULL;
11931198 }
 1199+ wfProfileIn( __METHOD__ );
11941200 $dbr = wfGetDB( DB_SLAVE );
11951201 // Skip deleted revisions
11961202 $result = $dbr->select(
@@ -1199,6 +1205,7 @@
12001206 'fr_rev_id = rev_id', 'rev_page' => $article->getId(), 'rev_deleted = 0'),
12011207 __METHOD__,
12021208 array('ORDER BY' => 'fr_rev_id DESC', 'LIMIT' => 1 ) );
 1209+ wfProfileOut( __METHOD__ );
12031210 // Do we have one?
12041211 if( $row = $dbr->fetchObject($result) ) {
12051212 $this->latestfound = true;
@@ -1217,7 +1224,6 @@
12181225 public function getFlagsForRevision( $rev_id ) {
12191226 global $wgFlaggedRevTags;
12201227
1221 - wfProfileIn( __METHOD__ );
12221228 // Cached results?
12231229 if( isset($this->flags[$rev_id]) && $this->flags[$rev_id] )
12241230 return $this->revflags[$rev_id];
@@ -1226,6 +1232,8 @@
12271233 foreach( array_keys($wgFlaggedRevTags) as $tag ) {
12281234 $flags[$tag] = 0;
12291235 }
 1236+
 1237+ wfProfileIn( __METHOD__ );
12301238 $db = wfGetDB( DB_SLAVE );
12311239 // Grab all the tags for this revision
12321240 $result = $db->select(
@@ -1233,6 +1241,8 @@
12341242 array('frt_dimension', 'frt_value'),
12351243 array('frt_rev_id' => $rev_id),
12361244 __METHOD__ );
 1245+ wfProfileOut( __METHOD__ );
 1246+
12371247 // Iterate through each tag result
12381248 while( $row = $db->fetchObject($result) ) {
12391249 $flags[$row->frt_dimension] = $row->frt_value;
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php
@@ -272,8 +272,6 @@
273273 function approveRevision( $rev=NULL, $notes='' ) {
274274 global $wgUser, $wgFlaggedRevsWatch, $wgParser;
275275
276 - wfProfileIn( __METHOD__ );
277 -
278276 if( is_null($rev) ) return false;
279277 // No bogus timestamps
280278 if ( $this->timestamp && ($this->timestamp < $rev->getTimestamp() || $this->timestamp > wfTimestampNow()) )
@@ -344,6 +342,7 @@
345343 );
346344 }
347345
 346+ wfProfileIn( __METHOD__ );
348347 $dbw = wfGetDB( DB_MASTER );
349348 // Update our versioning pointers
350349 if( !empty( $tmpset ) ) {
@@ -392,6 +391,8 @@
393392 # Purge squid for this page only
394393 $this->page->purgeSquid();
395394
 395+ wfProfileOut( __METHOD__ );
 396+
396397 return true;
397398 }
398399
@@ -401,13 +402,12 @@
402403 */
403404 function unapproveRevision( $row=NULL ) {
404405 global $wgUser, $wgFlaggedRevsWatch;
405 -
406 - wfProfileIn( __METHOD__ );
407406
408407 if( is_null($row) ) return false;
409408
410409 $user = $wgUser->getId();
411410
 411+ wfProfileIn( __METHOD__ );
412412 $dbw = wfGetDB( DB_MASTER );
413413 // Delete from table
414414 $dbw->delete( 'flaggedrevs', array( 'fr_rev_id' => $row->fr_rev_id ) );
@@ -439,6 +439,8 @@
440440 # Purge squid for this page only
441441 $this->page->purgeSquid();
442442
 443+ wfProfileOut( __METHOD__ );
 444+
443445 return true;
444446 }
445447

Status & tagging log