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
3 changes: 2 additions & 1 deletion lib/Db/FieldValueMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
use OCP\AppFramework\Db\QBMapper;
use OCP\IDBConnection;
use PDO;

/** @template-extends QBMapper<FieldValue> */
class FieldValueMapper extends QBMapper {
Expand Down Expand Up @@ -98,7 +99,7 @@ public function findDistinctUserUids(): array {
->orderBy('user_uid', 'ASC');

$cursor = $qb->executeQuery();
$userUids = $cursor->fetchFirstColumn();
$userUids = $cursor->fetchAll(PDO::FETCH_COLUMN);
$cursor->closeCursor();

return array_values(array_map(static fn (mixed $uid): string => (string)$uid, $userUids));
Expand Down
26 changes: 26 additions & 0 deletions tests/integration/features/api/repair.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Feature: orphaned profile field value repair
Background:
Given user "repairuser" exists
And run the command "profile_fields:developer:reset --all" with result code 0

Scenario: maintenance:repair removes values for deleted users without errors
Given as user "admin"
When sending "post" to ocs "/apps/profile_fields/api/v1/definitions"
| fieldKey | repair_test_field |
| label | Repair test |
| type | text |
| editPolicy | users |
| exposurePolicy | private |
| sortOrder | 10 |
| active | true |
Then the response should have a status code 201
And fetch field "(REPAIR_FIELD_ID)(jq).ocs.data.id" from previous JSON response
When sending "put" to ocs "/apps/profile_fields/api/v1/users/repairuser/values/<REPAIR_FIELD_ID>"
| value | orphaned |
Then the response should have a status code 200
And run the command "user:delete repairuser" with result code 0
And run the command "maintenance:repair" with result code 0
And the output of the last command should contain the following text:
"""
Repair orphaned profile field values
"""
Loading