Skip to content

Fix: Remove user memoization#2674

Merged
Koc merged 1 commit into
masterfrom
bugfix/fix-user-memoization
Jun 25, 2026
Merged

Fix: Remove user memoization#2674
Koc merged 1 commit into
masterfrom
bugfix/fix-user-memoization

Conversation

@Koc

@Koc Koc commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

User memoization in the Activity app causes incorrect activity notifications in edge cases, particularly when activities are generated about files changed by other users. This was observed in the Forms app.

Reproducer:

  1. Alice creates a form with submissions linked to file1.xlsx
  2. Bob creates a form with submissions linked to file2.xlsx
  3. Both forms are submitted quickly
  4. Wait for SyncSubmissionsWithLinkedFileJob to execute

Root cause:
The memoized user state persists across console commands and background jobs, even when the user context changes via:

$user = $this->userManager->get($ownerId);
$this->userSession->setUser($user);

Solution:
Remove user memoization at the Activity level since it's not needed and causes state leakage between different user contexts.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@Koc Koc force-pushed the bugfix/fix-user-memoization branch from 2bc0e8c to e5d2576 Compare June 22, 2026 21:55
@Koc Koc force-pushed the bugfix/fix-user-memoization branch 3 times, most recently from 00eb0dd to 105d42c Compare June 24, 2026 16:23
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
@Koc Koc force-pushed the bugfix/fix-user-memoization branch from 105d42c to 1673f42 Compare June 24, 2026 16:41
@Koc

Koc commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Psalm failures looks a bit unrelated... All other pipelines are green

@Koc Koc changed the title Remove user memoization Fix: Remove user memoization Jun 25, 2026
@Koc Koc merged commit 4d5a97b into master Jun 25, 2026
50 of 51 checks passed
@Koc Koc deleted the bugfix/fix-user-memoization branch June 25, 2026 15:23
@artonge

artonge commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Some were related @Koc :

Error: lib/CurrentUser.php:63:11: RedundantCast: Redundant cast to string (see https://psalm.dev/262)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants