Fix userid casting in notifications

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2019-06-11 09:52:04 +02:00 committed by Backportbot
parent f21b9c0df7
commit 9346718cc2
3 changed files with 7 additions and 5 deletions

View file

@ -1,4 +1,5 @@
<?php <?php
declare (strict_types = 1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *
@ -133,7 +134,7 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the app id is invalid * @throws \InvalidArgumentException if the app id is invalid
* @since 8.2.0 * @since 8.2.0
*/ */
public function setApp($app) { public function setApp(string $app) {
if (!is_string($app) || $app === '' || isset($app[32])) { if (!is_string($app) || $app === '' || isset($app[32])) {
throw new \InvalidArgumentException('The given app name is invalid'); throw new \InvalidArgumentException('The given app name is invalid');
} }
@ -155,7 +156,7 @@ class Notification implements INotification {
* @throws \InvalidArgumentException if the user id is invalid * @throws \InvalidArgumentException if the user id is invalid
* @since 8.2.0 * @since 8.2.0
*/ */
public function setUser($user) { public function setUser(string $user) {
if (!is_string($user) || $user === '' || isset($user[64])) { if (!is_string($user) || $user === '' || isset($user[64])) {
throw new \InvalidArgumentException('The given user id is invalid'); throw new \InvalidArgumentException('The given user id is invalid');
} }

View file

@ -196,7 +196,7 @@ class RemoveLinkShares implements IRepairStep {
$users = array_keys($this->userToNotify); $users = array_keys($this->userToNotify);
foreach ($users as $user) { foreach ($users as $user) {
$notification->setUser($user); $notification->setUser((string) $user);
$this->notificationManager->notify($notification); $this->notificationManager->notify($notification);
} }
} }

View file

@ -1,4 +1,5 @@
<?php <?php
declare (strict_types = 1);
/** /**
* @copyright Copyright (c) 2016, ownCloud, Inc. * @copyright Copyright (c) 2016, ownCloud, Inc.
* *
@ -36,7 +37,7 @@ interface INotification {
* @throws \InvalidArgumentException if the app id is invalid * @throws \InvalidArgumentException if the app id is invalid
* @since 9.0.0 * @since 9.0.0
*/ */
public function setApp($app); public function setApp(string $app);
/** /**
* @return string * @return string
@ -50,7 +51,7 @@ interface INotification {
* @throws \InvalidArgumentException if the user id is invalid * @throws \InvalidArgumentException if the user id is invalid
* @since 9.0.0 * @since 9.0.0
*/ */
public function setUser($user); public function setUser(string $user);
/** /**
* @return string * @return string