From: Tim Starling Date: Fri, 23 Jun 2006 06:31:46 +0000 (+0000) Subject: s/Revision::MW_REV_DELETED/Revision::DELETED/, and introduced aliases for compatibili... X-Git-Tag: 1.31.0-rc.0~56685 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=eac0376cdc20b91e12ca8252c445fcd7a8ed3435;p=lhc%2Fweb%2Fwiklou.git s/Revision::MW_REV_DELETED/Revision::DELETED/, and introduced aliases for compatibility with 1.6. --- diff --git a/includes/Article.php b/includes/Article.php index b58dda3fca..402bceddc4 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -436,7 +436,7 @@ class Article { // FIXME: Horrible, horrible! This content-loading interface just plain sucks. // We should instead work with the Revision object when we need it... - $this->mContent = $revision->userCan( Revision::MW_REV_DELETED_TEXT ) ? $revision->getRawText() : ""; + $this->mContent = $revision->userCan( Revision::DELETED_TEXT ) ? $revision->getRawText() : ""; //$this->mContent = $revision->getText(); $this->mUser = $revision->getUser(); @@ -803,8 +803,8 @@ class Article { // FIXME: This would be a nice place to load the 'no such page' text. } else { $this->setOldSubtitle( isset($this->mOldId) ? $this->mOldId : $oldid ); - if( $this->mRevision->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) { - if( !$this->mRevision->userCan( Revision::MW_REV_DELETED_TEXT ) ) { + if( $this->mRevision->isDeleted( Revision::DELETED_TEXT ) ) { + if( !$this->mRevision->userCan( Revision::DELETED_TEXT ) ) { $wgOut->addWikiText( wfMsg( 'rev-deleted-text-permission' ) ); $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); return; diff --git a/includes/Export.php b/includes/Export.php index 88a83d9b2b..da92694e4d 100644 --- a/includes/Export.php +++ b/includes/Export.php @@ -395,7 +395,7 @@ class XmlDumpWriter { $ts = wfTimestamp( TS_ISO_8601, $row->rev_timestamp ); $out .= " " . wfElement( 'timestamp', null, $ts ) . "\n"; - if( $row->rev_deleted & Revision::MW_REV_DELETED_USER ) { + if( $row->rev_deleted & Revision::DELETED_USER ) { $out .= " " . wfElement( 'contributor', array( 'deleted' => 'deleted' ) ) . "\n"; } else { $out .= " \n"; @@ -411,13 +411,13 @@ class XmlDumpWriter { if( $row->rev_minor_edit ) { $out .= " \n"; } - if( $row->rev_deleted & Revision::MW_REV_DELETED_COMMENT ) { + if( $row->rev_deleted & Revision::DELETED_COMMENT ) { $out .= " " . wfElement( 'comment', array( 'deleted' => 'deleted' ) ) . "\n"; } elseif( $row->rev_comment != '' ) { $out .= " " . wfElementClean( 'comment', null, strval( $row->rev_comment ) ) . "\n"; } - if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) { + if( $row->rev_deleted & Revision::DELETED_TEXT ) { $out .= " " . wfElement( 'text', array( 'deleted' => 'deleted' ) ) . "\n"; } elseif( isset( $row->old_text ) ) { // Raw text from the database may have invalid chars diff --git a/includes/Linker.php b/includes/Linker.php index 416a940d73..86b1ec64e9 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -833,12 +833,12 @@ class Linker { * @return string HTML */ function revUserLink( $rev ) { - if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) { + if( $rev->userCan( Revision::DELETED_USER ) ) { $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ); } else { $link = wfMsgHtml( 'rev-deleted-user' ); } - if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) { + if( $rev->isDeleted( Revision::DELETED_USER ) ) { return '' . $link . ''; } return $link; @@ -850,14 +850,14 @@ class Linker { * @return string HTML */ function revUserTools( $rev ) { - if( $rev->userCan( Revision::MW_REV_DELETED_USER ) ) { + if( $rev->userCan( Revision::DELETED_USER ) ) { $link = $this->userLink( $rev->getRawUser(), $rev->getRawUserText() ) . ' ' . $this->userToolLinks( $rev->getRawUser(), $rev->getRawUserText() ); } else { $link = wfMsgHtml( 'rev-deleted-user' ); } - if( $rev->isDeleted( Revision::MW_REV_DELETED_USER ) ) { + if( $rev->isDeleted( Revision::DELETED_USER ) ) { return '' . $link . ''; } return $link; @@ -977,13 +977,13 @@ class Linker { * @return string HTML */ function revComment( $rev ) { - if( $rev->userCan( Revision::MW_REV_DELETED_COMMENT ) ) { + if( $rev->userCan( Revision::DELETED_COMMENT ) ) { $block = $this->commentBlock( $rev->getRawComment(), $rev->getTitle() ); } else { $block = " " . wfMsgHtml( 'rev-deleted-comment' ) . ""; } - if( $rev->isDeleted( Revision::MW_REV_DELETED_COMMENT ) ) { + if( $rev->isDeleted( Revision::DELETED_COMMENT ) ) { return " $block"; } return $block; diff --git a/includes/PageHistory.php b/includes/PageHistory.php index 0dbf356b9d..8b72a0a765 100644 --- a/includes/PageHistory.php +++ b/includes/PageHistory.php @@ -263,7 +263,7 @@ class PageHistory { if ($notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp)) { $s .= ' ' . wfMsgHtml( 'updatedmarker' ) . ''; } - if( $row->rev_deleted & Revision::MW_REV_DELETED_TEXT ) { + if( $row->rev_deleted & Revision::DELETED_TEXT ) { $s .= ' ' . wfMsgHtml( 'deletedrev' ); } $s .= "\n"; @@ -275,13 +275,13 @@ class PageHistory { function revLink( $rev ) { global $wgLang; $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true ); - if( $rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { + if( $rev->userCan( Revision::DELETED_TEXT ) ) { $link = $this->mSkin->makeKnownLinkObj( $this->mTitle, $date, "oldid=" . $rev->getId() ); } else { $link = $date; } - if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) { + if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { return '' . $link . ''; } return $link; @@ -290,7 +290,7 @@ class PageHistory { /** @todo document */ function curLink( $rev, $latest ) { $cur = wfMsgExt( 'cur', array( 'escape') ); - if( $latest || !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { + if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) { return $cur; } else { return $this->mSkin->makeKnownLinkObj( @@ -313,7 +313,7 @@ class PageHistory { $last, "diff=" . $rev->getId() . "&oldid=prev" ); } - } elseif( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { + } elseif( !$rev->userCan( Revision::DELETED_TEXT ) ) { return $last; } else { return $this->mSkin->makeKnownLinkObj( @@ -337,7 +337,7 @@ class PageHistory { # 'title' => wfMsgHtml( 'selectolderversionfordiff' ) ); - if( !$rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { + if( !$rev->userCan( Revision::DELETED_TEXT ) ) { $radio['disabled'] = 'disabled'; } diff --git a/includes/Revision.php b/includes/Revision.php index 7ee0ffa5e2..3139f241bd 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -12,10 +12,10 @@ require_once( 'Database.php' ); * @todo document */ class Revision { - const MW_REV_DELETED_TEXT = 1; - const MW_REV_DELETED_COMMENT = 2; - const MW_REV_DELETED_USER = 4; - const MW_REV_DELETED_RESTRICTED = 8; + const DELETED_TEXT = 1; + const DELETED_COMMENT = 2; + const DELETED_USER = 4; + const DELETED_RESTRICTED = 8; /** * Load a page revision from a given revision ID number. @@ -348,7 +348,7 @@ class Revision { * @return int */ function getUser() { - if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) { + if( $this->isDeleted( self::DELETED_USER ) ) { return 0; } else { return $this->mUser; @@ -368,7 +368,7 @@ class Revision { * @return string */ function getUserText() { - if( $this->isDeleted( self::MW_REV_DELETED_USER ) ) { + if( $this->isDeleted( self::DELETED_USER ) ) { return ""; } else { return $this->mUserText; @@ -388,7 +388,7 @@ class Revision { * @return string */ function getComment() { - if( $this->isDeleted( self::MW_REV_DELETED_COMMENT ) ) { + if( $this->isDeleted( self::DELETED_COMMENT ) ) { return ""; } else { return $this->mComment; @@ -411,7 +411,7 @@ class Revision { } /** - * int $field one of MW_REV_DELETED_* bitfield constants + * int $field one of DELETED_* bitfield constants * @return bool */ function isDeleted( $field ) { @@ -423,7 +423,7 @@ class Revision { * @return string */ function getText() { - if( $this->isDeleted( self::MW_REV_DELETED_TEXT ) ) { + if( $this->isDeleted( self::DELETED_TEXT ) ) { return ""; } else { return $this->getRawText(); @@ -734,15 +734,15 @@ class Revision { /** * Determine if the current user is allowed to view a particular * field of this revision, if it's marked as deleted. - * @param int $field one of self::MW_REV_DELETED_TEXT, - * self::MW_REV_DELETED_COMMENT, - * self::MW_REV_DELETED_USER + * @param int $field one of self::DELETED_TEXT, + * self::DELETED_COMMENT, + * self::DELETED_USER * @return bool */ function userCan( $field ) { if( ( $this->mDeleted & $field ) == $field ) { global $wgUser; - $permission = ( $this->mDeleted & self::MW_REV_DELETED_RESTRICTED ) == self::MW_REV_DELETED_RESTRICTED + $permission = ( $this->mDeleted & self::DELETED_RESTRICTED ) == self::DELETED_RESTRICTED ? 'hiderevision' : 'deleterevision'; wfDebug( "Checking for $permission due to $field match on $this->mDeleted\n" ); @@ -752,6 +752,31 @@ class Revision { } } + + /** + * Get rev_timestamp from rev_id, without loading the rest of the row + * @param integer $id + */ + static function getTimestampFromID( $id ) { + $timestamp = $dbr->selectField( 'revision', 'rev_timestamp', + array( 'rev_id' => $id ), __METHOD__ ); + if ( $timestamp === false ) { + # Not in slave, try master + $dbw =& wfGetDB( DB_MASTER ); + $timestamp = $dbw->selectField( 'revision', 'rev_timestamp', + array( 'rev_id' => $id ), __METHOD__ ); + } + return $timestamp; + } } +/** + * Aliases for backwards compatibility with 1.6 + */ +define( 'MW_REV_DELETED_TEXT', Revision::DELETED_TEXT ); +define( 'MW_REV_DELETED_COMMENT', Revision::DELETED_COMMENT ); +define( 'MW_REV_DELETED_USER', Revision::DELETED_USER ); +define( 'MW_REV_DELETED_RESTRICTED', Revision::DELETED_RESTRICTED ); + + ?> diff --git a/includes/SpecialContributions.php b/includes/SpecialContributions.php index c35909e6a5..8fe1f66631 100644 --- a/includes/SpecialContributions.php +++ b/includes/SpecialContributions.php @@ -412,7 +412,7 @@ function ucListEdit( $sk, $row ) { } } - if( $rev->userCan( Revision::MW_REV_DELETED_TEXT ) ) { + if( $rev->userCan( Revision::DELETED_TEXT ) ) { $difftext = '(' . $sk->makeKnownLinkObj( $page, $messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')'; } else { $difftext = '(' . $messages['diff'] . ')'; @@ -422,7 +422,7 @@ function ucListEdit( $sk, $row ) { $comment = $sk->revComment( $rev ); $d = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true ); - if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) { + if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { $d = '' . $d . ''; } @@ -433,7 +433,7 @@ function ucListEdit( $sk, $row ) { } $ret = "{$d} {$histlink} {$difftext} {$mflag} {$link} {$comment} {$topmarktext}"; - if( $rev->isDeleted( Revision::MW_REV_DELETED_TEXT ) ) { + if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { $ret .= ' ' . wfMsgHtml( 'deletedrev' ); } $ret = "
  • $ret
  • \n"; diff --git a/includes/SpecialRevisiondelete.php b/includes/SpecialRevisiondelete.php index f14e07bab5..7fa8bbb4b5 100644 --- a/includes/SpecialRevisiondelete.php +++ b/includes/SpecialRevisiondelete.php @@ -46,10 +46,10 @@ class RevisionDeleteForm { $this->skin = $wgUser->getSkin(); $this->checks = array( - array( 'revdelete-hide-text', 'wpHideText', Revision::MW_REV_DELETED_TEXT ), - array( 'revdelete-hide-comment', 'wpHideComment', Revision::MW_REV_DELETED_COMMENT ), - array( 'revdelete-hide-user', 'wpHideUser', Revision::MW_REV_DELETED_USER ), - array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::MW_REV_DELETED_RESTRICTED ) ); + array( 'revdelete-hide-text', 'wpHideText', Revision::DELETED_TEXT ), + array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ), + array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ), + array( 'revdelete-hide-restricted', 'wpHideRestricted', Revision::DELETED_RESTRICTED ) ); } /** @@ -222,9 +222,9 @@ class RevisionDeleter { function updateRecentChanges( $rev, $bitfield ) { $this->db->update( 'recentchanges', array( - 'rc_user' => ($bitfield & Revision::MW_REV_DELETED_USER) ? 0 : $rev->getUser(), - 'rc_user_text' => ($bitfield & Revision::MW_REV_DELETED_USER) ? wfMsg( 'rev-deleted-user' ) : $rev->getUserText(), - 'rc_comment' => ($bitfield & Revision::MW_REV_DELETED_COMMENT) ? wfMsg( 'rev-deleted-comment' ) : $rev->getComment() ), + 'rc_user' => ($bitfield & Revision::DELETED_USER) ? 0 : $rev->getUser(), + 'rc_user_text' => ($bitfield & Revision::DELETED_USER) ? wfMsg( 'rev-deleted-user' ) : $rev->getUserText(), + 'rc_comment' => ($bitfield & Revision::DELETED_COMMENT) ? wfMsg( 'rev-deleted-comment' ) : $rev->getComment() ), array( 'rc_this_oldid' => $rev->getId() ), 'RevisionDeleter::updateRecentChanges' ); diff --git a/includes/Title.php b/includes/Title.php index 6c29bc6695..ed46c4a7db 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -2152,11 +2152,11 @@ class Title { /** * Get the revision ID of the previous revision * - * @param integer $revision Revision ID. Get the revision that was before this one. + * @param integer $revId Revision ID. Get the revision that was before this one. + * @param string $timestamp The timestamp of the current revision, if known * @return interger $oldrevision|false */ - function getPreviousRevisionID( $revision ) { - $dbr =& wfGetDB( DB_SLAVE ); + function getPreviousRevisionID( $revId, $timestamp = false ) { return $dbr->selectField( 'revision', 'rev_id', 'rev_page=' . intval( $this->getArticleId() ) . ' AND rev_id<' . intval( $revision ) . ' ORDER BY rev_id DESC' );