Made the page_count update defered, as for the site_stats update. I just removed...
[lhc/web/wiklou.git] / includes / Title.php
index 76bf76a..a5d9884 100644 (file)
@@ -411,9 +411,7 @@ class Title {
                                // and URL-decode links
                                if ( strpos( $m[1], '%' ) !== false ) {
                                        // Match behavior of inline link parsing here;
-                                       // don't interpret + as " " most of the time!
-                                       // It might be safe to just use rawurldecode instead, though.
-                                       $m[1] = urldecode( ltrim( $m[1], ':' ) );
+                                       $m[1] = rawurldecode( ltrim( $m[1], ':' ) );
                                }
                                $title = Title::newFromText( $m[1] );
                                // If the title is a redirect to bad special pages or is invalid, return null
@@ -1142,16 +1140,23 @@ class Title {
        }
 
        /**
-        * Determines if $wgUser is unable to edit this page because it has been protected
+        * Determines if $user is unable to edit this page because it has been protected
         * by $wgNamespaceProtection.
         *
+        * @param $user User object, $wgUser will be used if not passed
         * @return \type{\bool}
         */
-       public function isNamespaceProtected() {
-               global $wgNamespaceProtection, $wgUser;
+       public function isNamespaceProtected( User $user = null ) {
+               global $wgNamespaceProtection;
+
+               if ( $user === null ) {
+                       global $wgUser;
+                       $user = $wgUser;
+               }
+
                if ( isset( $wgNamespaceProtection[$this->mNamespace] ) ) {
                        foreach ( (array)$wgNamespaceProtection[$this->mNamespace] as $right ) {
-                               if ( $right != '' && !$wgUser->isAllowed( $right ) ) {
+                               if ( $right != '' && !$user->isAllowed( $right ) ) {
                                        return true;
                                }
                        }
@@ -1352,7 +1357,7 @@ class Title {
                }
 
                # Check $wgNamespaceProtection for restricted namespaces
-               if ( $this->isNamespaceProtected() ) {
+               if ( $this->isNamespaceProtected( $user ) ) {
                        $ns = $this->mNamespace == NS_MAIN ?
                                wfMsg( 'nstab-main' ) : $this->getNsText();
                        $errors[] = $this->mNamespace == NS_MEDIAWIKI ?
@@ -2415,7 +2420,7 @@ class Title {
         * Uses link cache, adding it if necessary
         *
         * @param $flags \type{\int} a bit field; may be Title::GAID_FOR_UPDATE to select for update
-        * @return \type{\bool}
+        * @return \type{\int}
         */
        public function getLength( $flags = 0 ) {
                if ( $this->mLength != -1 ) {
@@ -2455,7 +2460,7 @@ class Title {
         * This clears some fields in this object, and clears any associated
         * keys in the "bad links" section of the link cache.
         *
-        * - This is called from Article::insertNewArticle() to allow
+        * - This is called from Article::doEdit() and Article::insertOn() to allow
         * loading of the new page_id. It's also called from
         * Article::doDeleteArticle()
         *
@@ -3748,11 +3753,11 @@ class Title {
         */
        public function countRevisionsBetween( $old, $new ) {
                $dbr = wfGetDB( DB_SLAVE );
-               return (int)$dbr->selectField( 'revision', 'count(*)',
-                       'rev_page' => intval( $this->getArticleId() ) .
-                       ' AND rev_id > ' . intval( $old ) .
-                       ' AND rev_id < ' . intval( $new ),
-                       __METHOD__
+               return (int)$dbr->selectField( 'revision', 'count(*)', array(
+                               'rev_page' => intval( $this->getArticleId() ),
+                               'rev_id > ' . intval( $old ),
+                               'rev_id < ' . intval( $new )
+                       ), __METHOD__
                );
        }