Repository navigation
fix: use priority 11 for ensure_tokens_still_fresh init hook - #678
Merged
daggerhart merged 3 commits intoNov 17, 2026
Merged
daggerhart merged 3 commits into
daggerhart merged 3 commits into
Conversation
This hook is registered inside the plugin's own init callback, which runs at priority 10. WordPress does not enqueue callbacks added to a priority that is currently executing, so ensure_tokens_still_fresh was silently never called when token refresh was enabled. Using priority 11 means it lands in the next batch WordPress processes, after the current priority-10 queue drains. Fixes oidc-wp#675
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts the execution order of token refresh logic during WordPress initialization to run after default init handlers.
Changes:
- Sets an explicit
inithook priority forensure_tokens_still_fresh(priority11) when token refresh is enabled.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Per Copilot review: the magic number 11 is not obvious without context. Adds an inline comment clarifying that priority 11 ensures this runs after default-priority (10) init callbacks so session and auth state are fully initialised before token freshness is checked.
|
@daggerhart would be great if you could merge this! We need token refresh at CERN :) |
daggerhart
approved these changes
Nov 17, 2026
daggerhart
left a comment
Collaborator
There was a problem hiding this comment.
Looks great, thanks for the help!
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
ensure_tokens_still_freshwas registered as aninithook at the default priority 10. The problem is that this registration happens inside the plugin's owninitcallback, which also runs at priority 10. WordPress doesn't add callbacks to a priority that's currently executing — they're silently dropped. So token refresh was never called, even when enabled.Changing to priority 11 puts it in the next batch WordPress processes, after the priority-10 queue drains.
One argument added, no other changes.
Closes #675.
How to test the changes in this Pull Request:
request_new_tokensentry. Before this fix it would not appear.Other information:
Changelog entry
(full disclosure, I used AI help with the testing and tweaks - Christopher)