You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix duplicate key collisions for form/field keys over 60 characters - #3622
Broken: a form or field key longer than 60 characters is cut to 60 before the numeric suffix is appended, but the list of existing similar keys was loaded for the full key. Copies already made from the truncated key (…2, …3) weren't in that list, so the second duplicate got …2 again and failed on the unique index (form), or the field was silently dropped (61–69 character field keys).
Changed:FrmAppHelper::get_unique_key() reloads the similar keys after truncating. The query is extracted into a private get_similar_keys() so it isn't written twice.
Verified:
New test_get_unique_key_increments_for_truncated_long_key failed before the fix (…2 returned where …3 expected) and passes after.
tests/phpunit/misc/test_FrmAppHelper.php: 51/51 green locally. Full Lite suite: 950 tests, 6 failures, all from view-transitions.min.css / wp-commands stylesheet files missing from the local WordPress checkout — unrelated to this change.
We reviewed changes in a0b9742...c4bf9c9 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.
AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.
Before/after run (PHPUnit, wp-env tests container, Lite master a0b9742 as base):
Base code + this PR's new test_get_unique_key_increments_for_truncated_long_key: fails. It returns …aaaa2 where …aaaa3 is expected, which is the duplicate-suffix collision from the bug report.
PR code, same test: passes. The full test_FrmAppHelper.php file is 51 tests, 2 failures (test_site_url, test_get_server_value). Both compare against example.org and get localhost:4013 from the harness host. They fail identically on base, so they are environment noise and unrelated to this change.
Code read:
get_unique_key() only reloads the similar-keys list when maybe_truncate_key_before_appending() actually changed the key, so keys of 60 characters or fewer take the same path and do the same single query as before.
The reload uses the truncated key, so …2, …3 copies are now in the list and the suffix loop skips them. The is_numeric → a branch is handled because the reload runs on the already-adjusted key.
get_similar_keys() is a straight extraction of the old query, no behavior change.
CI: Psalm is red, but every error I opened is MissingPureAnnotation on lines this PR doesn't touch, and master's own Psalm run is red too. Most other jobs were skipping at this head (no run tests/run analysis label), so PHPUnit was only run by me, above.
Not run: field-key (61–69 character) path live in the builder (same function, source-read only), code-review/security-review/simplify skills (46-line diff read in full instead), PHPStan/PHPCS.
The reason will be displayed to describe this comment to others. Learn more.
This looks good!
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
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.
Fixes Strategy11/formidable-pro#6902
Broken: a form or field key longer than 60 characters is cut to 60 before the numeric suffix is appended, but the list of existing similar keys was loaded for the full key. Copies already made from the truncated key (
…2,…3) weren't in that list, so the second duplicate got…2again and failed on the unique index (form), or the field was silently dropped (61–69 character field keys).Changed:
FrmAppHelper::get_unique_key()reloads the similar keys after truncating. The query is extracted into a privateget_similar_keys()so it isn't written twice.Verified:
test_get_unique_key_increments_for_truncated_long_keyfailed before the fix (…2returned where…3expected) and passes after.tests/phpunit/misc/test_FrmAppHelper.php: 51/51 green locally. Full Lite suite: 950 tests, 6 failures, all fromview-transitions.min.css/wp-commandsstylesheet files missing from the local WordPress checkout — unrelated to this change.🤖 Generated with Claude Code