Merge "ParserOutput::addLanguageLink needs a string"
[lhc/web/wiklou.git] / includes / SpecialPage.php
index 5b5d0a4..e844d93 100644 (file)
@@ -254,12 +254,14 @@ class SpecialPage {
         *
         * @param $name String
         * @param $subpage String|Bool subpage string, or false to not use a subpage
+        * @param $fragment String the link fragment (after the "#")
+        * @throws MWException
         * @return Title object
         */
-       public static function getTitleFor( $name, $subpage = false ) {
+       public static function getTitleFor( $name, $subpage = false, $fragment = '' ) {
                $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
                if ( $name ) {
-                       return Title::makeTitle( NS_SPECIAL, $name );
+                       return Title::makeTitle( NS_SPECIAL, $name, $fragment );
                } else {
                        throw new MWException( "Invalid special page name \"$name\"" );
                }
@@ -350,6 +352,7 @@ class SpecialPage {
         *
         * @param $fName String Name of called method
         * @param $a Array Arguments to the method
+        * @throws MWException
         * @deprecated since 1.17, call parent::__construct()
         */
        public function __call( $fName, $a ) {
@@ -511,6 +514,19 @@ class SpecialPage {
                return false;
        }
 
+       /**
+        * Is this page cached?
+        * Expensive pages are cached or disabled in miser mode.
+        * Used by QueryPage and subclasses, moved here so that
+        * Special:SpecialPages can safely call it for all special pages.
+        *
+        * @return Boolean
+        * @since 1.21
+        */
+       public function isCached() {
+               return false;
+       }
+
        /**
         * Can be overridden by subclasses with more complicated permissions
         * schemes.
@@ -519,9 +535,8 @@ class SpecialPage {
         *   pages?
         */
        public function isRestricted() {
-               global $wgGroupPermissions;
                // DWIM: If all anons can do something, then it is not restricted
-               return $this->mRestriction != '' && empty( $wgGroupPermissions['*'][$this->mRestriction] );
+               return $this->mRestriction != '' && !User::groupHasPermission( '*', $this->mRestriction );
        }
 
        /**
@@ -932,8 +947,8 @@ abstract class FormSpecialPage extends SpecialPage {
         * Called from execute() to check if the given user can perform this action.
         * Failures here must throw subclasses of ErrorPageError.
         * @param $user User
+        * @throws UserBlockedError
         * @return Bool true
-        * @throws ErrorPageError
         */
        protected function checkExecutePermissions( User $user ) {
                $this->checkPermissions();
@@ -1016,14 +1031,12 @@ abstract class RedirectSpecialPage extends UnlistedSpecialPage {
                if ( $redirect instanceof Title ) {
                        $url = $redirect->getFullUrl( $query );
                        $this->getOutput()->redirect( $url );
-                       wfProfileOut( __METHOD__ );
                        return $redirect;
                // Redirect to index.php with query parameters
                } elseif ( $redirect === true ) {
                        global $wgScript;
                        $url = $wgScript . '?' . wfArrayToCGI( $query );
                        $this->getOutput()->redirect( $url );
-                       wfProfileOut( __METHOD__ );
                        return $redirect;
                } else {
                        $class = __CLASS__;
@@ -1208,7 +1221,7 @@ abstract class RedirectSpecialArticle extends RedirectSpecialPage {
                        'ctype', 'maxage', 'smaxage',
                );
 
-               wfRunHooks( "RedirectSpecialArticleRedirectParams", array(&$redirectParams) );
+               wfRunHooks( "RedirectSpecialArticleRedirectParams", array( &$redirectParams ) );
                $this->mAllowedRedirectParams = $redirectParams;
        }
 }