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
28 changes: 28 additions & 0 deletions lib/Command/CirclesMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
use OCA\Circles\Service\FederatedUserService;
use OCA\Circles\Service\MaintenanceService;
use OCA\Circles\Service\OutputService;
use OCA\User_LDAP\Mapping\UserMapping;
use OCP\App\IAppManager;
use OCP\IDBConnection;
use OCP\Server;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -54,6 +57,7 @@ public function __construct(
private MaintenanceService $maintenanceService,
private OutputService $outputService,
private IDBConnection $dbConnection,
private IAppManager $appManager,
) {
parent::__construct();
}
Expand All @@ -65,6 +69,8 @@ protected function configure() {
->setDescription('Clean stuff, keeps the app running')
->addOption('refresh-display-name', '', InputOption::VALUE_REQUIRED, 'refresh single user display name', '')
->addOption('fix-saml-users-display-name', '', InputOption::VALUE_NONE, 'retrieve users from the db table \'user_saml_users\' to fix their display-name')
->addOption('fix-ldap-users-display-name', '',
InputOption::VALUE_NONE, 'retrieve users from the db table \'user_ldap_users\' to fix their display-name')
->addOption('level', '', InputOption::VALUE_REQUIRED, 'level of maintenance', '3')
->addOption(
'reset', '', InputOption::VALUE_NONE, 'reset Circles; remove all data related to the App'
Expand Down Expand Up @@ -95,6 +101,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

if ($input->getOption('fix-ldap-users-display-name')) {
if (!in_array('user_ldap', $this->appManager->getInstalledApps())) {
$output->writeln('The "user_ldap" app is not enabled');
return 1;
}
$this->fixLdapUsersDisplayName($output);
return 0;
}

$reset = $input->getOption('reset');
$uninstall = $input->getOption('uninstall');
$level = (int)$input->getOption('level');
Expand Down Expand Up @@ -190,4 +205,17 @@ public function fixSamlDisplayName(OutputInterface $output): void {
}
}
}

public function fixLdapUsersDisplayName(OutputInterface $output): void {
$ldapUserMapping = Server::get(UserMapping::class);
/** @var array<int, array{dn: string, name: string, uuid: string}> $list */
$list = $ldapUserMapping->getList();
foreach ($list as $user) {
try {
$this->refreshSingleDisplayName($user['name'], $output);
} catch (Exception $e) {
$output->writeln(get_class($e) . ' while trying to update display name of ' . $user['name']);
}
}
}
}
4 changes: 4 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
>
<stubs>
<file name="tests/stub.phpstub" preloadClasses="true"/>
<file name="tests/stubs/oc_server.php" />
<file name="tests/stubs/oc_servercontainer.php" />
<file name="tests/stubs/oca_user_ldap_mapping_abstractmapping.php" />
<file name="tests/stubs/oca_user_ldap_mapping_usermapping.php" />
</stubs>
<projectFiles>
<directory name="lib" />
Expand Down
38 changes: 8 additions & 30 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.26.1@d747f6500b38ac4f7dfc5edbcae6e4b637d7add0">
<files psalm-version="5.22.1@e9dad66e11274315dac27e08349c628c7d6a1a43">
<file src="lib/Activity/ProviderParser.php">
<TypeDoesNotContainType>
<code><![CDATA[str_starts_with($sK, '_')]]></code>
Expand Down Expand Up @@ -112,15 +112,6 @@
<code><![CDATA[CircleEventService]]></code>
</UndefinedDocblockClass>
</file>
<file src="lib/Migration/ImportOwncloudCustomGroups.php">
<MissingDependency>
<code><![CDATA[Share]]></code>
<code><![CDATA[Share]]></code>
</MissingDependency>
<UndefinedConstant>
<code><![CDATA[Share::SHARE_TYPE_CIRCLE]]></code>
</UndefinedConstant>
</file>
<file src="lib/Migration/Version0022Date20220526111723.php">
<UndefinedClass>
<code><![CDATA[Connection]]></code>
Expand Down Expand Up @@ -223,7 +214,7 @@
</file>
<file src="lib/Model/Mount.php">
<MissingDependency>
<code><![CDATA[OCA\Files_Sharing\External\Manager]]></code>
<code><![CDATA[CircleMountManager]]></code>
<code><![CDATA[CircleMountManager]]></code>
<code><![CDATA[CircleMountManager]]></code>
</MissingDependency>
Expand All @@ -235,8 +226,8 @@
</file>
<file src="lib/Model/ShareWrapper.php">
<InvalidArgument>
<code><![CDATA[$attributes]]></code>
<code><![CDATA[Cache::cacheEntryFromData($this->getFileCache()->toCache(), OC::$server->getMimeTypeLoader())]]></code>
<code><![CDATA[$this->setAttributes($attributes)]]></code>
</InvalidArgument>
<InvalidNullableReturnType>
<code><![CDATA[Circle]]></code>
Expand Down Expand Up @@ -272,19 +263,11 @@
<code><![CDATA[MoveableMount]]></code>
</UndefinedClass>
</file>
<file src="lib/MountManager/CircleMountManager.php">
<MissingDependency>
<code><![CDATA[OCA\Files_Sharing\External\Manager]]></code>
</MissingDependency>
</file>
<file src="lib/MountManager/CircleMountProvider.php">
<MissingDependency>
<code><![CDATA[CircleMount]]></code>
<code><![CDATA[CircleMountManager]]></code>
<code><![CDATA[private]]></code>
</MissingDependency>
<UndefinedClass>
<code><![CDATA[ExternalStorage]]></code>
</UndefinedClass>
</file>
<file src="lib/Service/ContactService.php">
<UndefinedClass>
Expand All @@ -296,11 +279,6 @@
<code><![CDATA[gObj]]></code>
</InvalidMethodCall>
</file>
<file src="lib/Service/FederatedUserService.php">
<InvalidReturnType occurrences="1">
<code>FederatedUser</code>
</InvalidReturnType>
</file>
<file src="lib/Service/GlobalScaleService.php">
<UndefinedClass>
<code><![CDATA[Signer]]></code>
Expand Down Expand Up @@ -403,15 +381,15 @@
</TooManyArguments>
</file>
<file src="lib/Tools/Traits/TNCLogger.php">
<UndefinedClass>
<code><![CDATA[HintException]]></code>
</UndefinedClass>
<RedundantCondition>
<code><![CDATA[$this->logger]]></code>
<code><![CDATA[isset($this->logger)]]></code>
</RedundantCondition>
<RedundantPropertyInitializationCheck>
<code><![CDATA[isset($this->logger)]]></code>
</RedundantPropertyInitializationCheck>
<UndefinedClass>
<code><![CDATA[HintException]]></code>
</UndefinedClass>
</file>
<file src="lib/Tools/Traits/TNCRequest.php">
<InvalidArgument>
Expand Down
Loading
Loading