Repository navigation
Fixed preserve unloaded post taxonomy selections - #1387
Conversation
|
Plugin build for e5381d9 is ready 🛎️!
Note You can preview the changes in the Playground |
There was a problem hiding this comment.
🟡 Changes requested
Fix the stale taxonomy response path. An older response can enable the new flag, and the save then deletes the saved Post Taxonomy.
Validation details
- Files reviewed: 4/4 changed files.
- PHPUnit A/B run on WordPress 7.1.4 with PHP 8.3: both new tests pass at HEAD. At base, the "keeps" test fails on its assertion and the "clears" test passes. No run record was printed; the log is in the sandbox.
- Real editor, Firefox and Chromium: a save without opening Map Content kept the terms. A save after a soft reload kept them too
cd /workspace/checks/R3 && cat > save-flow2.js <<'EOF' // R3 rerun: settled flag state after reload, flag state at submi…(run R25, exit 0). - Real editor, Chromium race: post type
post, optionsnone, flag posted, term deletedcd /workspace/checks/R4 && sed -i 's|^const wp = (c) => execSync('wp ${c} ${WP} 2>&1', { encoding: .utf8. }).trim();|con…(run R30, exit 0). - Security: the new read runs after the existing nonce and
edit_postchecks.
Untested areas
- The Pro plugin and external
feedzy_save_fieldslisteners are not in the checkout. - Clearing every term in the browser was not run. The server side is covered by a PHPUnit test.
- The variant pass did not settle these places, where the fixed cause may still reach:
includes/admin/feedzy-rss-feeds-import.php:1429— unverified: Empty or truncated taxonomy responses can enable the loaded flag without restoring saved selections. Explore empty-taxonomy responses and saved terms beyond the 999 query limit, pa…
🤖 Automated review · run code-review-agent_6afafeccbbc751.76148677.
🤖 Review agent — review posted ✅ on 6a7e723f · changes requested · 2 findings · 39 min
Run code-review-agent_6afafeccbbc751.76148677 · trail
There was a problem hiding this comment.
🟡 Changes requested
The stale-response fix works, but a saved term beyond the 999-term limit is still deleted on save, and the loading-flag test gap remains open.
Validation details
- Files reviewed: 4/4 changed files. The commit since the last review changes the taxonomy script and the e2e spec.
- Playwright on WordPress 7.1.4, PHP 8.3, Chromium: the four new Post Taxonomy tests pass at HEAD (
4 passed (19.5s), sandbox run R11). - With the previous script, the superseded post type test fails (
1 failed, sandbox run R12). - With line 376 deleted, all four tests still pass (
4 passed (16.7s), sandbox run R13). - PHPUnit A/B from run code-review-agent_6afafeccbbc751.76148677 is reused, not rerun. The PHP files are unchanged since then.
Untested areas
- The save-handler request read was not re-audited. It is unchanged since the last review, which found it behind the nonce and capability checks.
- The Pro plugin and external
feedzy_save_fieldslisteners are not in the checkout. - An empty taxonomy response enables the flag. It can lose a term only if site code unlinks a taxonomy from the post type. No real setup was shown.
🤖 Automated review · run code-review-agent_6afbf98336fd54.87460832.
🤖 Review agent — review posted ✅ on df916193 · changes requested · 1 finding · 27 min
Run code-review-agent_6afbf98336fd54.87460832 · trail
There was a problem hiding this comment.
🟢 Approved
The PR passes. Both earlier findings are fixed, and the new tests fail when their fixes are removed.
Validation details
- Files reviewed: 6/6 changed files. The two commits since the last review change 5 of them.
- Playwright on WordPress, PHP 8.3 and Chromium runs all Post Taxonomy tests at HEAD:
cd /workspace/checks/R1 && export WP_BASE_URL=http://localhost:8080 WP_USERNAME=admin WP_PASSWORD=admin WP_ARTIFACTS_PAT…printed5 passed(run R3). - Without the line that disables the loaded flag, the loading test fails:
cd /workspace/checks/R1 && export WP_BASE_URL=http://localhost:8080 WP_USERNAME=admin WP_PASSWORD=admin WP_ARTIFACTS_PAT…printedReceived: enabled(run R4). - Without the new saved-term query, the term limit test fails:
cd /var/www/html && wp term delete category 6 2>&1|tail -1; wp term delete category 7 2>&1|tail -1; cd /workspace/checks…printed1 failed(run R20). - Two saved categories past a limit of 1 stay listed, selected and saved:
rm -rf /workspace/e2e-copy && mkdir -p /workspace/e2e-copy && cp -r /repo/tests/e2e/specs /repo/tests/e2e/utils.js /work…printed1 passed(run R26). - The security pass found the new
selectedinput behind the existing nonce and capability checks.
Untested areas
- A loaded save in Lite still drops saved terms of a taxonomy that the post type no longer has. An empty taxonomy list also enables clearing. Base code did the same. No common setup reaches it.
- The Pro plugin is not in the checkout.
- PHP CodeSniffer and the JavaScript build were left to CI.
- The variant pass did not settle these places, where the fixed cause may still reach:
includes/views/js/import-metabox-edit.js:481-487— unverified: An empty taxonomy response skips restoration of ordinary terms, Pro custom tags and both category markers, but enables clearing. This confirms the carried concern’s destructive bra…includes/views/import-metabox-edit.php:1073-1075— unverified: An empty taxonomy response skips restoration of ordinary terms, Pro custom tags and both category markers, but enables clearing. This confirms the carried concern’s destructive bra…includes/admin/feedzy-rss-feeds-import.php:726-727,756-778— unverified: An empty taxonomy response skips restoration of ordinary terms, Pro custom tags and both category markers, but enables clearing. This confirms the carried concern’s destructive bra…includes/admin/feedzy-rss-feeds-import.php:1431-1460— unverified: Lite restores only returned taxonomy terms; the unmatched-value fallback requires Pro. A saved term belonging to another post type can therefore disappear. Missing deciding evidenc…includes/views/js/import-metabox-edit.js:400-428,464-475— unverified: Lite restores only returned taxonomy terms; the unmatched-value fallback requires Pro. A saved term belonging to another post type can therefore disappear. Missing deciding evidenc…includes/views/js/import-metabox-edit.js:358-371— unverified: The carried limit concern now has an include-query backfill for every matching saved ID. Final coverage, especially several saved values, depends on X1’s assigned request-shape che…
🤖 Automated review · run code-review-agent_6afc05055aca29.39815405.
🤖 Review agent — review posted ✅ on 6306c1c0 · approved · 0 findings · 26 min
Run code-review-agent_6afc05055aca29.39815405 · trail
|
🎉 This PR is included in version 5.2.17 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Saving an existing import without opening Map Content deleted its saved Post Taxonomy selections (categories, custom taxonomy terms and the Auto Categories / Item Categories markers).
Root cause: The Post Taxonomy multiselect is rendered empty and only gets its options via AJAX (
update_taxonomy()) when Map Content is opened or the post type changes. An empty multiselect submits nothing, and since #1126 the save handler turned a missingimport_post_terminto''and deleted the meta. So any save made before the selector loaded wiped the stored terms. This also happened when saving while the terms were still loading, or after the AJAX request failed.Fix:
includes/views/import-metabox-edit.php: adds a disabled hidden input,feedzy_post_terms_loaded, next to the taxonomy selector.includes/views/js/import-metabox-edit.js:update_taxonomy()disables that input when it starts loading and enables it once the options are rendered.selected).includes/admin/feedzy-rss-feeds-import.php:save_feedzy_import_feed_meta()normalizes a missingimport_post_termto''only whenfeedzy_post_terms_loadedwas posted. Otherwise the saved value is left untouched.get_taxonomies()also returns saved terms that fall outside thefeedzy_post_taxonomy_limitcap (999 per taxonomy by default). They are listed with their names and stay selected, so opening Map Content and saving no longer drops them. Only<taxonomy>_<id>values for the requested post type's taxonomies are used.Deliberately clearing every term still works (#1126 behavior), because by then the selector has loaded and the flag is submitted. Abilities API / Pro import creation write the meta directly or always send the terms, so they are unaffected. Nonce and capability checks on the AJAX and save handlers are unchanged; the new
selectedinput is sanitized and only matching integer term IDs are used.Tests:
tests/test-import.php):test_save_keeps_post_terms_when_selector_not_loaded_1385: fails ondevelopment, passes with the fix.test_save_clears_post_terms_when_selector_loaded_1385: guards the feat: improve taxonomy setting UI #1126 clearing behavior.test_get_taxonomies_returns_saved_terms_past_limit: with the limit filtered to 1, a saved term past it is still returned with its name.tests/e2e/specs/import.spec.js, Post Taxonomy):tests/e2e/mu-plugins/feedzy-e2e-taxonomy-limit.php).Test instructions
Use Feedzy Lite with Pro active, so the Auto Categories option is available.
add_filter( 'feedzy_post_taxonomy_limit', fn() => 1 );(e.g. in a mu-plugin). Select a category that is not first alphabetically, save, reopen Map Content and save again. The category should still be listed and selected.Check before Pull Request is ready:
Closes #1385.