Index: trunk/phase3/includes/Article.php |
— | — | @@ -436,7 +436,7 @@ |
437 | 437 | |
438 | 438 | // FIXME: Horrible, horrible! This content-loading interface just plain sucks. |
439 | 439 | // We should instead work with the Revision object when we need it... |
440 | | - $this->mContent = $revision->userCan( Revision::MW_REV_DELETED_TEXT ) ? $revision->getRawText() : ""; |
| 440 | + $this->mContent = $revision->userCan( Revision::DELETED_TEXT ) ? $revision->getRawText() : ""; |
441 | 441 | //$this->mContent = $revision->getText(); |
442 | 442 | |
443 | 443 | $this->mUser = $revision->getUser(); |
— | — | @@ -803,8 +803,8 @@ |
804 | 804 | // FIXME: This would be a nice place to load the 'no such page' text. |
805 | 805 | } else { |
806 | 806 | $this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid ); |
807 | | - if( $this->mRevision->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) { |
808 | | - if( !$this->mRevision->userCan( Revision::MW_REV_DELETED_TEXT ) ) { |
| 807 | + if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { |
| 808 | + if( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) { |
809 | 809 | $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) ); |
810 | 810 | $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); |
811 | 811 | return; |
Index: trunk/phase3/includes/SpecialRevisiondelete.php |
— | — | @@ -46,10 +46,10 @@ |
47 | 47 | |
48 | 48 | $this->skin = $wgUser->getSkin(); |
49 | 49 | $this->checks = array( |
50 | | - array( 'revdelete-hide-text', 'wpHideText', Revision::MW_REV_DELETED_TEXT ), |
51 | | - array( 'revdelete-hide-comment', 'wpHideComment', Revision::MW_REV_DELETED_COMMENT ), |
52 | | - array( 'revdelete-hide-user', 'wpHideUser', Revision::MW_REV_DELETED_USER ), |
53 | | - array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::MW_REV_DELETED_RESTRICTED ) ); |
| 50 | + array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT ), |
| 51 | + array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ), |
| 52 | + array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ), |
| 53 | + array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED ) ); |
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
— | — | @@ -222,9 +222,9 @@ |
223 | 223 | function updateRecentChanges( $rev, $bitfield ) { |
224 | 224 | $this->db->update( 'recentchanges', |
225 | 225 | array( |
226 | | - 'rc_user' => ($bitfield & Revision::MW_REV_DELETED_USER) ? 0 : $rev->getUser(), |
227 | | - 'rc_user_text' => ($bitfield & Revision::MW_REV_DELETED_USER) ? wfMsg( 'rev-deleted-user' ) : $rev->getUserText(), |
228 | | - 'rc_comment' => ($bitfield & Revision::MW_REV_DELETED_COMMENT) ? wfMsg( 'rev-deleted-comment' ) : $rev->getComment() ), |
| 226 | + 'rc_user' => ($bitfield & Revision::DELETED_USER) ? 0 : $rev->getUser(), |
| 227 | + 'rc_user_text' => ($bitfield & Revision::DELETED_USER) ? wfMsg( 'rev-deleted-user' ) : $rev->getUserText(), |
| 228 | + 'rc_comment' => ($bitfield & Revision::DELETED_COMMENT) ? wfMsg( 'rev-deleted-comment' ) : $rev->getComment() ), |
229 | 229 | array( |
230 | 230 | 'rc_this_oldid' => $rev->getId() ), |
231 | 231 | 'RevisionDeleter::updateRecentChanges' ); |
Index: trunk/phase3/includes/Linker.php |
— | — | @@ -833,12 +833,12 @@ |
834 | 834 | * @return string HTML |
835 | 835 | */ |
836 | 836 | function revUserLink( $rev ) { |
837 | | - if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) { |
| 837 | + if( $rev->userCan( Revision::DELETED_USER ) ) { |
838 | 838 | $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ); |
839 | 839 | } else { |
840 | 840 | $link = wfMsgHtml( 'rev-deleted-user' ); |
841 | 841 | } |
842 | | - if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) { |
| 842 | + if( $rev->isDeleted( Revision::DELETED_USER ) ) { |
843 | 843 | return '<span class="history-deleted">' . $link . '</span>'; |
844 | 844 | } |
845 | 845 | return $link; |
— | — | @@ -850,14 +850,14 @@ |
851 | 851 | * @return string HTML |
852 | 852 | */ |
853 | 853 | function revUserTools( $rev ) { |
854 | | - if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) { |
| 854 | + if( $rev->userCan( Revision::DELETED_USER ) ) { |
855 | 855 | $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ) . |
856 | 856 | ' ' . |
857 | 857 | $this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() ); |
858 | 858 | } else { |
859 | 859 | $link = wfMsgHtml( 'rev-deleted-user' ); |
860 | 860 | } |
861 | | - if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) { |
| 861 | + if( $rev->isDeleted( Revision::DELETED_USER ) ) { |
862 | 862 | return '<span class="history-deleted">' . $link . '</span>'; |
863 | 863 | } |
864 | 864 | return $link; |
— | — | @@ -977,13 +977,13 @@ |
978 | 978 | * @return string HTML |
979 | 979 | */ |
980 | 980 | function revComment( $rev ) { |
981 | | - if( $rev->userCan( Revision::MW_REV_DELETED_COMMENT ) ) { |
| 981 | + if( $rev->userCan( Revision::DELETED_COMMENT ) ) { |
982 | 982 | $block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle() ); |
983 | 983 | } else { |
984 | 984 | $block = " <span class=\"comment\">" . |
985 | 985 | wfMsgHtml( 'rev-deleted-comment' ) . "</span>"; |
986 | 986 | } |
987 | | - if( $rev->isDeleted( Revision::MW_REV_DELETED_COMMENT ) ) { |
| 987 | + if( $rev->isDeleted( Revision::DELETED_COMMENT ) ) { |
988 | 988 | return " <span class=\"history-deleted\">$block</span>"; |
989 | 989 | } |
990 | 990 | return $block; |
Index: trunk/phase3/includes/SpecialContributions.php |
— | — | @@ -412,7 +412,7 @@ |
413 | 413 | } |
414 | 414 | |
415 | 415 | } |
416 | | - if( $rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { |
| 416 | + if( $rev->userCan( Revision::DELETED_TEXT ) ) { |
417 | 417 | $difftext = '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')'; |
418 | 418 | } else { |
419 | 419 | $difftext = '(' . $messages['diff'] . ')'; |
— | — | @@ -422,7 +422,7 @@ |
423 | 423 | $comment = $sk->revComment( $rev ); |
424 | 424 | $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true ); |
425 | 425 | |
426 | | - if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) { |
| 426 | + if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
427 | 427 | $d = '<span class="history-deleted">' . $d . '</span>'; |
428 | 428 | } |
429 | 429 | |
— | — | @@ -433,7 +433,7 @@ |
434 | 434 | } |
435 | 435 | |
436 | 436 | $ret = "{$d} {$histlink} {$difftext} {$mflag} {$link} {$comment} {$topmarktext}"; |
437 | | - if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) { |
| 437 | + if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
438 | 438 | $ret .= ' ' . wfMsgHtml( 'deletedrev' ); |
439 | 439 | } |
440 | 440 | $ret = "<li>$ret</li>\n"; |
Index: trunk/phase3/includes/Export.php |
— | — | @@ -395,7 +395,7 @@ |
396 | 396 | $ts = wfTimestamp( TS_ISO_8601, $row->rev_timestamp ); |
397 | 397 | $out .= " " . wfElement( 'timestamp', null, $ts ) . "\n"; |
398 | 398 | |
399 | | - if( $row->rev_deleted & Revision::MW_REV_DELETED_USER ) { |
| 399 | + if( $row->rev_deleted & Revision::DELETED_USER ) { |
400 | 400 | $out .= " " . wfElement( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n"; |
401 | 401 | } else { |
402 | 402 | $out .= " <contributor>\n"; |
— | — | @@ -411,13 +411,13 @@ |
412 | 412 | if( $row->rev_minor_edit ) { |
413 | 413 | $out .= " <minor/>\n"; |
414 | 414 | } |
415 | | - if( $row->rev_deleted & Revision::MW_REV_DELETED_COMMENT ) { |
| 415 | + if( $row->rev_deleted & Revision::DELETED_COMMENT ) { |
416 | 416 | $out .= " " . wfElement( 'comment', array( 'deleted' => 'deleted' ) ) . "\n"; |
417 | 417 | } elseif( $row->rev_comment != '' ) { |
418 | 418 | $out .= " " . wfElementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n"; |
419 | 419 | } |
420 | 420 | |
421 | | - if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) { |
| 421 | + if( $row->rev_deleted & Revision::DELETED_TEXT ) { |
422 | 422 | $out .= " " . wfElement( 'text', array( 'deleted' => 'deleted' ) ) . "\n"; |
423 | 423 | } elseif( isset( $row->old_text ) ) { |
424 | 424 | // Raw text from the database may have invalid chars |
Index: trunk/phase3/includes/Revision.php |
— | — | @@ -12,10 +12,10 @@ |
13 | 13 | * @todo document |
14 | 14 | */ |
15 | 15 | class Revision { |
16 | | - const MW_REV_DELETED_TEXT = 1; |
17 | | - const MW_REV_DELETED_COMMENT = 2; |
18 | | - const MW_REV_DELETED_USER = 4; |
19 | | - const MW_REV_DELETED_RESTRICTED = 8; |
| 16 | + const DELETED_TEXT = 1; |
| 17 | + const DELETED_COMMENT = 2; |
| 18 | + const DELETED_USER = 4; |
| 19 | + const DELETED_RESTRICTED = 8; |
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Load a page revision from a given revision ID number. |
— | — | @@ -348,7 +348,7 @@ |
349 | 349 | * @return int |
350 | 350 | */ |
351 | 351 | function getUser() { |
352 | | - if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) { |
| 352 | + if( $this->isDeleted( self::DELETED_USER ) ) { |
353 | 353 | return 0; |
354 | 354 | } else { |
355 | 355 | return $this->mUser; |
— | — | @@ -368,7 +368,7 @@ |
369 | 369 | * @return string |
370 | 370 | */ |
371 | 371 | function getUserText() { |
372 | | - if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) { |
| 372 | + if( $this->isDeleted( self::DELETED_USER ) ) { |
373 | 373 | return ""; |
374 | 374 | } else { |
375 | 375 | return $this->mUserText; |
— | — | @@ -388,7 +388,7 @@ |
389 | 389 | * @return string |
390 | 390 | */ |
391 | 391 | function getComment() { |
392 | | - if( $this->isDeleted( self::MW_REV_DELETED_COMMENT ) ) { |
| 392 | + if( $this->isDeleted( self::DELETED_COMMENT ) ) { |
393 | 393 | return ""; |
394 | 394 | } else { |
395 | 395 | return $this->mComment; |
— | — | @@ -411,7 +411,7 @@ |
412 | 412 | } |
413 | 413 | |
414 | 414 | /** |
415 | | - * int $field one of MW_REV_DELETED_* bitfield constants |
| 415 | + * int $field one of DELETED_* bitfield constants |
416 | 416 | * @return bool |
417 | 417 | */ |
418 | 418 | function isDeleted( $field ) { |
— | — | @@ -423,7 +423,7 @@ |
424 | 424 | * @return string |
425 | 425 | */ |
426 | 426 | function getText() { |
427 | | - if( $this->isDeleted( self::MW_REV_DELETED_TEXT ) ) { |
| 427 | + if( $this->isDeleted( self::DELETED_TEXT ) ) { |
428 | 428 | return ""; |
429 | 429 | } else { |
430 | 430 | return $this->getRawText(); |
— | — | @@ -734,15 +734,15 @@ |
735 | 735 | /** |
736 | 736 | * Determine if the current user is allowed to view a particular |
737 | 737 | * field of this revision, if it's marked as deleted. |
738 | | - * @param int $field one of self::MW_REV_DELETED_TEXT, |
739 | | - * self::MW_REV_DELETED_COMMENT, |
740 | | - * self::MW_REV_DELETED_USER |
| 738 | + * @param int $field one of self::DELETED_TEXT, |
| 739 | + * self::DELETED_COMMENT, |
| 740 | + * self::DELETED_USER |
741 | 741 | * @return bool |
742 | 742 | */ |
743 | 743 | function userCan( $field ) { |
744 | 744 | if( ( $this->mDeleted & $field ) == $field ) { |
745 | 745 | global $wgUser; |
746 | | - $permission = ( $this->mDeleted & self::MW_REV_DELETED_RESTRICTED ) == self::MW_REV_DELETED_RESTRICTED |
| 746 | + $permission = ( $this->mDeleted & self::DELETED_RESTRICTED ) == self::DELETED_RESTRICTED |
747 | 747 | ? 'hiderevision' |
748 | 748 | : 'deleterevision'; |
749 | 749 | wfDebug( "Checking for $permission due to $field match on $this->mDeleted\n" ); |
— | — | @@ -752,6 +752,31 @@ |
753 | 753 | } |
754 | 754 | } |
755 | 755 | |
| 756 | + |
| 757 | + /** |
| 758 | + * Get rev_timestamp from rev_id, without loading the rest of the row |
| 759 | + * @param integer $id |
| 760 | + */ |
| 761 | + static function getTimestampFromID( $id ) { |
| 762 | + $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', |
| 763 | + array( 'rev_id' => $id ), __METHOD__ ); |
| 764 | + if ( $timestamp === false ) { |
| 765 | + # Not in slave, try master |
| 766 | + $dbw =& wfGetDB( DB_MASTER ); |
| 767 | + $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', |
| 768 | + array( 'rev_id' => $id ), __METHOD__ ); |
| 769 | + } |
| 770 | + return $timestamp; |
| 771 | + } |
756 | 772 | } |
757 | 773 | |
| 774 | +/** |
| 775 | + * Aliases for backwards compatibility with 1.6 |
| 776 | + */ |
| 777 | +define( 'MW_REV_DELETED_TEXT', Revision::DELETED_TEXT ); |
| 778 | +define( 'MW_REV_DELETED_COMMENT', Revision::DELETED_COMMENT ); |
| 779 | +define( 'MW_REV_DELETED_USER', Revision::DELETED_USER ); |
| 780 | +define( 'MW_REV_DELETED_RESTRICTED', Revision::DELETED_RESTRICTED ); |
| 781 | + |
| 782 | + |
758 | 783 | ?> |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -2152,11 +2152,11 @@ |
2153 | 2153 | /** |
2154 | 2154 | * Get the revision ID of the previous revision |
2155 | 2155 | * |
2156 | | - * @param integer $revision Revision ID. Get the revision that was before this one. |
| 2156 | + * @param integer $revId Revision ID. Get the revision that was before this one. |
| 2157 | + * @param string $timestamp The timestamp of the current revision, if known |
2157 | 2158 | * @return interger $oldrevision|false |
2158 | 2159 | */ |
2159 | | - function getPreviousRevisionID( $revision ) { |
2160 | | - $dbr =& wfGetDB( DB_SLAVE ); |
| 2160 | + function getPreviousRevisionID( $revId, $timestamp = false ) { |
2161 | 2161 | return $dbr->selectField( 'revision', 'rev_id', |
2162 | 2162 | 'rev_page=' . intval( $this->getArticleId() ) . |
2163 | 2163 | ' AND rev_id<' . intval( $revision ) . ' ORDER BY rev_id DESC' ); |
Index: trunk/phase3/includes/PageHistory.php |
— | — | @@ -263,7 +263,7 @@ |
264 | 264 | if ($notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp)) { |
265 | 265 | $s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>'; |
266 | 266 | } |
267 | | - if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) { |
| 267 | + if( $row->rev_deleted & Revision::DELETED_TEXT ) { |
268 | 268 | $s .= ' ' . wfMsgHtml( 'deletedrev' ); |
269 | 269 | } |
270 | 270 | $s .= "</li>\n"; |
— | — | @@ -275,13 +275,13 @@ |
276 | 276 | function revLink( $rev ) { |
277 | 277 | global $wgLang; |
278 | 278 | $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true ); |
279 | | - if( $rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { |
| 279 | + if( $rev->userCan( Revision::DELETED_TEXT ) ) { |
280 | 280 | $link = $this->mSkin->makeKnownLinkObj( |
281 | 281 | $this->mTitle, $date, "oldid=" . $rev->getId() ); |
282 | 282 | } else { |
283 | 283 | $link = $date; |
284 | 284 | } |
285 | | - if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) { |
| 285 | + if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
286 | 286 | return '<span class="history-deleted">' . $link . '</span>'; |
287 | 287 | } |
288 | 288 | return $link; |
— | — | @@ -290,7 +290,7 @@ |
291 | 291 | /** @todo document */ |
292 | 292 | function curLink( $rev, $latest ) { |
293 | 293 | $cur = wfMsgExt( 'cur', array( 'escape') ); |
294 | | - if( $latest || !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { |
| 294 | + if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { |
295 | 295 | return $cur; |
296 | 296 | } else { |
297 | 297 | return $this->mSkin->makeKnownLinkObj( |
— | — | @@ -313,7 +313,7 @@ |
314 | 314 | $last, |
315 | 315 | "diff=" . $rev->getId() . "&oldid=prev" ); |
316 | 316 | } |
317 | | - } elseif( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { |
| 317 | + } elseif( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
318 | 318 | return $last; |
319 | 319 | } else { |
320 | 320 | return $this->mSkin->makeKnownLinkObj( |
— | — | @@ -337,7 +337,7 @@ |
338 | 338 | # 'title' => wfMsgHtml( 'selectolderversionfordiff' ) |
339 | 339 | ); |
340 | 340 | |
341 | | - if( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { |
| 341 | + if( !$rev->userCan( Revision::DELETED_TEXT ) ) { |
342 | 342 | $radio['disabled'] = 'disabled'; |
343 | 343 | } |
344 | 344 | |