Repository navigation
Rework tracking limits so they can't silently pause recommendations (on #93) - #95
Merged
Merged
Conversation
The tracking-limited flag paused unused-option recommendations site-wide and only a manual reset cleared it, yet it was set by routine events: a 1s lock timeout under concurrent traffic, any request reading over 1,000 options, or a transient SQL error. Legacy migrations over 10,000 names could never finish, and pruning deleted the oldest (core) rows. - Drop the GET_LOCK serialisation; the 10,000-name cap is now a soft limit checked without a lock. No MySQL-only lock functions or DELETE ... LIMIT. - Set the flag only when a new name is actually dropped for capacity, or one request reads more names than storage holds. Write failures don't set it. - Detect existing names with a SQL join, so case/accent variants of a stored row count as existing, matching the primary key's collation. - Migrate legacy data without the cap so migration always completes. - Never prune rows, and don't truncate reads at the limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wpdb parses the first FROM to check the table charset for non-ASCII queries; a leading subquery made every at-capacity write with a non-ASCII name fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write failures no longer pause recommendations, so the notice now names the only remaining cause: a full tracking table. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Test on Playground |
SQLite's case folding is ASCII-only, so vary only the ASCII letters; the name stays non-ASCII to keep exercising wpdb's charset check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #93, targeting its branch. Touches different code from #94, so both merge into #93 without conflicts. Checked with a local trial merge.
Problem in #93
A site-wide
tracking_limitedflag paused unused-option recommendations, and only a manual reset cleared it. Routine events set it:GET_LOCKtimeout, which every tracked request took at shutdown;Also: legacy migrations over 10,000 names could never finish; pruning deleted the oldest rows, which are core options; and the existing-name check compared case- and accent-insensitive DB results with exact PHP keys.
Reproduced on #93's head: one 3-second slow writer during 20 requests lost 8 requests' observations, set the flag permanently and added about 1s latency. With this PR: 20/20 recorded, no flag, no stall.
What changes
Verification
tests/hardening.php, with the tracking section rewritten for the new rules, passes on a disposable WP 7.1.4 / MySQL 8.0.33 site, as do PHPCS, PHPStan and lint.FROM, wpdb's charset check for non-ASCII queries ranSHOW FULL COLUMNS FROM SELECT. Every at-capacity write containing a non-ASCII name failed. Fixed in 1ea05ec, with a test.WP_MySQL_On_SQLitedriver, SQLite 3.54.1, WP 7.1.4): the fulltests/hardening.phppasses with no database errors printed.'1=1'forGET_LOCK, which Harden option actions, tracking, and release workflows #93 compares with'1'. With this PR, writes succeed and no flag is set.database is lockederrors.sitéurlthere is a different, unprotected option. Deleting it returns 404 and leavessiteurluntouched.🤖 Generated with Claude Code