Clear translation file cache after uninstall#178
Conversation
As of WP 6.5, the presence of .mo and .l10n.php files is cached.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a caching behavior introduced in WordPress 6.5, where the presence of translation files is cached. When language packs are uninstalled via WP-CLI, the system now explicitly clears this cache, preventing stale data and ensuring that subsequent requests correctly identify the absence of the uninstalled translations. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new clear_translation_files_cache method to ensure that WordPress translation files cache is properly cleared when language packs for core, plugins, or themes are uninstalled. A review comment suggests improving the cache clearing logic by replacing the function_exists check with Utils\wp_version_compare('6.5', '>=') for more explicit version-specific behavior.
|
Hello! 👋 Thanks for opening this pull request! Please check out our contributing guidelines. We appreciate you taking the initiative to contribute to this project. Contributing isn't limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation. Here are some useful Composer commands to get you started:
To run a single Behat test, you can use the following command: # Run all tests in a single file
composer behat features/some-feature.feature
# Run only a specific scenario (where 123 is the line number of the "Scenario:" title)
composer behat features/some-feature.feature:123You can find a list of all available Behat steps in our handbook. |
There was a problem hiding this comment.
Pull request overview
Adds cache invalidation for WordPress 6.5+ translation file discovery so that uninstalling language packs doesn’t leave stale .mo / .l10n.php presence cached in the object cache.
Changes:
- Introduces a shared helper to clear the
translation_filescache entry for a given directory. - Calls the helper after successful theme/plugin language pack uninstalls.
- Calls the helper after successful core language pack uninstalls.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/WP_CLI/CommandWithTranslation.php |
Adds clear_translation_files_cache() helper that deletes the translation_files cache entry for a directory. |
src/Theme_Language_Command.php |
Clears the translation-files cache after a successful theme language uninstall. |
src/Plugin_Language_Command.php |
Clears the translation-files cache after a successful plugin language uninstall. |
src/Core_Language_Command.php |
Clears the translation-files cache after a successful core language uninstall. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
As of WP 6.5, the presence of .mo and .l10n.php files is cached.