Merge "Expose the log_id of the deletion log entry in the action=delete API"
[lhc/web/wiklou.git] / includes / Title.php
index 6e3f16c..2b1a513 100644 (file)
@@ -209,7 +209,15 @@ class Title {
         */
        public static function newFromID( $id, $flags = 0 ) {
                $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
-               $row = $db->selectRow( 'page', '*', array( 'page_id' => $id ), __METHOD__ );
+               $row = $db->selectRow(
+                       'page',
+                       array(
+                               'page_namespace', 'page_title', 'page_id',
+                               'page_len', 'page_is_redirect', 'page_latest',
+                       ),
+                       array( 'page_id' => $id ),
+                       __METHOD__
+               );
                if ( $row !== false ) {
                        $title = Title::newFromRow( $row );
                } else {
@@ -928,7 +936,7 @@ class Title {
         */
        public function isConversionTable() {
                return $this->getNamespace() == NS_MEDIAWIKI &&
-                       strpos( $this->getText(), 'Conversiontable' ) !== false;
+                       strpos( $this->getText(), 'Conversiontable/' ) === 0;
        }
 
        /**
@@ -1508,6 +1516,7 @@ class Title {
        /**
         * Is $wgUser watching this page?
         *
+        * @deprecated in 1.20; use User::isWatched() instead.
         * @return Bool
         */
        public function userIsWatching() {
@@ -2555,7 +2564,10 @@ class Title {
                                        $this->mRestrictions['edit'] = explode( ',', trim( $temp[0] ) );
                                        $this->mRestrictions['move'] = explode( ',', trim( $temp[0] ) );
                                } else {
-                                       $this->mRestrictions[$temp[0]] = explode( ',', trim( $temp[1] ) );
+                                       $restriction = trim( $temp[1] );
+                                       if( $restriction != '' ) { //some old entries are empty
+                                               $this->mRestrictions[$temp[0]] = explode( ',', $restriction );
+                                       }
                                }
                        }
 
@@ -3273,16 +3285,14 @@ class Title {
         * @return Array of String the URLs
         */
        public function getSquidURLs() {
-               global $wgContLang;
-
                $urls = array(
                        $this->getInternalURL(),
                        $this->getInternalURL( 'action=history' )
                );
 
-               // purge variant urls as well
-               if ( $wgContLang->hasVariants() ) {
-                       $variants = $wgContLang->getVariants();
+               $pageLang = $this->getPageLanguage();
+               if ( $pageLang->hasVariants() ) {
+                       $variants = $pageLang->getVariants();
                        foreach ( $variants as $vCode ) {
                                $urls[] = $this->getInternalURL( '', $vCode );
                        }
@@ -3486,12 +3496,7 @@ class Title {
                $protected = $this->isProtected();
 
                // Do the actual move
-               $err = $this->moveToInternal( $nt, $reason, $createRedirect );
-               if ( is_array( $err ) ) {
-                       # @todo FIXME: What about the File we have already moved?
-                       $dbw->rollback( __METHOD__ );
-                       return $err;
-               }
+               $this->moveToInternal( $nt, $reason, $createRedirect );
 
                // Refresh the sortkey for this row.  Be careful to avoid resetting
                // cl_timestamp, which may disturb time-based lists on some sites.
@@ -3567,6 +3572,7 @@ class Title {
         * @param $reason String The reason for the move
         * @param $createRedirect Bool Whether to leave a redirect at the old title.  Ignored
         *   if the user doesn't have the suppressredirect right
+        * @throws MWException
         */
        private function moveToInternal( &$nt, $reason = '', $createRedirect = true ) {
                global $wgUser, $wgContLang;
@@ -3971,7 +3977,7 @@ class Title {
                $pageId = $this->getArticleID( $flags );
                if ( $pageId ) {
                        $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
-                       $row = $db->selectRow( 'revision', '*',
+                       $row = $db->selectRow( 'revision', Revision::selectFields(),
                                array( 'rev_page' => $pageId ),
                                __METHOD__,
                                array( 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 1 )