Skip to content

Clear the permission cache after adding Recent Topics permissions - #205

Merged
avandenberghe merged 1 commit into
develop33from
issue-194-clear-permission-cache
Oct 4, 2026
Merged

avandenberghe merged 1 commit into
develop33from
issue-194-clear-permission-cache

Conversation

@avandenberghe

Copy link
Copy Markdown
Collaborator

Closes #194.

Problem
rt_perms::add_permissions() adds the u_rt_* options, the ROLE_USER_FULL role data and the group grants with raw INSERTs. Unlike the migrator's permission tools, it never calls acl_clear_prefetch(). phpBB only rebuilds a user's cached user_permissions when that column is empty, so existing members kept a cached set without u_rt_view. After the extension was enabled, they saw no Recent Topics until something else happened to clear the cache.

Fix
At the end of add_permissions(), clear the cache the way core's v33x\remove_orphaned_roles migration does:

$auth = new \phpbb\auth\auth();
$auth->acl_clear_prefetch();

A migration has no injected $auth, and acl_clear_prefetch() works through globals.

Verification
add_permissions() builds its own auth, so a mock-based unit test can't observe the clear. Instead I ran the real migration step against the local board's database with a boot script: give a member a cached permission set, run add_permissions() from a given file, then measure user_permissions.

Code Member's cached permissions before → after
current develop33 866 bytes → 866 bytes (stale, the #194 bug)
this PR 866 bytes → 0 bytes (cleared)

After the clear, phpBB rebuilds the member's permissions with u_rt_view = 1.

The unit suite still passes (44 tests, 0 failures); the functional tests run in CI.

Note on existing installs: this fixes fresh enables. Boards that already enabled 3.0.11 have their cache cleared by any later cache purge or permission change, so they don't need a separate migration.

No changelog entry or version bump, per this repo's convention.

🤖 Generated with Claude Code

rt_perms::add_permissions() adds its options, role data and group
grants with raw INSERTs, which skip the acl_clear_prefetch() the
migrator's permission tools run. phpBB only rebuilds a user's cached
user_permissions when it is empty, so existing members kept a set
without u_rt_view and saw no Recent Topics after the extension was
enabled, until something else happened to clear the cache.

Clear it at the end of add_permissions(), the same way core's
remove_orphaned_roles migration does (no $auth is injected into a
migration).

Closes #194

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@avandenberghe
avandenberghe merged commit 82fce62 into develop33 Oct 4, 2026
28 checks passed
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.

Existing users get no Recent Topics after enabling the extension (u_rt_view not applied — stale permission cache)

1 participant