Fix PHP 5.2 compatibility for r77144
[lhc/web/wiklou.git] / includes / Title.php
index 02bf964..da282fd 100644 (file)
@@ -329,8 +329,8 @@ class Title {
         * This will only return the very next target, useful for
         * the redirect table and other checks that don't need full recursion
         *
-        * @param $text \type{\string} Text with possible redirect
-        * @return \type{Title} The corresponding Title
+        * @param $text String: Text with possible redirect
+        * @return Title: The corresponding Title
         */
        public static function newFromRedirect( $text ) {
                return self::newFromRedirectInternal( $text );
@@ -595,21 +595,21 @@ class Title {
        /**
         * Get the main part with underscores
         *
-        * @return \type{\string} Main part of the title, with underscores
+        * @return String: Main part of the title, with underscores
         */
        public function getDBkey() { return $this->mDbkeyform; }
 
        /**
         * Get the namespace index, i.e.\ one of the NS_xxxx constants.
         *
-        * @return \type{\int} Namespace index
+        * @return Integer: Namespace index
         */
        public function getNamespace() { return $this->mNamespace; }
 
        /**
         * Get the namespace text
         *
-        * @return \type{\string} Namespace text
+        * @return String: Namespace text
         */
        public function getNsText() {
                global $wgContLang;
@@ -1602,6 +1602,10 @@ class Title {
                return $this->mTitleProtection;
        }
 
+       private function invalidateTitleProtectionCache() {
+               unset( $this->mTitleProtection );
+       }
+
        /**
         * Update the title protection status
         *
@@ -1650,6 +1654,8 @@ class Title {
                        $dbw->delete( 'protected_titles', array( 'pt_namespace' => $namespace,
                                'pt_title' => $title ), __METHOD__ );
                }
+               $this->invalidateTitleProtectionCache();
+
                # Update the protection log
                if ( $dbw->affectedRows() ) {
                        $log = new LogPage( 'protect' );
@@ -1676,6 +1682,7 @@ class Title {
                        array( 'pt_namespace' => $this->getNamespace(), 'pt_title' => $this->getDBkey() ),
                        __METHOD__
                );
+               $this->invalidateTitleProtectionCache();
        }
 
        /**
@@ -2058,6 +2065,7 @@ class Title {
                }
                if ( $purgeExpired ) {
                        Title::purgeExpiredRestrictions();
+                       $this->invalidateTitleProtectionCache();
                }
 
                wfProfileOut( __METHOD__ );
@@ -2177,6 +2185,7 @@ class Title {
 
                        if ( $purgeExpired ) {
                                Title::purgeExpiredRestrictions();
+                               $this->invalidateTitleProtectionCache();
                        }
                }
 
@@ -2211,6 +2220,7 @@ class Title {
                                                $this->mRestrictions['create'] = explode( ',', trim( $title_protection['pt_create_perm'] ) );
                                        } else { // Get rid of the old restrictions
                                                Title::purgeExpiredRestrictions();
+                                               $this->invalidateTitleProtectionCache();
                                        }
                                } else {
                                        $this->mRestrictionsExpiry['create'] = Block::decodeExpiry( '' );
@@ -2794,7 +2804,7 @@ class Title {
                $retVal = array();
                if ( $db->numRows( $res ) ) {
                        foreach ( $res as $row ) {
-                               $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title )
+                               $titleObj = Title::makeTitle( $row->page_namespace, $row->page_title );
                                if ( $titleObj ) {
                                        $linkCache->addGoodLinkObj( $row->page_id, $titleObj, $row->page_len, $row->page_is_redirect, $row->page_latest );
                                        $retVal[] = $titleObj;
@@ -3292,7 +3302,6 @@ class Title {
                # Truncate for whole multibyte characters. +5 bytes for ellipsis
                $comment = $wgContLang->truncate( $comment, 250 );
 
-               $newid = $nt->getArticleID();
                $oldid = $this->getArticleID();
                $latest = $this->getLatestRevId();
 
@@ -3705,6 +3714,29 @@ class Title {
                );
        }
 
+       /**
+        * Get the number of authors between the given revision IDs.
+        * Used for diffs and other things that really need it.
+        *
+        * @param $fromRevId \type{\int} Revision ID (first before range)
+        * @param $toRevId \type{\int} Revision ID (first after range)
+        * @param $limit \type{\int} Maximum number of authors
+        * @param $flags \type{\int} Title::GAID_FOR_UPDATE
+        * @return \type{\int}
+        */
+       public function countAuthorsBetween( $fromRevId, $toRevId, $limit, $flags = 0 ) {
+               $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
+               $res = $db->select( 'revision', 'DISTINCT rev_user_text',
+                       array(
+                               'rev_page = ' . $this->getArticleID(),
+                               'rev_id > ' . (int)$fromRevId,
+                               'rev_id < ' . (int)$toRevId
+                       ), __METHOD__,
+                       array( 'LIMIT' => $limit )
+               );
+               return (int)$db->numRows( $res );
+       }
+
        /**
         * Compare with another title.
         *
@@ -4020,7 +4052,7 @@ class Title {
         * In other words, is this a content page, for the purposes of calculating
         * statistics, etc?
         *
-        * @return \type{\bool}
+        * @return Boolean
         */
        public function isContentPage() {
                return MWNamespace::isContent( $this->getNamespace() );