Repository navigation
Add a "Send site report now" button and keep the daily report going with an object cache - #231
Merged
Merged
Conversation
…n object cache The BCC Login settings page gets a Site report section under Maintenance, for administrators. Its button sends the report right away and shows what was sent or why it couldn't be sent, such as Auth0's error. It clears the last claim instead of claiming the next 12 hours, so the next daily report still goes out at its usual time. The 12-hour window is now claimed with SQL instead of WP_Upgrader::create_lock(). Re-creating an expired lock left the option cached as missing, so with a persistent object cache the daily report stopped after two days. INSERT IGNORE adds the first claim and a guarded UPDATE moves it forward. Both count a row only when they claim it, also on connections with MYSQLI_CLIENT_FOUND_ROWS. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues were identified in authorization, output escaping, delivery handling, or atomic report claims.
No open issues 🎉
What changed in this PR
Adds manual site reporting to BCC Login and fixes daily reporting on sites with persistent object caches.
Changes:
- Adds an administrator-only, nonce-protected button with escaped delivery results.
- Replaces upgrader locks with atomic SQL claims.
- Shares delivery logic between manual and daily reports.
| File | Description |
|---|---|
| plugins/bcc-login/includes/class-bcc-login-site-report.php | Adds manual reporting, shared delivery logic, and SQL-based claims. |
| plugins/bcc-login/includes/class-bcc-login-settings.php | Adds the maintenance hook for the reporting controls. |
Review effort: Balanced
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.
Changes
Send site report now (Settings → BCC Login → Maintenance → Site report) sends the report right away, however recently it was sent, and shows the result on the page:
It lets a site's administrators check its Auth0 setup without SSH or logs.
Fix: the daily report stopped after two days on sites with a persistent object cache (Redis, Memcached).
WP_Upgrader::create_lock()re-creates an expired lock by deleting the option and adding it again. The re-add leaves the option cached as missing, becauseadd_option()sees 0 changed rows and returns early. From then on,create_lock()finds no lock and gives up, every day.INSERT IGNOREadds the first claim, and anUPDATEthat only matches a claim at least 12 hours old moves it forward.MYSQLI_CLIENT_FOUND_ROWS. Of two runs at once, only one claims it.wp option delete bcc_login_site_report.lockstill works.Refactor: sending is split into
send()(daily),send_now()(the button) anddeliver()(shared by both). The daily report logs the same messages as before.Testing
In a throwaway WordPress 7.0.2 on PHP 7.4 and MariaDB 10.5, against a mock Auth0 and a mock API:
manage_optionswho isn't an administrator doesn't see it, and pressing does nothing for them.<script>in its description is shown escaped, and an API 401 is shown.MYSQLI_CLIENT_FOUND_ROWS. Failures are logged as before.PHPStan with the CI config passes, and
php -lpasses on PHP 7.4 and 8.4.🤖 Generated with Claude Code