Skip to content

Commit

Permalink
Fix since annotations and add boolean return type for setUserEnabled
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Jun 20, 2023
1 parent 367b4fe commit 1603cdc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion apps/user_ldap/lib/User_LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,8 @@ public function isUserEnabled(string $uid, callable $queryDatabaseValue): bool {
}
}

public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): void {
public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool {
$setDatabaseValue($enabled);
return $enabled;
}
}
4 changes: 2 additions & 2 deletions apps/user_ldap/lib/User_Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public function isUserEnabled(string $uid, callable $queryDatabaseValue): bool {
return $this->handleRequest($uid, 'isUserEnabled', [$uid, $queryDatabaseValue]);
}

public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): void {
$this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]);
public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool {
return $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]);
}
}
6 changes: 3 additions & 3 deletions lib/private/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public function isEnabled() {
$enabled = $this->config->getUserValue($this->uid, 'core', 'enabled', 'true');
$this->enabled = $enabled === 'true';
}
return (bool) $this->enabled;
return $this->enabled;
};
if ($this->backend instanceof IProvideEnabledStateBackend) {
return $this->backend->isUserEnabled($this->uid, $queryDatabaseValue);
Expand All @@ -464,9 +464,9 @@ public function setEnabled(bool $enabled = true) {
$enabled = $this->config->getUserValue($this->uid, 'core', 'enabled', 'true');
$this->enabled = $enabled === 'true';
}
return (bool) $this->enabled;
return $this->enabled;
};
$this->backend->setUserEnabled($this->uid, $enabled, $queryDatabaseValue, $setDatabaseValue);
$enabled = $this->backend->setUserEnabled($this->uid, $enabled, $queryDatabaseValue, $setDatabaseValue);
if ($oldStatus !== $enabled) {
$this->triggerChange('enabled', $enabled, $oldStatus);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/public/User/Backend/IProvideEnabledStateBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@
namespace OCP\User\Backend;

/**
* @since 26.0.0
* @since 28.0.0
*/
interface IProvideEnabledStateBackend {
/**
* @since 26.0.0
* @since 28.0.0
*
* @param callable():bool $queryDatabaseValue A callable to query the enabled state from database
*/
public function isUserEnabled(string $uid, callable $queryDatabaseValue): bool;

/**
* @since 26.0.0
* @since 28.0.0
*
* @param callable():bool $queryDatabaseValue A callable to query the enabled state from database
* @param callable(bool):void $setDatabaseValue A callable to set the enabled state in the database.
*/
public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): void;
public function setUserEnabled(string $uid, bool $enabled, callable $queryDatabaseValue, callable $setDatabaseValue): bool;
}

0 comments on commit 1603cdc

Please sign in to comment.