WP_Textdomain_Registry::invalidate_mo_files_cache( WP_Upgrader $upgrader, array $hook_extra )
- Since
- 6.5.0
- Source
wp-includes/class-wp-textdomain-registry.php:252
Description
This function deletes the cache entries related to .mo files when triggered by specific actions, such as the completion of an upgrade process.
Compatibility
- WordPress
- since 6.5.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$upgraderWP_Upgrader- Unused. WP_Upgrader instance. In other contexts this might be a Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
$hook_extraarray- Array of bulk item update data.
$actionstringdefault: 'update'Type of action.$typestringType of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.$bulkbooldefault: trueWhether the update process is a bulk update.$pluginsarrayArray of the basename paths of the plugins' main files.$themesarrayThe theme slugs.$translationsarray{ Array of translations update data.$languagestringThe locale the translation is for.$typestringType of translation. Accepts 'plugin', 'theme', or 'core'.$slugstringText domain the translation is for. The slug of a theme/plugin or 'default' for core translations.$versionstringThe version of a theme, plugin, or core. }
Performance profile
How much work a call to WP_Textdomain_Registry::invalidate_mo_files_cache() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Moderate
- Scaling
- Scales with input
- Instructions
- 5–24
- Plugin surface
- None
- Called by
- 0
Only touches the object cache, via wp_cache_delete().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 61.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- cacheobject cache
wp_cache_delete()called directly
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Textdomain_Registry::invalidate_mo_files_cache() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 5–11 | none |
isset($hook_extra) | 23–24 | wp_list_pluck(), array_unique() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 61 | 5–24 | 8 | |
| 8.5 | 61 | 5–24 | 8 | |
| 8.4 | 61 | 5–24 | 8 | |
| 8.3 | 61 | 5–24 | 8 | |
| 8.2 | 61 | 5–24 | 8 | 1 more instruction than PHP 8.1 |
| 8.1 | 60 | 5–24 | 8 | |
| 7.4 | 60 | 5–24 | 8 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 2
- wp_list_pluck()Plucks a certain field out of each object or array in an array.
- wp_cache_delete()Removes the cache contents matching key and group.
Source code
public function invalidate_mo_files_cache( $upgrader, $hook_extra ) { if ( ! isset( $hook_extra['type'] ) || 'translation' !== $hook_extra['type'] || array() === $hook_extra['translations'] ) { return; } $translation_types = array_unique( wp_list_pluck( $hook_extra['translations'], 'type' ) ); foreach ( $translation_types as $type ) { switch ( $type ) { case 'plugin': wp_cache_delete( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' ); break; case 'theme': wp_cache_delete( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' ); break; default: wp_cache_delete( md5( WP_LANG_DIR . '/' ), 'translation_files' ); break; } } }Changelog
Introduced in 6.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-textdomain-registry.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.