Merge "Stop mangling $_GET and provide WebRequest::getQueryValuesOnly()"
[lhc/web/wiklou.git] / includes / user / User.php
index 91b9420..7068879 100644 (file)
@@ -110,12 +110,6 @@ class User implements IDBAccessObject, UserIdentity {
                'mActorId',
        ];
 
-       /**
-        * @var string[]
-        * @var string[] Cached results of getAllRights()
-        */
-       protected static $mAllRights = false;
-
        /** Cache variables */
        // @{
        /** @var int */
@@ -255,7 +249,8 @@ class User implements IDBAccessObject, UserIdentity {
                        return $this->$name;
                } else {
                        wfLogWarning( 'tried to get non-visible property' );
-                       return null;
+                       $null = null;
+                       return $null;
                }
        }
 
@@ -1758,6 +1753,7 @@ class User implements IDBAccessObject, UserIdentity {
                // overwriting mBlockedby, surely?
                $this->load();
 
+               // @phan-suppress-next-line PhanAccessMethodInternal It's the only allowed use
                $block = MediaWikiServices::getInstance()->getBlockManager()->getUserBlock(
                        $this,
                        $fromReplica
@@ -3597,32 +3593,30 @@ class User implements IDBAccessObject, UserIdentity {
        /**
         * Check if user is allowed to access a feature / make an action
         *
+        * @deprecated since 1.34, use MediaWikiServices::getInstance()
+        * ->getPermissionManager()->userHasAnyRights(...) instead
+        *
         * @param string $permissions,... Permissions to test
         * @return bool True if user is allowed to perform *any* of the given actions
+        * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
         */
        public function isAllowedAny() {
-               $permissions = func_get_args();
-               foreach ( $permissions as $permission ) {
-                       if ( $this->isAllowed( $permission ) ) {
-                               return true;
-                       }
-               }
-               return false;
+               return MediaWikiServices::getInstance()
+                       ->getPermissionManager()
+                       ->userHasAnyRight( $this, ...func_get_args() );
        }
 
        /**
-        *
+        * @deprecated since 1.34, use MediaWikiServices::getInstance()
+        * ->getPermissionManager()->userHasAllRights(...) instead
         * @param string $permissions,... Permissions to test
         * @return bool True if the user is allowed to perform *all* of the given actions
+        * @suppress PhanCommentParamOnEmptyParamList Cannot make variadic due to HHVM bug, T191668#5263929
         */
        public function isAllowedAll() {
-               $permissions = func_get_args();
-               foreach ( $permissions as $permission ) {
-                       if ( !$this->isAllowed( $permission ) ) {
-                               return false;
-                       }
-               }
-               return true;
+               return MediaWikiServices::getInstance()
+                       ->getPermissionManager()
+                       ->userHasAllRights( $this, ...func_get_args() );
        }
 
        /**
@@ -4868,8 +4862,7 @@ class User implements IDBAccessObject, UserIdentity {
        /**
         * Get a list of all available permissions.
         *
-        * @deprecated since 1.34, use MediaWikiServices::getInstance()->getPermissionManager()
-        *             ->getAllPermissions() instead
+        * @deprecated since 1.34, use PermissionManager::getAllPermissions() instead
         *
         * @return string[] Array of permission names
         */
@@ -5122,6 +5115,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @return bool
         */
        public function addNewUserLogEntryAutoCreate() {
+               wfDeprecated( __METHOD__, '1.27' );
                $this->addNewUserLogEntry( 'autocreate' );
 
                return true;
@@ -5347,7 +5341,9 @@ class User implements IDBAccessObject, UserIdentity {
                global $wgLang;
 
                $groups = [];
-               foreach ( self::getGroupsWithPermission( $permission ) as $group ) {
+               foreach ( MediaWikiServices::getInstance()
+                                         ->getPermissionManager()
+                                         ->getGroupsWithPermission( $permission ) as $group ) {
                        $groups[] = UserGroupMembership::getLink( $group, RequestContext::getMain(), 'wiki' );
                }