Skip to content

[SITE-5390] Explicitly purge REST API term endpoints when draft posts are updated#357

Merged
AnaisPantheor merged 9 commits intodevelopfrom
testsFix
Dec 15, 2025
Merged

[SITE-5390] Explicitly purge REST API term endpoints when draft posts are updated#357
AnaisPantheor merged 9 commits intodevelopfrom
testsFix

Conversation

@AnaisPantheor
Copy link
Contributor

@AnaisPantheor AnaisPantheor commented Nov 28, 2025

WordPress Core introduced two optimizations (Tickets #63562 and #42522) on June 29 and July 25, 2025, to avoid unnecessary recalculations of term counts for non-public statuses like 'draft'. Now, it's skipping the call to clean_term_cache() when a draft post with terms is saved.

Tests started failing when updating draft posts with assigned categories or tags. The plugin was not purging term-related cache keys (rest-term-*) when non-published posts were modified.

The following errors:

  • test_update_post - missing rest-term-* keys
  • test_update_post_draft - missing rest-term-* keys
  • test_update_product - missing rest-term-* keys

See issue: #335

The plugin previously relied on WordPress Core to call clean_term_cache() when terms were updated, triggering the plugin's action_clean_term_cache() hook. Now we are doing it explicitly for both published and draft posts.

✅ Adding rest-term-* keys to purge_post_with_related() for published posts.

❓ Since tests were added in 2023, do we want to keep purging keys for draft posts or should we follow WordPress Core optimisation and also optimize our purging logic.

@AnaisPantheor AnaisPantheor changed the base branch from release to develop November 28, 2025 22:15
@github-actions
Copy link
Contributor

Composer Changes

Dev Packages Operation Base Target
dealerdirect/phpcodesniffer-composer-installer Upgraded v1.0.0 v1.1.2
fig-r/psr2r-sniffer Upgraded 1.5.1 2.2.1
myclabs/deep-copy Upgraded 1.12.0 1.13.0
nikic/php-parser Upgraded v5.1.0 v5.4.0
pantheon-systems/pantheon-wp-coding-standards Upgraded 2.0.3 3.0.1
pantheon-systems/wpunit-helpers Upgraded v2.0.2 v2.0.3
php-collective/code-sniffer New - 0.2.18
phpcompatibility/phpcompatibility-wp Upgraded 2.1.5 2.1.7
phpcsstandards/phpcsextra Upgraded 1.2.1 1.4.0
phpcsstandards/phpcsutils Upgraded 1.0.12 1.1.0
phpstan/phpdoc-parser Upgraded 1.29.1 2.2.0
phpunit/php-code-coverage Upgraded 9.2.31 9.2.32
phpunit/phpunit Upgraded 9.6.20 9.6.22
sirbrillig/phpcs-variable-analysis Upgraded v2.11.19 v2.12.0
slevomat/coding-standard Upgraded 8.15.0 8.19.1
squizlabs/php_codesniffer Upgraded 3.10.2 3.13.2
symfony/polyfill-ctype Upgraded v1.30.0 v1.31.0
yoast/phpunit-polyfills Upgraded 2.0.1 4.0.0
spryker/code-sniffer Removed 0.17.24 -

@AnaisPantheor AnaisPantheor changed the title [SITE-5390] Add fixes for failing tests [SITE-5390] Fix REST API Term Cache Invalidation for Post Updates Dec 1, 2025
@AnaisPantheor AnaisPantheor marked this pull request as ready for review December 1, 2025 20:06
@AnaisPantheor AnaisPantheor requested a review from a team as a code owner December 1, 2025 20:06
@AnaisPantheor AnaisPantheor changed the title [SITE-5390] Fix REST API Term Cache Invalidation for Post Updates [SITE-5390] Explicitly purge REST API term endpoints when draft posts are updated Dec 15, 2025
@AnaisPantheor AnaisPantheor merged commit e8e0c88 into develop Dec 15, 2025
15 checks passed
@AnaisPantheor AnaisPantheor deleted the testsFix branch December 15, 2025 21:16
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