Merge "Don't double escape in Linker::formatLinksInComment"
[lhc/web/wiklou.git] / includes / Revision.php
index e81ed75..90cc35a 100644 (file)
@@ -515,7 +515,6 @@ class Revision implements IDBAccessObject {
                if ( !$revIds ) {
                        return $revLens; // empty
                }
-               wfProfileIn( __METHOD__ );
                $res = $db->select( 'revision',
                        array( 'rev_id', 'rev_len' ),
                        array( 'rev_id' => $revIds ),
@@ -523,7 +522,6 @@ class Revision implements IDBAccessObject {
                foreach ( $res as $row ) {
                        $revLens[$row->rev_id] = $row->rev_len;
                }
-               wfProfileOut( __METHOD__ );
                return $revLens;
        }
 
@@ -828,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 );
        }
 
        /**
@@ -852,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;
                }
        }
 
@@ -860,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 );
        }
 
        /**
@@ -900,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 );
        }
 
        /**
@@ -938,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()
                        ),
@@ -1213,7 +1217,6 @@ class Revision implements IDBAccessObject {
         * @return string Text the text requested or false on failure
         */
        public static function getRevisionText( $row, $prefix = 'old_', $wiki = false ) {
-               wfProfileIn( __METHOD__ );
 
                # Get data
                $textField = $prefix . 'text';
@@ -1228,7 +1231,6 @@ class Revision implements IDBAccessObject {
                if ( isset( $row->$textField ) ) {
                        $text = $row->$textField;
                } else {
-                       wfProfileOut( __METHOD__ );
                        return false;
                }
 
@@ -1237,7 +1239,6 @@ class Revision implements IDBAccessObject {
                        $url = $text;
                        $parts = explode( '://', $url, 2 );
                        if ( count( $parts ) == 1 || $parts[1] == '' ) {
-                               wfProfileOut( __METHOD__ );
                                return false;
                        }
                        $text = ExternalStore::fetchFromURL( $url, array( 'wiki' => $wiki ) );
@@ -1247,7 +1248,6 @@ class Revision implements IDBAccessObject {
                if ( $text !== false ) {
                        $text = self::decompressRevisionText( $text, $flags );
                }
-               wfProfileOut( __METHOD__ );
                return $text;
        }
 
@@ -1331,8 +1331,6 @@ class Revision implements IDBAccessObject {
        public function insertOn( $dbw ) {
                global $wgDefaultExternalStore, $wgContentHandlerUseDB;
 
-               wfProfileIn( __METHOD__ );
-
                $this->checkContentModel();
 
                $data = $this->mText;
@@ -1343,7 +1341,6 @@ class Revision implements IDBAccessObject {
                        // Store and get the URL
                        $data = ExternalStore::insertToDefault( $data );
                        if ( !$data ) {
-                               wfProfileOut( __METHOD__ );
                                throw new MWException( "Unable to store text to external storage" );
                        }
                        if ( $flags ) {
@@ -1403,7 +1400,6 @@ class Revision implements IDBAccessObject {
                        $title = $this->getTitle();
 
                        if ( $title === null ) {
-                               wfProfileOut( __METHOD__ );
                                throw new MWException( "Insufficient information to determine the title of the "
                                        . "revision's page!" );
                        }
@@ -1419,9 +1415,8 @@ class Revision implements IDBAccessObject {
 
                $this->mId = $rev_id !== null ? $rev_id : $dbw->insertId();
 
-               wfRunHooks( 'RevisionInsertComplete', array( &$this, $data, $flags ) );
+               Hooks::run( 'RevisionInsertComplete', array( &$this, $data, $flags ) );
 
-               wfProfileOut( __METHOD__ );
                return $this->mId;
        }
 
@@ -1490,7 +1485,6 @@ class Revision implements IDBAccessObject {
         * @return string|bool The revision's text, or false on failure
         */
        protected function loadText() {
-               wfProfileIn( __METHOD__ );
 
                // Caching may be beneficial for massive use of external storage
                global $wgRevisionCacheExpiry, $wgMemc;
@@ -1500,7 +1494,6 @@ class Revision implements IDBAccessObject {
                        $text = $wgMemc->get( $key );
                        if ( is_string( $text ) ) {
                                wfDebug( __METHOD__ . ": got id $textId from cache\n" );
-                               wfProfileOut( __METHOD__ );
                                return $text;
                        }
                }
@@ -1548,8 +1541,6 @@ class Revision implements IDBAccessObject {
                        $wgMemc->set( $key, $text, $wgRevisionCacheExpiry );
                }
 
-               wfProfileOut( __METHOD__ );
-
                return $text;
        }
 
@@ -1571,8 +1562,6 @@ class Revision implements IDBAccessObject {
        public static function newNullRevision( $dbw, $pageId, $summary, $minor, $user = null ) {
                global $wgContentHandlerUseDB;
 
-               wfProfileIn( __METHOD__ );
-
                $fields = array( 'page_latest', 'page_namespace', 'page_title',
                                                'rev_text_id', 'rev_len', 'rev_sha1' );
 
@@ -1619,7 +1608,6 @@ class Revision implements IDBAccessObject {
                        $revision = null;
                }
 
-               wfProfileOut( __METHOD__ );
                return $revision;
        }