diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php index 804000bf2a754..673ed1be05b80 100644 --- a/core/Controller/AvatarController.php +++ b/core/Controller/AvatarController.php @@ -131,7 +131,7 @@ public function getAvatarDark(string $userId, int $size) { * * @return JSONResponse|FileDisplayResponse */ - public function getAvatar(string $userId, int $size, bool $darkTheme = false) { + public function getAvatar(string $userId, int $size) { if ($size <= 64) { if ($size !== 64) { $this->logger->debug('Avatar requested in deprecated size ' . $size); diff --git a/core/Controller/GuestAvatarController.php b/core/Controller/GuestAvatarController.php index 09146ff3928db..dc4f81bd643c3 100644 --- a/core/Controller/GuestAvatarController.php +++ b/core/Controller/GuestAvatarController.php @@ -60,9 +60,9 @@ public function __construct( * @param string $size The desired avatar size, e.g. 64 for 64x64px * @return FileDisplayResponse|Http\Response */ - public function getAvatar(string $guestName, string $size, ?bool $dark = false) { + public function getAvatar(string $guestName, string $size, ?bool $darkTheme = false) { $size = (int) $size; - $dark = $dark === null ? false : $dark; + $darkTheme = $darkTheme ?? false; if ($size <= 64) { if ($size !== 64) { @@ -78,7 +78,7 @@ public function getAvatar(string $guestName, string $size, ?bool $dark = false) try { $avatar = $this->avatarManager->getGuestAvatar($guestName); - $avatarFile = $avatar->getFile($size); + $avatarFile = $avatar->getFile($size, $darkTheme); $resp = new FileDisplayResponse( $avatarFile, diff --git a/lib/private/Avatar/Avatar.php b/lib/private/Avatar/Avatar.php index 1e6ebd7c61b81..9b9220936eb02 100644 --- a/lib/private/Avatar/Avatar.php +++ b/lib/private/Avatar/Avatar.php @@ -111,10 +111,10 @@ public function get(int $size = 64, bool $darkTheme = false) { * @return string * */ - protected function getAvatarVector(int $size, bool $dark): string { + protected function getAvatarVector(int $size, bool $darkTheme): string { $userDisplayName = $this->getDisplayName(); $fgRGB = $this->avatarBackgroundColor($userDisplayName); - $bgRGB = $fgRGB->alphaBlending(0.1, $dark ? new Color(0, 0, 0) : new Color(255, 255, 255)); + $bgRGB = $fgRGB->alphaBlending(0.1, $darkTheme ? new Color(0, 0, 0) : new Color(255, 255, 255)); $fill = sprintf("%02x%02x%02x", $bgRGB->red(), $bgRGB->green(), $bgRGB->blue()); $fgFill = sprintf("%02x%02x%02x", $fgRGB->red(), $fgRGB->green(), $fgRGB->blue()); $text = $this->getAvatarText(); @@ -125,13 +125,13 @@ protected function getAvatarVector(int $size, bool $dark): string { /** * Generate png avatar from svg with Imagick */ - protected function generateAvatarFromSvg(int $size, bool $dark): ?string { + protected function generateAvatarFromSvg(int $size, bool $darkTheme): ?string { if (!extension_loaded('imagick')) { return null; } try { $font = __DIR__ . '/../../../core/fonts/NotoSans-Regular.ttf'; - $svg = $this->getAvatarVector($size, $dark); + $svg = $this->getAvatarVector($size, $darkTheme); $avatar = new Imagick(); $avatar->setFont($font); $avatar->readImageBlob($svg); @@ -147,10 +147,10 @@ protected function generateAvatarFromSvg(int $size, bool $dark): ?string { /** * Generate png avatar with GD */ - protected function generateAvatar(string $userDisplayName, int $size, bool $dark): string { + protected function generateAvatar(string $userDisplayName, int $size, bool $darkTheme): string { $text = $this->getAvatarText(); $textColor = $this->avatarBackgroundColor($userDisplayName); - $backgroundColor = $textColor->alphaBlending(0.1, $dark ? new Color(0, 0, 0) : new Color(255, 255, 255)); + $backgroundColor = $textColor->alphaBlending(0.1, $darkTheme ? new Color(0, 0, 0) : new Color(255, 255, 255)); $im = imagecreatetruecolor($size, $size); $background = imagecolorallocate( diff --git a/lib/private/Repair/ClearGeneratedAvatarCache.php b/lib/private/Repair/ClearGeneratedAvatarCache.php index 314299a052817..b180dc31b3e4e 100644 --- a/lib/private/Repair/ClearGeneratedAvatarCache.php +++ b/lib/private/Repair/ClearGeneratedAvatarCache.php @@ -30,35 +30,29 @@ use OCP\Migration\IRepairStep; class ClearGeneratedAvatarCache implements IRepairStep { - - /** @var AvatarManager */ - protected $avatarManager; - - /** @var IConfig */ - private $config; + protected AvatarManager $avatarManager; + private IConfig $config; public function __construct(IConfig $config, AvatarManager $avatarManager) { $this->config = $config; $this->avatarManager = $avatarManager; } - public function getName() { + public function getName(): string { return 'Clear every generated avatar on major updates'; } /** * Check if this repair step should run - * - * @return boolean */ - private function shouldRun() { + private function shouldRun(): bool { $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0'); - // was added to 15.0.0.4 - return version_compare($versionFromBeforeUpdate, '15.0.0.4', '<='); + // was added to 25.0.0.8 + return version_compare($versionFromBeforeUpdate, '25.0.0.8', '<='); } - public function run(IOutput $output) { + public function run(IOutput $output): void { if ($this->shouldRun()) { try { $this->avatarManager->clearCachedAvatars();