Fix userid casting in notifications (#15912)

Fix userid casting in notifications
This commit is contained in:
John Molakvoæ 2019-06-11 18:30:42 +02:00 committed by GitHub
commit cf2d12340f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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