From 323fee7cce3f09b2f14f9082f4d4de9c0e6ae9da Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Tue, 26 Jul 2011 19:27:14 +0000 Subject: [PATCH] Implement an accessor for User->mBlock. Doing this separately as it would be nice to backport this to 1.18 for the purposes of updating extensions for 1.19. --- includes/User.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/User.php b/includes/User.php index f353e09954..a160e93a0d 100644 --- a/includes/User.php +++ b/includes/User.php @@ -1524,8 +1524,18 @@ class User { * @return Bool True if blocked, false otherwise */ public function isBlocked( $bFromSlave = true ) { // hacked from false due to horrible probs on site + return $this->getBlock( $bFromSlave ) instanceof Block && $this->getBlock()->prevents( 'edit' ); + } + + /** + * Get the block affecting the user, or null if the user is not blocked + * + * @param $bFromSlave Bool Whether to check the slave database instead of the master + * @return Block|null + */ + public function getBlock( $bFromSlave = true ){ $this->getBlockedStatus( $bFromSlave ); - return $this->mBlock instanceof Block && $this->mBlock->prevents( 'edit' ); + return $this->mBlock instanceof Block ? $this->mBlock : null; } /** -- 2.20.1