refactor: Port away from search

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
Carl Schwan 2025-10-01 16:32:22 +02:00
parent 623b8e2ad8
commit ce02a5b27c
11 changed files with 14 additions and 65 deletions

View file

@ -2622,11 +2622,6 @@
<code><![CDATA[setAppValue]]></code>
</DeprecatedMethod>
</file>
<file src="core/BackgroundJobs/GenerateMetadataJob.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/App/ListApps.php">
<LessSpecificImplementedReturnType>
<code><![CDATA[array]]></code>
@ -2749,11 +2744,6 @@
<code><![CDATA[\OC_Util::tearDownFS()]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/Group/AddUser.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/Log/File.php">
<InvalidReturnStatement>
<code><![CDATA[[0]]]></code>
@ -2779,9 +2769,6 @@
</UndefinedInterfaceMethod>
</file>
<file src="core/Command/Preview/ResetRenderedTexts.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
<InvalidReturnStatement>
<code><![CDATA[[]]]></code>
</InvalidReturnStatement>
@ -2797,11 +2784,6 @@
<code><![CDATA[resetDelayForIP]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/TwoFactorAuth/Base.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/Upgrade.php">
<DeprecatedMethod>
<code><![CDATA[listen]]></code>
@ -2848,41 +2830,6 @@
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/User/Disable.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/User/Enable.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/User/Info.php">
<DeprecatedClass>
<code><![CDATA[\OC_Util::setupFS($user->getUID())]]></code>
<code><![CDATA[\OC_Util::tearDownFS()]]></code>
</DeprecatedClass>
<DeprecatedMethod>
<code><![CDATA[\OC_Util::tearDownFS()]]></code>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/User/LastSeen.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/User/Profile.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/User/ResetPassword.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>
</DeprecatedMethod>
</file>
<file src="core/Command/User/Setting.php">
<DeprecatedMethod>
<code><![CDATA[search]]></code>

View file

@ -48,7 +48,7 @@ class GenerateMetadataJob extends TimedJob {
$lastHandledUser = $this->appConfig->getValueString('core', 'metadataGenerationLastHandledUser', '');
$users = $this->userManager->search('');
$users = $this->userManager->searchDisplayName('');
// we'll only start timer once we have found a valid user to handle
// meaning NOW if we have not handled any user from a previous run

View file

@ -71,7 +71,7 @@ class AddUser extends Base {
}
$members = array_map(static fn (IUser $user) => $user->getUID(), $group->searchUsers($context->getCurrentWord()));
$users = array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
$users = array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->searchDisplayName($context->getCurrentWord()));
return array_diff($users, $members);
}
return [];

View file

@ -79,7 +79,7 @@ class ResetRenderedTexts extends Command {
}
private function getAvatarsToDelete(): \Iterator {
foreach ($this->userManager->search('') as $user) {
foreach ($this->userManager->searchDisplayName('') as $user) {
$avatar = $this->avatarManager->getAvatar($user->getUID());
if (!$avatar->isCustomAvatar()) {

View file

@ -40,7 +40,7 @@ class Base extends \OC\Core\Command\Base {
if ($argumentName === 'uid') {
return array_map(function (IUser $user) {
return $user->getUID();
}, $this->userManager->search($context->getCurrentWord(), 100));
}, $this->userManager->searchDisplayName($context->getCurrentWord(), 100));
}
return [];
}

View file

@ -55,7 +55,7 @@ class Disable extends Base {
return array_map(
static fn (IUser $user) => $user->getUID(),
array_filter(
$this->userManager->search($context->getCurrentWord()),
$this->userManager->searchDisplayName($context->getCurrentWord()),
static fn (IUser $user) => $user->isEnabled()
)
);

View file

@ -55,7 +55,7 @@ class Enable extends Base {
return array_map(
static fn (IUser $user) => $user->getUID(),
array_filter(
$this->userManager->search($context->getCurrentWord()),
$this->userManager->searchDisplayName($context->getCurrentWord()),
static fn (IUser $user) => !$user->isEnabled()
)
);

View file

@ -7,6 +7,7 @@
namespace OC\Core\Command\User;
use OC\Core\Command\Base;
use OC\Files\SetupManager;
use OCP\Files\NotFoundException;
use OCP\IGroupManager;
use OCP\IUser;
@ -21,6 +22,7 @@ class Info extends Base {
public function __construct(
protected IUserManager $userManager,
protected IGroupManager $groupManager,
protected SetupManager $setupManager,
) {
parent::__construct();
}
@ -82,8 +84,8 @@ class Info extends Base {
* @return array
*/
protected function getStorageInfo(IUser $user): array {
\OC_Util::tearDownFS();
\OC_Util::setupFS($user->getUID());
$this->setupManager->tearDown();
$this->setupManager->setupForUser($user);
try {
$storage = \OC_Helper::getStorageInfo('/');
} catch (NotFoundException $e) {
@ -105,7 +107,7 @@ class Info extends Base {
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'user') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->searchDisplayName($context->getCurrentWord()));
}
return [];
}

View file

@ -88,7 +88,7 @@ class LastSeen extends Base {
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'uid') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->searchDisplayName($context->getCurrentWord()));
}
return [];
}

View file

@ -215,7 +215,7 @@ class Profile extends Base {
*/
public function completeArgumentValues($argumentName, CompletionContext $context): array {
if ($argumentName === 'uid') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->searchDisplayName($context->getCurrentWord()));
}
if ($argumentName === 'key') {
$userId = $context->getWordAtIndex($context->getWordIndex() - 1);

View file

@ -122,7 +122,7 @@ class ResetPassword extends Base {
*/
public function completeArgumentValues($argumentName, CompletionContext $context) {
if ($argumentName === 'user') {
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->search($context->getCurrentWord()));
return array_map(static fn (IUser $user) => $user->getUID(), $this->userManager->searchDisplayName($context->getCurrentWord()));
}
return [];
}