Merge "MessageCache: Remove $wgMsgCacheExpiry configuration var"
[lhc/web/wiklou.git] / includes / block / AbstractBlock.php
index d24a2a5..fcc624e 100644 (file)
@@ -23,6 +23,7 @@ namespace MediaWiki\Block;
 use IContextSource;
 use InvalidArgumentException;
 use IP;
+use MediaWiki\MediaWikiServices;
 use RequestContext;
 use Title;
 use User;
@@ -31,13 +32,22 @@ use User;
  * @since 1.34 Factored out from DatabaseBlock (previously Block).
  */
 abstract class AbstractBlock {
-       /** @var string */
+       /**
+        * @deprecated since 1.34. Use getReason and setReason instead.
+        * @var string
+        */
        public $mReason;
 
-       /** @var string */
+       /**
+        * @deprecated since 1.34. Use getTimestamp and setTimestamp instead.
+        * @var string
+        */
        public $mTimestamp;
 
-       /** @var string */
+       /**
+        * @deprecated since 1.34. Use getExpiry and setExpiry instead.
+        * @var string
+        */
        public $mExpiry = '';
 
        /** @var bool */
@@ -49,7 +59,10 @@ abstract class AbstractBlock {
        /** @var bool */
        protected $blockCreateAccount = false;
 
-       /** @var bool */
+       /**
+        * @deprecated since 1.34. Use getHideName and setHideName instead.
+        * @var bool
+        */
        public $mHideName = false;
 
        /** @var User|string */
@@ -83,6 +96,7 @@ abstract class AbstractBlock {
         *     reason string        Reason of the block
         *     timestamp string     The time at which the block comes into effect
         *     byText string        Username of the blocker (for foreign users)
+        *     hideName bool        Hide the target user name
         */
        public function __construct( array $options = [] ) {
                $defaults = [
@@ -91,6 +105,7 @@ abstract class AbstractBlock {
                        'reason'          => '',
                        'timestamp'       => '',
                        'byText'          => '',
+                       'hideName'        => false,
                ];
 
                $options += $defaults;
@@ -107,6 +122,7 @@ abstract class AbstractBlock {
 
                $this->setReason( $options['reason'] );
                $this->setTimestamp( wfTimestamp( TS_MW, $options['timestamp'] ) );
+               $this->setHideName( (bool)$options['hideName'] );
        }
 
        /**
@@ -267,8 +283,9 @@ abstract class AbstractBlock {
                if ( !$res && $blockDisablesLogin ) {
                        // If a block would disable login, then it should
                        // prevent any right that all users cannot do
+                       $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
                        $anon = new User;
-                       $res = $anon->isAllowed( $right ) ? $res : true;
+                       $res = $permissionManager->userHasRight( $anon, $right ) ? $res : true;
                }
 
                return $res;
@@ -327,8 +344,9 @@ abstract class AbstractBlock {
                if ( !$res && $blockDisablesLogin ) {
                        // If a block would disable login, then it should
                        // prevent any action that all users cannot do
+                       $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
                        $anon = new User;
-                       $res = $anon->isAllowed( $action ) ? $res : true;
+                       $res = $permissionManager->userHasRight( $anon, $action ) ? $res : true;
                }
 
                return $res;