Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Guests users can only access files shared to them and cannot create any files ou
<repair-steps>
<post-migration>
<step>OCA\Guests\Migration\OwncloudGuestsMigration</step>
<step>OCA\Guests\Repair\ResetEmails</step>
</post-migration>
</repair-steps>
<commands>
Expand Down
38 changes: 38 additions & 0 deletions lib/Repair/ResetEmails.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Robin Appelman <[email protected]>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OCA\Guests\Repair;

use OCA\Guests\GuestManager;
use OCP\IConfig;
use OCP\IUserManager;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;

class ResetEmails implements IRepairStep {
public function __construct(
private readonly GuestManager $guestManager,
private readonly IUserManager $userManager,
private readonly IConfig $config,
) {
}

public function getName(): string {
return 'Reset the email of all guest accounts';
}

public function run(IOutput $output) {
foreach ($this->guestManager->listGuests() as $guestId) {
$guest = $this->userManager->get($guestId);
if (strtolower($guest->getSystemEMailAddress()) !== strtolower($guestId)) {
Copy link
Member

Choose a reason for hiding this comment

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

@icewind1991 psalm should have warned us about the potential null, no?
Is psalm even properly working?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I have it if I show infos

INFO: PossiblyNullArgument - lib/Repair/ResetEmails.php:35:19 - Argument 1 of strtolower cannot be null, possibly null value provided (see https://psalm.dev/078)
			if (strtolower($guest?->getSystemEMailAddress()) !== strtolower($guestId)) {


INFO: PossiblyNullArgument - lib/Repair/ResetEmails.php:36:66 - Argument 4 of OCP\IConfig::setUserValue cannot be null, possibly null value provided (see https://psalm.dev/078)
				$this->config->setUserValue($guestId, 'guests', 'old_email', $guest->getSystemEMailAddress());


INFO: PossiblyNullReference - lib/Repair/ResetEmails.php:36:74 - Cannot call method getSystemEMailAddress on possibly null value (see https://psalm.dev/083)
				$this->config->setUserValue($guestId, 'guests', 'old_email', $guest->getSystemEMailAddress());

$this->config->setUserValue($guestId, 'guests', 'old_email', $guest->getSystemEMailAddress());
$guest->setSystemEMailAddress(strtolower($guestId));
}
}
}
}
Loading