Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -131,8 +131,12 @@ |
132 | 132 | if ( !( $flags & FR_MASTER ) && $this->pendingRevs !== null ) { |
133 | 133 | return $this->pendingRevs; |
134 | 134 | } |
| 135 | + $srev = $this->getStableRev( $flags ); |
| 136 | + if ( !$srev ) { |
| 137 | + return 0; // none |
| 138 | + } |
135 | 139 | $count = null; |
136 | | - $sRevId = $this->getStable( $flags ); |
| 140 | + $sRevId = $srev->getRevId(); |
137 | 141 | # Try the cache... |
138 | 142 | $key = wfMemcKey( 'flaggedrevs', 'countPending', $this->getId() ); |
139 | 143 | if ( !( $flags & FR_MASTER ) ) { |
— | — | @@ -149,11 +153,12 @@ |
150 | 154 | } |
151 | 155 | # Otherwise, fetch result from DB as needed... |
152 | 156 | 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() ); |
156 | 160 | $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 |
158 | 163 | __METHOD__ ); |
159 | 164 | # Save result to cache... |
160 | 165 | $data = FlaggedRevs::makeMemcObj( "{$sRevId}-{$count}" ); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php |
— | — | @@ -311,8 +311,8 @@ |
312 | 312 | 'fr_img_sha1' => $this->getFileSha1() |
313 | 313 | ); |
314 | 314 | # 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__ ); |
317 | 317 | # Clear out any previous garbage. |
318 | 318 | # We want to be able to use this for tracking... |
319 | 319 | $dbw->delete( 'flaggedtemplates', |
— | — | @@ -387,14 +387,23 @@ |
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
| 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 | + /** |
391 | 401 | * Get timestamp of the corresponding revision |
| 402 | + * Note: here for convenience |
392 | 403 | * @return string revision timestamp in MW format |
393 | 404 | */ |
394 | 405 | 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" ); |
399 | 408 | } |
400 | 409 | |
401 | 410 | /** |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -1643,7 +1643,10 @@ |
1644 | 1644 | } |
1645 | 1645 | # Fetch and process cache the stable revision |
1646 | 1646 | 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; |
1648 | 1651 | $history->fr_pendingRevs = false; |
1649 | 1652 | } |
1650 | 1653 | if ( !$history->fr_stableRevId ) { |
— | — | @@ -1653,7 +1656,7 @@ |
1654 | 1657 | $revId = (int)$row->rev_id; |
1655 | 1658 | // Pending revision: highlight and add diff link |
1656 | 1659 | $link = $class = ''; |
1657 | | - if ( $revId > $history->fr_stableRevId ) { |
| 1660 | + if ( wfTimestamp( TS_UNIX, $row->rev_timestamp ) > $history->fr_stableRevUTS ) { |
1658 | 1661 | $class = 'flaggedrevs-pending'; |
1659 | 1662 | $link = wfMsgExt( 'revreview-hist-pending-difflink', 'parseinline', |
1660 | 1663 | $title->getPrefixedText(), $history->fr_stableRevId, $revId ); |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -1555,7 +1555,7 @@ |
1556 | 1556 | return ( $srev && $oldRev && $newRev |
1557 | 1557 | && $oldRev->getPage() == $newRev->getPage() // no multipage diffs |
1558 | 1558 | && $oldRev->getId() == $srev->getRevId() |
1559 | | - && $newRev->getTimestamp() >= $oldRev->getTimestamp() |
| 1559 | + && $newRev->getTimestamp() >= $oldRev->getTimestamp() // no backwards diffs |
1560 | 1560 | ); |
1561 | 1561 | } |
1562 | 1562 | |