Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move admin_audit to proper event listeners v2 #47865

Merged
merged 8 commits into from
Sep 13, 2024

Conversation

come-nc
Copy link
Contributor

@come-nc come-nc commented Sep 10, 2024

See #32128

Summary

Rebased version of #37193
Part of original PR were already done in master so some commit endup a bit empty, but everything should work.

Does not fix all cases of deprecated mecanism but this is already a good improvement and as such it should be merged before it conflicts again.

Checklist

Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Psalm found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@come-nc come-nc changed the title Admin audit/enh/move to event listeners v2 Move admin_audit to proper event listeners v2 Sep 10, 2024
@come-nc come-nc self-assigned this Sep 10, 2024
@come-nc come-nc added this to the Nextcloud 31 milestone Sep 10, 2024
apps/admin_audit/lib/AppInfo/Application.php Fixed Show fixed Hide fixed
apps/admin_audit/lib/Listener/AppManagementEventListener.php Dismissed Show dismissed Hide dismissed
apps/admin_audit/lib/Listener/AuthEventListener.php Dismissed Show dismissed Hide dismissed
*/
class ConsoleEventListener extends Action implements IEventListener {
public function handle(Event $event): void {
if ($event instanceof ConsoleEvent) {

Check notice

Code scanning / Psalm

RedundantConditionGivenDocblockType Note

Docblock-defined type OCP\Console\ConsoleEvent for $event is always OCP\Console\ConsoleEvent
$this->passwordUpdated($event);
} elseif ($event instanceof UserIdAssignedEvent) {
$this->userIdAssigned($event);
} elseif ($event instanceof UserIdUnassignedEvent) {

Check notice

Code scanning / Psalm

RedundantConditionGivenDocblockType Note

Docblock-defined type OCP\User\Events\UserIdUnassignedEvent for $event is always OCP\User\Events\UserIdUnassignedEvent
} elseif (!$isUser) {
$this->dispatcher->dispatchTyped(new UserIdAssignedEvent($name));
if ($this->ncUserManager instanceof PublicEmitter) {
$this->ncUserManager->emit('\OC\User', 'assignedUserId', [$name]);

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OC\Hooks\PublicEmitter::emit has been marked as deprecated
$this->setInterval(
(int)\OC::$server->getConfig()->getAppValue(
(int)$this->config->getAppValue(

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::getAppValue has been marked as deprecated
$prefixes = $this->ldapHelper->getServerConfigurationPrefixes(true);
if (count($prefixes) === 0) {
return null;
}

$cycleData = [
'prefix' => $this->config->getAppValue('user_ldap', 'background_sync_prefix', null),
'prefix' => $this->config->getAppValue('user_ldap', 'background_sync_prefix', 'none'),

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::getAppValue has been marked as deprecated
$this->config->setAppValue('user_ldap', 'background_sync_prefix', $cycleData['prefix']);
$this->config->setAppValue('user_ldap', 'background_sync_offset', $cycleData['offset']);
$this->config->setAppValue('user_ldap', 'background_sync_offset', (string)$cycleData['offset']);

Check notice

Code scanning / Psalm

DeprecatedMethod Note

The method OCP\IConfig::setAppValue has been marked as deprecated
tcitworld and others added 5 commits September 10, 2024 14:05
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Based on work from #32019

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc force-pushed the admin_audit/enh/move-to-event-listeners-v2 branch from f52dda0 to ec37338 Compare September 10, 2024 12:06
@come-nc come-nc added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Sep 10, 2024
@come-nc come-nc marked this pull request as ready for review September 10, 2024 12:32
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc force-pushed the admin_audit/enh/move-to-event-listeners-v2 branch from 01f9bb4 to 957ac81 Compare September 10, 2024 12:48
@come-nc come-nc added the pending documentation This pull request needs an associated documentation update label Sep 10, 2024
apps/user_ldap/tests/AccessTest.php Show resolved Hide resolved
lib/public/User/Events/BeforeUserIdUnassignedEvent.php Outdated Show resolved Hide resolved
lib/public/User/Events/UserIdAssignedEvent.php Outdated Show resolved Hide resolved
lib/public/User/Events/UserIdUnassignedEvent.php Outdated Show resolved Hide resolved
lib/public/User/Events/UserIdAssignedEvent.php Outdated Show resolved Hide resolved
lib/public/User/Events/UserIdUnassignedEvent.php Outdated Show resolved Hide resolved
public function handle(Event $event): void {
if ($event instanceof TwoFactorProviderChallengePassed) {
$this->twoFactorProviderChallengePassed($event);
} elseif ($event instanceof TwoFactorProviderChallengeFailed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's safe to ignore the psalm warning.
If you want to get rid of it, add "Event" to template-implements.

lib/private/Preview/Generator.php Show resolved Hide resolved
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
@come-nc come-nc requested review from a team, icewind1991 and artonge and removed request for a team September 10, 2024 14:45
@come-nc come-nc requested a review from nfebe September 10, 2024 14:45
Copy link
Contributor

@miaulalala miaulalala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some nitpicks you could implement but don't have to. Otherwise LGTM.

Co-authored-by: Anna <anna@nextcloud.com>
Signed-off-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
@come-nc come-nc added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Sep 13, 2024
@come-nc come-nc enabled auto-merge September 13, 2024 14:08
@come-nc come-nc merged commit dfa994e into master Sep 13, 2024
174 checks passed
@come-nc come-nc deleted the admin_audit/enh/move-to-event-listeners-v2 branch September 13, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish pending documentation This pull request needs an associated documentation update technical debt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants