Merge pull request #23894 from nextcloud/backport/23799/stable20-minimal
[stable20] fix potentially passing null to events where IUser is expected
This commit is contained in:
commit
e30c80c490
|
@ -47,6 +47,7 @@ use OCP\EventDispatcher\IEventDispatcher;
|
||||||
use OCP\Group\Events\UserAddedEvent;
|
use OCP\Group\Events\UserAddedEvent;
|
||||||
use OCP\Group\Events\UserRemovedEvent;
|
use OCP\Group\Events\UserRemovedEvent;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
|
use OCP\IUser;
|
||||||
|
|
||||||
class UpdateGroups extends \OC\BackgroundJob\TimedJob {
|
class UpdateGroups extends \OC\BackgroundJob\TimedJob {
|
||||||
private static $groupsFromDB;
|
private static $groupsFromDB;
|
||||||
|
@ -116,7 +117,9 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob {
|
||||||
$groupObject = $groupManager->get($group);
|
$groupObject = $groupManager->get($group);
|
||||||
foreach (array_diff($knownUsers, $actualUsers) as $removedUser) {
|
foreach (array_diff($knownUsers, $actualUsers) as $removedUser) {
|
||||||
$userObject = $userManager->get($removedUser);
|
$userObject = $userManager->get($removedUser);
|
||||||
$dispatcher->dispatchTyped(new UserRemovedEvent($groupObject, $userObject));
|
if ($userObject instanceof IUser) {
|
||||||
|
$dispatcher->dispatchTyped(new UserRemovedEvent($groupObject, $userObject));
|
||||||
|
}
|
||||||
\OCP\Util::writeLog('user_ldap',
|
\OCP\Util::writeLog('user_ldap',
|
||||||
'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".',
|
'bgJ "updateGroups" – "'.$removedUser.'" removed from "'.$group.'".',
|
||||||
ILogger::INFO);
|
ILogger::INFO);
|
||||||
|
@ -124,7 +127,9 @@ class UpdateGroups extends \OC\BackgroundJob\TimedJob {
|
||||||
}
|
}
|
||||||
foreach (array_diff($actualUsers, $knownUsers) as $addedUser) {
|
foreach (array_diff($actualUsers, $knownUsers) as $addedUser) {
|
||||||
$userObject = $userManager->get($addedUser);
|
$userObject = $userManager->get($addedUser);
|
||||||
$dispatcher->dispatchTyped(new UserAddedEvent($groupObject, $userObject));
|
if ($userObject instanceof IUser) {
|
||||||
|
$dispatcher->dispatchTyped(new UserAddedEvent($groupObject, $userObject));
|
||||||
|
}
|
||||||
\OCP\Util::writeLog('user_ldap',
|
\OCP\Util::writeLog('user_ldap',
|
||||||
'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".',
|
'bgJ "updateGroups" – "'.$addedUser.'" added to "'.$group.'".',
|
||||||
ILogger::INFO);
|
ILogger::INFO);
|
||||||
|
|
Loading…
Reference in New Issue