Skip to content

Clean up data left behind by the old OpenID Connect Generic plugin - #224

Merged
cs1m0n merged 2 commits into
masterfrom
feature/openid-connect-generic-cleanup
Oct 12, 2026
Merged

cs1m0n merged 2 commits into
masterfrom
feature/openid-connect-generic-cleanup

Conversation

@cs1m0n

@cs1m0n cs1m0n commented Oct 9, 2026

Copy link
Copy Markdown
Member

"Delete subscribers" (Settings → BCC Login → Maintenance) only removed the capabilities row of each subscriber. The rest of their user meta stayed in the database, including the openid-connect-generic-* tokens and claims stored by the old OpenID Connect Generic plugin.

Changes

  • Delete subscribers now also removes:
    • the user meta of users that no longer exist
    • the openid-connect-generic-* user meta of the remaining users (e.g. admins and editors)
    • the old plugin's options and transients (openid_connect_generic_settings is kept, as it's still the fallback for the client ID and secret)
    • expired transients
  • New daily WP-Cron task (BCC_Login_Cleanup) that deletes any openid-connect-generic-* user meta. Activation hooks don't run on plugin updates, so it schedules itself on the first request that loads the new code. Sites are cleaned up after updating without anyone clicking the button, and again if the data comes back (e.g. from a restored backup). Deactivating the plugin unschedules it.

Notes for review

  • The orphaned-meta cleanup uses $wpdb->users / $wpdb->usermeta, so it also works on multisite subsites. The existing subscriber DELETE still uses the {$wpdb->prefix} tables, as before.
  • The success notice only lists counts for steps that succeeded. Failed steps get their own error notice.
  • The first run on a site with a lot of legacy data takes a second or two, in a WP-Cron request rather than a page load.
  • The build check fails on pull requests in this repo, because it tries to commit a release. Lint PHP - validate code is the relevant check.

Testing

On a throwaway WordPress 7.0.2 / PHP 7.4 install, starting from v1.2.9 with about 10,000 legacy rows:

  • After swapping in the new code, one front-page request scheduled the task and spawned WP-Cron, which deleted all legacy rows and left the other user meta untouched. The next run was scheduled 24 hours later.
  • Rows added again were removed on the next run. A blocked delete logged an error and was cleaned up on the following run.
  • 8 simultaneous first requests scheduled exactly one task. Deactivating removes it, reactivating brings it back, and uninstall runs without errors.
  • "Delete subscribers" on a single site, and on the main site and a subsite of a multisite network.
  • PHPStan with the CI config passes.

🤖 Generated with Claude Code

"Delete subscribers" only removed the capabilities row of each subscriber,
so their other user meta stayed in the database, including the
openid-connect-generic-* tokens and claims of the old plugin.

- The button now also removes the user meta of deleted users, the
  openid-connect-generic-* user meta of the remaining users, the old
  plugin's options and transients, and expired transients.
- A daily WP-Cron task deletes any openid-connect-generic-* user meta, so
  sites are cleaned up automatically once they update, and again if the
  data comes back (e.g. from a restored backup).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@cs1m0n
cs1m0n requested review from rvanoord and a balanced review from Copilot October 9, 2026 21:05
@cs1m0n cs1m0n self-assigned this Oct 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The cleanup has CSRF exposure, multisite deletion failures, inaccurate success reporting, and legacy logout compatibility risk.

2 open findings
What changed in this PR

Adds automated and manual cleanup of legacy OpenID Connect Generic data.

Changes:

  • Removes orphaned and legacy user metadata.
  • Deletes legacy options and expired transients.
  • Schedules daily cleanup and unschedules it on deactivation.
File Description
class-bcc-login-settings.php Expands maintenance cleanup and reporting.
class-bcc-login-cleanup.php Implements daily legacy-data cleanup.
bcc-login.php Registers cleanup and deactivation handling.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread plugins/bcc-login/includes/class-bcc-login-settings.php
Comment thread plugins/bcc-login/includes/class-bcc-login-cleanup.php
The handler ran whenever the referer contained delete_subscribers=true,
which a link or form on another site can set through _wp_http_referer.
An administrator opening such a link deleted all subscribers without
clicking anything. It now requires the form's nonce and an administrator.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@cs1m0n
cs1m0n merged commit 311e461 into master Oct 12, 2026
4 of 6 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.

2 participants