Don't always count CASCADINGSOURCES as expensive
[lhc/web/wiklou.git] / includes / Title.php
index 88268bb..f2de4b8 100644 (file)
@@ -2555,6 +2555,19 @@ class Title {
                return ( $sources > 0 );
        }
 
+       /**
+        * Determines whether cascading protection sources have already been loaded from
+        * the database.
+        *
+        * @param bool $getPages True to check if the pages are loaded, or false to check
+        * if the status is loaded.
+        * @return bool Whether or not the specified information has been loaded
+        * @since 1.23
+        */
+       public function areCascadeProtectionSourcesLoaded( $getPages = true ) {
+               return $getPages ? isset( $this->mCascadeSources ) : isset( $this->mHasCascadingRestrictions );
+       }
+
        /**
         * Cascading protection: Get the source of any cascading restrictions on this page.
         *
@@ -2655,6 +2668,17 @@ class Title {
                return array( $sources, $pagerestrictions );
        }
 
+       /**
+        * Accessor for mRestrictionsLoaded
+        *
+        * @return bool Whether or not the page's restrictions have already been
+        * loaded from the database
+        * @since 1.23
+        */
+       public function areRestrictionsLoaded() {
+               return $this->mRestrictionsLoaded;
+       }
+
        /**
         * Accessor/initialisation for mRestrictions
         *
@@ -2670,6 +2694,21 @@ class Title {
                                : array();
        }
 
+       /**
+        * Accessor/initialisation for mRestrictions
+        *
+        * @return Array of Arrays of Strings the first level indexed by
+        * action, the second level containing the names of the groups
+        * allowed to perform each action
+        * @since 1.23
+        */
+       public function getAllRestrictions() {
+               if ( !$this->mRestrictionsLoaded ) {
+                       $this->loadRestrictions();
+               }
+               return $this->mRestrictions;
+       }
+
        /**
         * Get the expiry time for the restriction against a given action
         *
@@ -3538,6 +3577,13 @@ class Title {
                        }
                }
 
+               // If we are looking at a css/js user subpage, purge the action=raw.
+               if ( $this->isJsSubpage() ) {
+                       $urls[] = $this->getInternalUrl( 'action=raw&ctype=text/javascript' );
+               } elseif ( $this->isCssSubpage() ) {
+                       $urls[] = $this->getInternalUrl( 'action=raw&ctype=text/css' );
+               }
+
                wfRunHooks( 'TitleSquidURLs', array( $this, &$urls ) );
                return $urls;
        }
@@ -3891,6 +3937,7 @@ class Title {
 
                if ( $moveOverRedirect ) {
                        $newid = $nt->getArticleID();
+                       $newcontent = $newpage->getContent();
 
                        # Delete the old redirect. We don't save it to history since
                        # by definition if we've got here it's rather uninteresting.
@@ -3898,7 +3945,7 @@ class Title {
                        # a conflict on the unique namespace+title index...
                        $dbw->delete( 'page', array( 'page_id' => $newid ), __METHOD__ );
 
-                       $newpage->doDeleteUpdates( $newid );
+                       $newpage->doDeleteUpdates( $newid, $newcontent );
                }
 
                # Save a null revision in the page's history notifying of the move