r78044 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78043‎ | r78044 | r78045 >
Date:05:17, 8 December 2010
Author:aaron
Status:ok (Comments)
Tags:
Comment:
* (bug 15515) Fixed history highlighting and getPendingRevCount() to handle transwiki imports of old revs
* A few comment/line tweaks
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedArticleView.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -131,8 +131,12 @@
132132 if ( !( $flags & FR_MASTER ) && $this->pendingRevs !== null ) {
133133 return $this->pendingRevs;
134134 }
 135+ $srev = $this->getStableRev( $flags );
 136+ if ( !$srev ) {
 137+ return 0; // none
 138+ }
135139 $count = null;
136 - $sRevId = $this->getStable( $flags );
 140+ $sRevId = $srev->getRevId();
137141 # Try the cache...
138142 $key = wfMemcKey( 'flaggedrevs', 'countPending', $this->getId() );
139143 if ( !( $flags & FR_MASTER ) ) {
@@ -149,11 +153,12 @@
150154 }
151155 # Otherwise, fetch result from DB as needed...
152156 if ( is_null( $count ) ) {
153 - $db = ( $flags & FR_MASTER )
154 - ? wfGetDB( DB_MASTER )
155 - : wfGetDB( DB_SLAVE );
 157+ $db = ( $flags & FR_MASTER ) ?
 158+ wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 159+ $srevTS = $db->timestamp( $srev->getRevTimestamp() );
156160 $count = $db->selectField( 'revision', 'COUNT(*)',
157 - array( 'rev_page' => $this->getId(), 'rev_id > ' . (int)$sRevId ),
 161+ array( 'rev_page' => $this->getId(),
 162+ 'rev_timestamp > ' . $db->addQuotes( $srevTS ) ), // bug 15515
158163 __METHOD__ );
159164 # Save result to cache...
160165 $data = FlaggedRevs::makeMemcObj( "{$sRevId}-{$count}" );
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -311,8 +311,8 @@
312312 'fr_img_sha1' => $this->getFileSha1()
313313 );
314314 # Update flagged revisions table
315 - $dbw->replace( 'flaggedrevs', array( array( 'fr_page_id', 'fr_rev_id' ) ),
316 - $revRow, __METHOD__ );
 315+ $dbw->replace( 'flaggedrevs',
 316+ array( array( 'fr_page_id', 'fr_rev_id' ) ), $revRow, __METHOD__ );
317317 # Clear out any previous garbage.
318318 # We want to be able to use this for tracking...
319319 $dbw->delete( 'flaggedtemplates',
@@ -387,14 +387,23 @@
388388 }
389389
390390 /**
 391+ * Check if the corresponding revision is the current revision
 392+ * Note: here for convenience
 393+ * @return bool
 394+ */
 395+ public function isCurrent() {
 396+ $rev = $this->getRevision(); // corresponding revision
 397+ return ( $rev ? $rev->isCurrent() : false );
 398+ }
 399+
 400+ /**
391401 * Get timestamp of the corresponding revision
 402+ * Note: here for convenience
392403 * @return string revision timestamp in MW format
393404 */
394405 public function getRevTimestamp() {
395 - # Get corresponding revision
396 - $rev = $this->getRevision();
397 - $timestamp = $rev ? $rev->getTimestamp() : "0";
398 - return $timestamp;
 406+ $rev = $this->getRevision(); // corresponding revision
 407+ return ( $rev ? $rev->getTimestamp() : "0" );
399408 }
400409
401410 /**
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -1643,7 +1643,10 @@
16441644 }
16451645 # Fetch and process cache the stable revision
16461646 if ( !isset( $history->fr_stableRevId ) ) {
1647 - $history->fr_stableRevId = $fa->getStable();
 1647+ $srev = $fa->getStableRev();
 1648+ $history->fr_stableRevId = $srev ? $srev->getRevId() : null;
 1649+ $history->fr_stableRevUTS = $srev ? // bug 15515
 1650+ wfTimestamp( TS_UNIX, $srev->getRevTimestamp() ) : null;
16481651 $history->fr_pendingRevs = false;
16491652 }
16501653 if ( !$history->fr_stableRevId ) {
@@ -1653,7 +1656,7 @@
16541657 $revId = (int)$row->rev_id;
16551658 // Pending revision: highlight and add diff link
16561659 $link = $class = '';
1657 - if ( $revId > $history->fr_stableRevId ) {
 1660+ if ( wfTimestamp( TS_UNIX, $row->rev_timestamp ) > $history->fr_stableRevUTS ) {
16581661 $class = 'flaggedrevs-pending';
16591662 $link = wfMsgExt( 'revreview-hist-pending-difflink', 'parseinline',
16601663 $title->getPrefixedText(), $history->fr_stableRevId, $revId );
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php
@@ -1555,7 +1555,7 @@
15561556 return ( $srev && $oldRev && $newRev
15571557 && $oldRev->getPage() == $newRev->getPage() // no multipage diffs
15581558 && $oldRev->getId() == $srev->getRevId()
1559 - && $newRev->getTimestamp() >= $oldRev->getTimestamp()
 1559+ && $newRev->getTimestamp() >= $oldRev->getTimestamp() // no backwards diffs
15601560 );
15611561 }
15621562

Follow-up revisions

RevisionCommit summaryAuthorDate
r78051*(bug 15515) Fixed addToContribsLine() and addDraftTab() query w.r.t page imp...aaron07:31, 8 December 2010
r78092Improved getDiffRevMsgAndClass() for bug 15515aaron19:42, 8 December 2010
r78140* Made addToRCQuery() more selective for RCL. The RC hook should really requi...aaron21:28, 9 December 2010
r78557*Made 'excludeLastDays' act on 'totalContentEdits'/'totalCheckedEdits' too...aaron06:03, 18 December 2010
r78649Merged r78044 from trunk ( bug 15515 )pdhanda23:29, 20 December 2010
r78650Merged r78051 from trunk ( bug 15515 )pdhanda23:30, 20 December 2010
r78651Merged r78092 from trunk ( bug 15515 )pdhanda23:32, 20 December 2010
r78729Merged r78166 from trunk (bug 15515)pdhanda19:57, 21 December 2010
r80733MFT first round of FlaggedRevs fixes r78517, r78346, r78319, r78293, r78226, ...demon23:56, 21 January 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   05:19, 8 December 2010

Also adds isCurrent() for later use.

Status & tagging log