return (string)$this->getName();
}
- public function __get( $name ) {
+ public function &__get( $name ) {
// A shortcut for $mRights deprecation phase
if ( $name === 'mRights' ) {
- return $this->getRights();
+ $copy = $this->getRights();
+ return $copy;
+ } elseif ( !property_exists( $this, $name ) ) {
+ // T227688 - do not break $u->foo['bar'] = 1
+ wfLogWarning( 'tried to get non-existent property' );
+ $this->$name = null;
+ return $this->$name;
+ } else {
+ wfLogWarning( 'tried to get non-visible property' );
+ return null;
}
}
$this,
is_null( $value ) ? [] : $value
);
+ } elseif ( !property_exists( $this, $name ) ) {
+ $this->$name = $value;
+ } else {
+ wfLogWarning( 'tried to set non-visible property' );
}
}
if ( $mode === 'refresh' ) {
$cache->delete( $key, 1 ); // low tombstone/"hold-off" TTL
} else {
- $lb->getConnection( DB_MASTER )->onTransactionPreCommitOrIdle(
+ $lb->getConnectionRef( DB_MASTER )->onTransactionPreCommitOrIdle(
function () use ( $cache, $key ) {
$cache->delete( $key );
},
/**
* 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
*/
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
*/
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() );
}
/**