-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce taxonomy-specific cache invalidation methods #8634
base: trunk
Are you sure you want to change the base?
Introduce taxonomy-specific cache invalidation methods #8634
Conversation
Revised caching logic by introducing `wp_cache_set_taxonomy_last_changed` and `wp_cache_get_taxonomy_last_changed` functions to track individual taxonomy changes. Updated related areas to leverage these methods for more granular cache management, improving efficiency and accuracy.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN:
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Added support for retrieving multiple taxonomy-related cache keys at once using `wp_cache_get_multiple`. This improves performance and ensures consistency when fetching last changed timestamps for taxonomies.
Corrected the placement of arguments in the array_map function to align with proper syntax. This resolves potential errors in generating cache keys for taxonomies.
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Updated `wp_cache_get_taxonomies_last_changed` to return a string instead of a float and added handling for empty taxonomy arrays. This ensures better consistency and prevents possible errors when no taxonomies are provided.
Adjusted assertions to reflect correct query count changes in getAdjacentPost tests and updated cache key usage in getTerms tests to ensure accuracy. These changes improve test reliability and align with the expected data structure.
Added a check to ensure the 'taxonomy' key exists in tax queries before accessing it. This prevents potential PHP notices or errors when the key is missing.
Replaced multiple individual cache calls with batch operations for better performance and maintainability. This change minimizes overhead when clearing taxonomy-related cache entries.
Ensure `wp_cache_get_taxonomy_last_changed()` handles empty taxonomy inputs by returning the default last changed value. Refine `wp_cache_get_taxonomies_last_changed()` to perform filtering only where input is used, improving efficiency.
Introduce new PHPUnit tests to verify proper cache invalidation behavior for terms and queries involving different taxonomies. These tests ensure term and query caches are refreshed or retained as expected, improving cache consistency validation.
Document the version for newly added or modified functions using @SInCE tags. This helps maintain clarity about when changes were introduced in the codebase.
This commit introduces PHPUnit tests for `wp_cache_get_taxonomy_last_changed` and `wp_cache_get_taxonomies_last_changed` functions. The tests ensure correct behavior for empty, single, and multiple taxonomy inputs, including duplicate handling.
Added unit tests to ensure that adding, updating, or deleting term metadata invalidates the term query cache correctly. These tests cover scenarios for `add_term_meta`, `update_term_meta`, and `delete_term_meta` to verify expected cache invalidation behavior.
Updated the assertion to reflect the expected number of queries increasing from 4 to 5, due to the inclusion of term data. This ensures the test correctly validates the query behavior after the change.
Refactors caching logic to account for changes in term meta data by appending a "last changed" timestamp. Additionally, simplifies `wp_cache_clear_term_meta()` to only adjust relevant cache keys, ensuring more accurate and efficient cache behavior.
Removed unused priority and argument count parameters from wp_cache_clear_term_meta callbacks for added, updated, and deleted term meta actions. This reduces unnecessary complexity and aligns with standard usage patterns.
Revised caching logic by introducing
wp_cache_set_taxonomy_last_changed
andwp_cache_get_taxonomy_last_changed
functions to track individual taxonomy changes. Updated related areas to leverage these methods for more granular cache management, improving efficiency and accuracy.Trac ticket:
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.