r87700 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87699‎ | r87700 | r87701 >
Date:22:36, 8 May 2011
Author:aaron
Status:ok
Tags:
Comment:
Tweak for bug 28598. Made insert() do strict insertions only and have the callers handle deleting any previous reviews via delete(). This eliminates the DELETE queries 99% of the time and replaces a REPLACE with a simple INSERT.
Modified paths:
  • /trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevision.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/dataclasses/FlaggedRevision.php
@@ -307,19 +307,15 @@
308308 'fr_img_timestamp' => $dbw->timestampOrNull( $this->mFileTimestamp ),
309309 'fr_img_sha1' => $this->mFileSha1
310310 );
311 - # Update flagged revisions table
312 - $dbw->replace( 'flaggedrevs',
313 - array( array( 'fr_rev_id' ) ), $revRow, __METHOD__ );
314 - # Clear out any previous garbage...
315 - $dbw->delete( 'flaggedtemplates',
316 - array( 'ft_rev_id' => $this->getRevId() ), __METHOD__ );
 311+ # Update the main flagged revisions table...
 312+ $dbw->insert( 'flaggedrevs', $revRow, __METHOD__, 'IGNORE' );
 313+ if ( !$dbw->affectedRows() ) {
 314+ return false; // duplicate review
 315+ }
317316 # ...and insert template version data
318317 if ( $tmpInsertRows ) {
319318 $dbw->insert( 'flaggedtemplates', $tmpInsertRows, __METHOD__, 'IGNORE' );
320319 }
321 - # Clear out any previous garbage...
322 - $dbw->delete( 'flaggedimages',
323 - array( 'fi_rev_id' => $this->getRevId() ), __METHOD__ );
324320 # ...and insert file version data
325321 if ( $fileInsertRows ) {
326322 $dbw->insert( 'flaggedimages', $fileInsertRows, __METHOD__, 'IGNORE' );
Index: trunk/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -367,7 +367,7 @@
368368 return true; // don't record if the same
369369 }
370370
371 - # Insert the review entry...
 371+ # The new review entry...
372372 $flaggedRevision = new FlaggedRevision( array(
373373 'rev' => $rev,
374374 'user_id' => $this->user->getId(),
@@ -381,6 +381,11 @@
382382 'fileVersions' => $fileVersions,
383383 'flags' => ''
384384 ) );
 385+ # Delete the old review entry if it exists...
 386+ if ( $oldFrev ) {
 387+ $oldFrev->delete();
 388+ }
 389+ # Insert the new review entry...
385390 $flaggedRevision->insert();
386391 # Update recent changes...
387392 $rcId = $rev->isUnpatrolled(); // int

Follow-up revisions

RevisionCommit summaryAuthorDate
r92317REL1_18 FR: r87606, r87617, r87669, r87690, r87700, r90388, r90419, r90741, r...reedy21:53, 15 July 2011

Status & tagging log