Merge "Make Special:ChangeContentModel field labels consistently use colons"
[lhc/web/wiklou.git] / includes / Title.php
index 281f75b..8c5bbdc 100644 (file)
@@ -1250,6 +1250,7 @@ class Title implements LinkTarget, IDBAccessObject {
         * @param int|int[] $namespaces,... The namespaces to check for
         * @return bool
         * @since 1.19
+        * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
         */
        public function inNamespaces( /* ... */ ) {
                $namespaces = func_get_args();
@@ -2499,6 +2500,7 @@ class Title implements LinkTarget, IDBAccessObject {
         * Determines if $user is unable to edit this page because it has been protected
         * by $wgNamespaceProtection.
         *
+        * @deprecated since 1.34 Don't use this function in new code.
         * @param User $user User object to check permissions
         * @return bool
         */
@@ -2506,8 +2508,9 @@ class Title implements LinkTarget, IDBAccessObject {
                global $wgNamespaceProtection;
 
                if ( isset( $wgNamespaceProtection[$this->mNamespace] ) ) {
+                       $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
                        foreach ( (array)$wgNamespaceProtection[$this->mNamespace] as $right ) {
-                               if ( $right != '' && !$user->isAllowed( $right ) ) {
+                               if ( !$permissionManager->userHasRight( $user, $right ) ) {
                                        return true;
                                }
                        }
@@ -3183,7 +3186,7 @@ class Title implements LinkTarget, IDBAccessObject {
        public static function capitalize( $text, $ns = NS_MAIN ) {
                $services = MediaWikiServices::getInstance();
                if ( $services->getNamespaceInfo()->isCapitalized( $ns ) ) {
-                       return MediaWikiServices::getInstance()->getContentLanguage()->ucfirst( $text );
+                       return $services->getContentLanguage()->ucfirst( $text );
                } else {
                        return $text;
                }
@@ -3461,7 +3464,7 @@ class Title implements LinkTarget, IDBAccessObject {
                        return [ [ 'badtitletext' ] ];
                }
 
-               $mp = new MovePage( $this, $nt );
+               $mp = MediaWikiServices::getInstance()->getMovePageFactory()->newMovePage( $this, $nt );
                $errors = $mp->isValidMove()->getErrorsArray();
                if ( $auth ) {
                        $errors = wfMergeErrorArrays(
@@ -3493,7 +3496,7 @@ class Title implements LinkTarget, IDBAccessObject {
 
                global $wgUser;
 
-               $mp = new MovePage( $this, $nt );
+               $mp = MediaWikiServices::getInstance()->getMovePageFactory()->newMovePage( $this, $nt );
                $method = $auth ? 'moveIfAllowed' : 'move';
                $status = $mp->$method( $wgUser, $reason, $createRedirect, $changeTags );
                if ( $status->isOK() ) {