Revision: mark getRaw*() methods as deprecated
authorRicordisamoa <ricordisamoa@openmailbox.org>
Tue, 9 Dec 2014 19:16:50 +0000 (19:16 +0000)
committerRicordisamoa <ricordisamoa@openmailbox.org>
Sun, 18 Jan 2015 05:57:56 +0000 (06:57 +0100)
   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

RELEASE-NOTES-1.25
includes/Linker.php
includes/Revision.php
includes/Title.php
includes/api/ApiQueryRevisionsBase.php
includes/diff/DifferenceEngine.php
includes/page/WikiPage.php
includes/specials/SpecialUndelete.php

index 76295a9..1ba6e97 100644 (file)
@@ -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 ==
 
index 7840868..f220eba 100644 (file)
@@ -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
index c8015e6..90cc35a 100644 (file)
@@ -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()
                        ),
index bb4d04e..ca12322 100644 (file)
@@ -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;
                }
index a658309..281f838 100644 (file)
@@ -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;
index 47967e4..7b2ba0d 100644 (file)
@@ -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"
                        }
 
index 8373dc0..9b98592 100644 (file)
@@ -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(),
index 2ea1b12..fb2c421 100644 (file)
@@ -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,