wppaste
WordPress

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
Invalidate the cache for .mo files.

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.
  • $typestring

    Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
  • $bulkbooldefault: true

    Whether the update process is a bulk update.
  • $pluginsarray

    Array of the basename paths of the plugins' main files.
  • $themesarray

    The theme slugs.
  • $translationsarray

    { Array of translations update data.
  • $languagestring

    The locale the translation is for.
  • $typestring

    Type of translation. Accepts 'plugin', 'theme', or 'core'.
  • $slugstring

    Text domain the translation is for. The slug of a theme/plugin or 'default' for core translations.
  • $versionstring

    The 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

Only touches the object cache, via wp_cache_delete().

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
5–24

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 61.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • cacheobject cachewp_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.

WhenInstructionsCalls it makes
always5–11none
isset($hook_extra)23–24wp_list_pluck(), array_unique()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev615–248
8.5615–248
8.4615–248
8.3615–248
8.2615–2481 more instruction than PHP 8.1
8.1605–248
7.4605–248

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

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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.