Skip to content

Conversation

@kesselb
Copy link
Contributor

@kesselb kesselb commented Aug 29, 2025

Summary

Grouping in contacts is done by the categories property and therefore it's not ideal to translate it.
See nextcloud/contacts#4663 for additional context and steps to reproduce.

TODO

  • Review

Helper script to generate recent contacts

<?php

$pdo = new \PDO('pgsql:host=postgres;port=5432;dbname=server', 'postgres', 'postgres');
$pdo->beginTransaction();

$delete = $pdo->prepare("delete from oc_recent_contact where actor_uid = 'bob' and email ilike '%@example.org';");
$delete->execute();

$insert = $pdo->prepare('INSERT INTO oc_recent_contact (actor_uid, uid, email, federated_cloud_id, card, last_contact) VALUES (?,?,?,?,?,?)');
for ($i = 0; $i < 49000; $i++) {
	if ($i % 2 === 0) {
		$category = 'Zuletzt kontaktiert';
	} else {
		$category = 'Recently contacted';
	}

	$card = sprintf('BEGIN:VCARD
VERSION:4.0
PRODID:-//Blub Blub//EN
UID:recent-contact-%1$s
URI:recent-contact-%1$s
FN:test+%[email protected]
CATEGORIES:%2$s
EMAIL:test+%[email protected]
END:VCARD
', $i, $category);

	$insert->execute(['bob', null, 'test+' . $i . '@example.org', null, $card, time()]);
}

$pdo->commit();

Checklist

@github-actions
Copy link
Contributor

Possible performance regression detected

Show Output
An unhandled exception has been thrown:
TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/runner/work/server/server/apps/profiler/lib/Command/Compare.php:35
Stack trace:
#0 /home/runner/work/server/server/apps/profiler/lib/Command/Compare.php(35): array_map()
#1 /home/runner/work/server/server/3rdparty/symfony/console/Command/Command.php(326): OCAProfilerCommandCompare->execute()
#2 /home/runner/work/server/server/core/Command/Base.php(218): SymfonyComponentConsoleCommandCommand->run()
#3 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(1078): OCCoreCommandBase->run()
#4 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(324): SymfonyComponentConsoleApplication->doRunCommand()
#5 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(175): SymfonyComponentConsoleApplication->doRun()
#6 /home/runner/work/server/server/lib/private/Console/Application.php(187): SymfonyComponentConsoleApplication->run()
#7 /home/runner/work/server/server/console.php(91): OCConsoleApplication->run()
#8 /home/runner/work/server/server/occ(33): require_once('...')
#9 {main}

@kesselb kesselb force-pushed the bug/noid/update-vcard-categories branch from e948659 to 9ccae2f Compare September 10, 2025 13:41
@github-actions
Copy link
Contributor

Possible performance regression detected

Show Output
An unhandled exception has been thrown:
TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/runner/work/server/server/apps/profiler/lib/Command/Compare.php:35
Stack trace:
#0 /home/runner/work/server/server/apps/profiler/lib/Command/Compare.php(35): array_map()
#1 /home/runner/work/server/server/3rdparty/symfony/console/Command/Command.php(326): OCAProfilerCommandCompare->execute()
#2 /home/runner/work/server/server/core/Command/Base.php(218): SymfonyComponentConsoleCommandCommand->run()
#3 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(1078): OCCoreCommandBase->run()
#4 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(324): SymfonyComponentConsoleApplication->doRunCommand()
#5 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(175): SymfonyComponentConsoleApplication->doRun()
#6 /home/runner/work/server/server/lib/private/Console/Application.php(187): SymfonyComponentConsoleApplication->run()
#7 /home/runner/work/server/server/console.php(91): OCConsoleApplication->run()
#8 /home/runner/work/server/server/occ(33): require_once('...')
#9 {main}

1 similar comment
@github-actions
Copy link
Contributor

Possible performance regression detected

Show Output
An unhandled exception has been thrown:
TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/runner/work/server/server/apps/profiler/lib/Command/Compare.php:35
Stack trace:
#0 /home/runner/work/server/server/apps/profiler/lib/Command/Compare.php(35): array_map()
#1 /home/runner/work/server/server/3rdparty/symfony/console/Command/Command.php(326): OCAProfilerCommandCompare->execute()
#2 /home/runner/work/server/server/core/Command/Base.php(218): SymfonyComponentConsoleCommandCommand->run()
#3 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(1078): OCCoreCommandBase->run()
#4 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(324): SymfonyComponentConsoleApplication->doRunCommand()
#5 /home/runner/work/server/server/3rdparty/symfony/console/Application.php(175): SymfonyComponentConsoleApplication->doRun()
#6 /home/runner/work/server/server/lib/private/Console/Application.php(187): SymfonyComponentConsoleApplication->run()
#7 /home/runner/work/server/server/console.php(91): OCConsoleApplication->run()
#8 /home/runner/work/server/server/occ(33): require_once('...')
#9 {main}

@github-actions
Copy link
Contributor

Possible performance regression detected

Show Output
An unhandled exception has been thrown:
TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /home/runner/actions-runner/_work/server/server/apps/profiler/lib/Command/Compare.php:35
Stack trace:
#0 /home/runner/actions-runner/_work/server/server/apps/profiler/lib/Command/Compare.php(35): array_map()
#1 /home/runner/actions-runner/_work/server/server/3rdparty/symfony/console/Command/Command.php(326): OCAProfilerCommandCompare->execute()
#2 /home/runner/actions-runner/_work/server/server/core/Command/Base.php(218): SymfonyComponentConsoleCommandCommand->run()
#3 /home/runner/actions-runner/_work/server/server/3rdparty/symfony/console/Application.php(1078): OCCoreCommandBase->run()
#4 /home/runner/actions-runner/_work/server/server/3rdparty/symfony/console/Application.php(324): SymfonyComponentConsoleApplication->doRunCommand()
#5 /home/runner/actions-runner/_work/server/server/3rdparty/symfony/console/Application.php(175): SymfonyComponentConsoleApplication->doRun()
#6 /home/runner/actions-runner/_work/server/server/lib/private/Console/Application.php(187): SymfonyComponentConsoleApplication->run()
#7 /home/runner/actions-runner/_work/server/server/console.php(91): OCConsoleApplication->run()
#8 /home/runner/actions-runner/_work/server/server/occ(33): require_once('...')
#9 {main}

@kesselb kesselb added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Sep 10, 2025
@kesselb kesselb changed the title Bug/noid/update vcard categories fix: always use english name for recently contacted category Sep 10, 2025
@kesselb kesselb marked this pull request as ready for review September 10, 2025 14:13
@kesselb kesselb requested review from a team and SebastianKrupinski as code owners September 10, 2025 14:13
@kesselb kesselb requested review from ArtificialOwl, provokateurin and salmart-dev and removed request for a team September 10, 2025 14:13
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

👏 for a live migration without downtime
👏 for using a transaction for fast throughput

@kesselb
Copy link
Contributor Author

kesselb commented Sep 11, 2025

/backport to stable32

@kesselb
Copy link
Contributor Author

kesselb commented Sep 11, 2025

/backport to stable31

Comment on lines 120 to 121
'URI' => UUIDUtil::getUUID(),
'FN' => $this->getDisplayName($contact->getUid()) ?? $contact->getEmail() ?? $contact->getFederatedCloudId(),
'CATEGORIES' => $this->l10n->t('Recently contacted'),
'CATEGORIES' => 'Recently contacted',
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment here that this should not be translated. Otherwise someone finds it in the future and makes it translated again.

@kesselb kesselb added this to the Nextcloud 32 milestone Sep 12, 2025
Copy link
Contributor

@SebastianKrupinski SebastianKrupinski left a comment

Choose a reason for hiding this comment

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

Tested. Works.

My only comment was going to be that if this is a one time thing, we could just do a regex, string replacement, as the structure is generated by us and is very predicable.

UPDATE vcards
SET vcard_data = REGEXP_REPLACE(
    vcard_data,
    'CATEGORIES:[^\r\n]*',
    'CATEGORIES:Recent Contact'
)
WHERE vcard_data REGEXP 'CATEGORIES:';

But Sqlite does not support regex_replace, so that ideas is out

@kesselb kesselb force-pushed the bug/noid/update-vcard-categories branch from d531867 to 247861d Compare September 15, 2025 14:57
@kesselb kesselb merged commit 30fcdf2 into master Sep 16, 2025
216 of 225 checks passed
@kesselb kesselb deleted the bug/noid/update-vcard-categories branch September 16, 2025 14:09
@backportbot
Copy link

backportbot bot commented Sep 16, 2025

The backport to stable31 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable31
git pull origin stable31

# Create the new backport branch
git checkout -b backport/54736/stable31

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick 247861d2

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/54736/stable31

Error: Failed to push branch backport/54736/stable31: remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/nextcloud/server.git/'


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@kesselb
Copy link
Contributor Author

kesselb commented Sep 17, 2025

/backport to stable31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Contacts interactions integration: Translated category leads to weird state when a user changed the language

6 participants