Repository navigation
Events Store: Scope table install check to the current database - #539
Merged
Merged
Conversation
is_installed() counted information_schema rows for the table name across every schema the DB user can see, and required exactly one. A same-named table in another database on the same server made the count 2, so the plugin never considered itself installed and re-ran the install on every request instead of handling cron. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
🟡 Changes recommended
The test can unconditionally drop a pre-existing database and disrupt parallel runs because it uses a fixed database name without confirming exclusive creation.
1 open issue
What changed in this PR
This PR scopes Events Store installation checks to the current database, preventing same-named tables in other databases from triggering repeated installation attempts and blocking event execution.
Changes:
- Adds a shared
table_exists()helper filtered byTABLE_SCHEMA = DATABASE()for both installation checks. - Adds a regression test with a same-named table in a second database.
| File | Description |
|---|---|
includes/class-events-store.php |
Centralizes table detection and limits it to the current database. |
__tests__/unit-tests/test-events-store.php |
Tests that a same-named table in another database does not affect installation detection. |
Review effort: Balanced
Create the second database with a per-run name and plain CREATE DATABASE, and drop it in finally, so the test only removes a database it created and parallel runs don't collide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sjinks
reviewed
Nov 12, 2026
sjinks
left a comment
Member
There was a problem hiding this comment.
Two issues in the new regression test affect isolation and whether it exercises the intended case.
CREATE DATABASE, CREATE TABLE and DROP DATABASE implicitly commit, which ended the test's transaction and made setUp() writes survive the rollback. Run them on a separate connection instead, and assert the same-named table was created so the test can't pass without the case it covers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sjinks
approved these changes
Nov 13, 2026
2 of 7 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.

Description
Events_Store::is_installed()countedinformation_schema.tablesrows for the table name across every schema the DB user can see, and required exactly one. When another database on the same server has a table with the same name, the count is 2, so the plugin never treats itself as installed: every runner command re-runs the install, exits with "Cron Control installation completed. Please try again.", and no events run. Both checks now use atable_exists()helper scoped toTABLE_SCHEMA = DATABASE(), which HyperDB still routes by table name.Steps to Test
test_is_installed_ignores_same_named_table_in_other_databasecreates the same table in a second database and expectsis_installed()to stay true. It fails without this change.🤖 Generated with Claude Code