From: Ricordisamoa Date: Tue, 9 Dec 2014 19:16:50 +0000 (+0000) Subject: Revision: mark getRaw*() methods as deprecated X-Git-Tag: 1.31.0-rc.0~12654^2 X-Git-Url: http://git.cyclocoop.org/%22.%24image2.%22?a=commitdiff_plain;h=4ece7f53aa71f6e5de16d0982d32b155234c061f;p=lhc%2Fweb%2Fwiklou.git Revision: mark getRaw*() methods as deprecated Revision->getRawUser() => Revision->getUser( Revision::RAW ) Revision->getRawUserText() => Revision->getUserText( Revision::RAW ) Revision->getRawComment() => Revision->getComment( Revision::RAW ) The body of Revision->getRawUserText() has been moved into Revision->getUserText(). Every usage has been replaced. Change-Id: Ic6fbfbc0507dcf88072fcb2a2e2364ae1436dce7 --- diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25 index 76295a9882..1ba6e97548 100644 --- a/RELEASE-NOTES-1.25 +++ b/RELEASE-NOTES-1.25 @@ -316,6 +316,7 @@ changes to languages because of Bugzilla reports. $form->setDisplayFormat( 'vform' ); // throws exception Instead, do this: $form = HTMLForm::factory( 'vform', … ); +* Deprecated Revision methods getRawUser(), getRawUserText() and getRawComment(). == Compatibility == diff --git a/includes/Linker.php b/includes/Linker.php index 78408680b6..f220eba67d 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1605,7 +1605,7 @@ class Linker { * @return string HTML fragment */ public static function revComment( Revision $rev, $local = false, $isPublic = false ) { - if ( $rev->getRawComment() == "" ) { + if ( $rev->getComment( Revision::RAW ) == "" ) { return ""; } if ( $rev->isDeleted( Revision::DELETED_COMMENT ) && $isPublic ) { @@ -1870,7 +1870,7 @@ class Linker { $editCount = 0; $moreRevs = false; foreach ( $res as $row ) { - if ( $rev->getRawUserText() != $row->rev_user_text ) { + if ( $rev->getUserText( Revision::RAW ) != $row->rev_user_text ) { if ( $verify && ( $row->rev_deleted & Revision::DELETED_TEXT || $row->rev_deleted & Revision::DELETED_USER diff --git a/includes/Revision.php b/includes/Revision.php index c8015e62b6..90cc35ad76 100644 --- a/includes/Revision.php +++ b/includes/Revision.php @@ -826,9 +826,11 @@ class Revision implements IDBAccessObject { * Fetch revision's user id without regard for the current user's permissions * * @return string + * @deprecated since 1.25, use getUser( Revision::RAW ) */ public function getRawUser() { - return $this->mUser; + wfDeprecated( __METHOD__, '1.25' ); + return $this->getUser( self::RAW ); } /** @@ -850,7 +852,15 @@ class Revision implements IDBAccessObject { } elseif ( $audience == self::FOR_THIS_USER && !$this->userCan( self::DELETED_USER, $user ) ) { return ''; } else { - return $this->getRawUserText(); + if ( $this->mUserText === null ) { + $this->mUserText = User::whoIs( $this->mUser ); // load on demand + if ( $this->mUserText === false ) { + # This shouldn't happen, but it can if the wiki was recovered + # via importing revs and there is no user table entry yet. + $this->mUserText = $this->mOrigUserText; + } + } + return $this->mUserText; } } @@ -858,17 +868,11 @@ class Revision implements IDBAccessObject { * Fetch revision's username without regard for view restrictions * * @return string + * @deprecated since 1.25, use getUserText( Revision::RAW ) */ public function getRawUserText() { - if ( $this->mUserText === null ) { - $this->mUserText = User::whoIs( $this->mUser ); // load on demand - if ( $this->mUserText === false ) { - # This shouldn't happen, but it can if the wiki was recovered - # via importing revs and there is no user table entry yet. - $this->mUserText = $this->mOrigUserText; - } - } - return $this->mUserText; + wfDeprecated( __METHOD__, '1.25' ); + return $this->getUserText( self::RAW ); } /** @@ -898,9 +902,11 @@ class Revision implements IDBAccessObject { * Fetch revision comment without regard for the current user's permissions * * @return string + * @deprecated since 1.25, use getComment( Revision::RAW ) */ public function getRawComment() { - return $this->mComment; + wfDeprecated( __METHOD__, '1.25' ); + return $this->getComment( self::RAW ); } /** @@ -936,7 +942,7 @@ class Revision implements IDBAccessObject { $dbr = wfGetDB( DB_SLAVE ); return RecentChange::newFromConds( array( - 'rc_user_text' => $this->getRawUserText(), + 'rc_user_text' => $this->getUserText( Revision::RAW ), 'rc_timestamp' => $dbr->timestamp( $this->getTimestamp() ), 'rc_this_oldid' => $this->getId() ), diff --git a/includes/Title.php b/includes/Title.php index bb4d04ef36..ca12322d74 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -4154,17 +4154,19 @@ class Title { } // No DB query needed if $old and $new are the same or successive revisions: if ( $old->getId() === $new->getId() ) { - return ( $old_cmp === '>' && $new_cmp === '<' ) ? array() : array( $old->getRawUserText() ); + return ( $old_cmp === '>' && $new_cmp === '<' ) ? + array() : + array( $old->getUserText( Revision::RAW ) ); } elseif ( $old->getId() === $new->getParentId() ) { if ( $old_cmp === '>=' && $new_cmp === '<=' ) { - $authors[] = $old->getRawUserText(); - if ( $old->getRawUserText() != $new->getRawUserText() ) { - $authors[] = $new->getRawUserText(); + $authors[] = $old->getUserText( Revision::RAW ); + if ( $old->getUserText( Revision::RAW ) != $new->getUserText( Revision::RAW ) ) { + $authors[] = $new->getUserText( Revision::RAW ); } } elseif ( $old_cmp === '>=' ) { - $authors[] = $old->getRawUserText(); + $authors[] = $old->getUserText( Revision::RAW ); } elseif ( $new_cmp === '<=' ) { - $authors[] = $new->getRawUserText(); + $authors[] = $new->getUserText( Revision::RAW ); } return $authors; } diff --git a/includes/api/ApiQueryRevisionsBase.php b/includes/api/ApiQueryRevisionsBase.php index a658309f73..281f8381cc 100644 --- a/includes/api/ApiQueryRevisionsBase.php +++ b/includes/api/ApiQueryRevisionsBase.php @@ -179,9 +179,9 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { } if ( $revision->userCan( Revision::DELETED_USER, $user ) ) { if ( $this->fld_user ) { - $vals['user'] = $revision->getRawUserText(); + $vals['user'] = $revision->getUserText( Revision::RAW ); } - $userid = $revision->getRawUser(); + $userid = $revision->getUser( Revision::RAW ); if ( !$userid ) { $vals['anon'] = ''; } @@ -228,7 +228,7 @@ abstract class ApiQueryRevisionsBase extends ApiQueryGeneratorBase { $anyHidden = true; } if ( $revision->userCan( Revision::DELETED_COMMENT, $user ) ) { - $comment = $revision->getRawComment(); + $comment = $revision->getComment( Revision::RAW ); if ( $this->fld_comment ) { $vals['comment'] = $comment; diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 47967e489c..7b2ba0d40d 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -962,7 +962,7 @@ class DifferenceEngine extends ContextSource { $users = $this->mNewPage->getAuthorsBetween( $oldRev, $newRev, $limit ); $numUsers = count( $users ); - if ( $numUsers == 1 && $users[0] == $newRev->getRawUserText() ) { + if ( $numUsers == 1 && $users[0] == $newRev->getUserText( Revision::RAW ) ) { $numUsers = 0; // special case to say "by the same user" instead of "by one other user" } diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php index 8373dc01b1..9b98592208 100644 --- a/includes/page/WikiPage.php +++ b/includes/page/WikiPage.php @@ -2983,8 +2983,8 @@ class WikiPage implements Page, IDBAccessObject { // Get the last edit not by this guy... // Note: these may not be public values - $user = intval( $current->getRawUser() ); - $user_text = $dbw->addQuotes( $current->getRawUserText() ); + $user = intval( $current->getUser( Revision::RAW ) ); + $user_text = $dbw->addQuotes( $current->getUserText( Revision::RAW ) ); $s = $dbw->selectRow( 'revision', array( 'rev_id', 'rev_timestamp', 'rev_deleted' ), array( 'rev_page' => $current->getPage(), diff --git a/includes/specials/SpecialUndelete.php b/includes/specials/SpecialUndelete.php index 2ea1b12a69..fb2c421d16 100644 --- a/includes/specials/SpecialUndelete.php +++ b/includes/specials/SpecialUndelete.php @@ -550,7 +550,7 @@ class PageArchive { 'title' => $article->getTitle(), // used to derive default content model ) ); - $user = User::newFromName( $revision->getRawUserText(), false ); + $user = User::newFromName( $revision->getUserText( Revision::RAW ), false ); $content = $revision->getContent( Revision::RAW ); //NOTE: article ID may not be known yet. prepareSave() should not modify the database. @@ -623,7 +623,7 @@ class PageArchive { $wasnew = $article->updateIfNewerOn( $dbw, $revision, $previousRevId ); if ( $created || $wasnew ) { // Update site stats, link tables, etc - $user = User::newFromName( $revision->getRawUserText(), false ); + $user = User::newFromName( $revision->getUserText( Revision::RAW ), false ); $article->doEditUpdates( $revision, $user,