wppaste
WordPress

Language_Pack_Upgrader::bulk_upgrade( object[] $language_updates = array(), array $args = array() ): array|bool|WP_Error

Since
3.7.0
Source
wp-admin/includes/class-language-pack-upgrader.php:167
Upgrades several language packs at once.

Compatibility

WordPress
since 3.7.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

$language_updatesobject[]optional
Array of language packs to update. See wp_get_translation_updates().
Default empty array.Default: array()
$argsarrayoptional
Other arguments for upgrading multiple language packs. Default empty array.Default: array()
  • $clear_update_cachebooldefault: true

    Whether to clear the update cache when done.

Return value

array|bool|WP_Error
Will return an array of results, or true if there are no updates, false or WP_Error for initial errors.

Performance profile

How much work a call to Language_Pack_Upgrader::bulk_upgrade() 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
Heavy

Reads stored settings via get_site_transient(), cached per request but not free on a cold cache.

Scaling
Scales with input

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

Instructions
34–187

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

Plugin surface
1 hook

Third-party callbacks on 'upgrader_process_complete' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksdo_action()called directly
  • transienttransientget_site_transient()one call below Language_Pack_Upgrader::bulk_upgrade()

Further down the call graph this can also reach cache, option, serialize and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 42 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost Language_Pack_Upgrader::bulk_upgrade() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
empty($language_updates)34wp_parse_args(), ->init(), ->upgrade_strings(), ->header(), ->set_result(), ->feedback(), ->bulk_footer(), ->footer()
empty($language_updates)37wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), ->header(), ->set_result(), ->feedback(), ->bulk_footer(), ->footer()
!empty($language_updates)57wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->footer()
!empty($language_updates)60wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->footer()
!empty($language_updates)61wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->footer()
!empty($language_updates)64wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->footer()
!empty($language_updates) && !->exists() && !->mkdir()83wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->fs_connect()
!empty($language_updates) && !->exists() && !->mkdir()86wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->fs_connect()
!empty($language_updates) && !->exists() && !->mkdir()87wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->fs_connect()
!empty($language_updates) && !->exists() && !->mkdir()90wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->fs_connect()
!empty($language_updates) && ->exists() && !$parsed_args137–138wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && $parsed_args139–140wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
30 further outcomes, up to 187 instructions
!empty($language_updates) && ->exists() && !$parsed_args140–141wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && !$parsed_args141–142wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && $parsed_args142–143wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$parsed_args143–144wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && $parsed_args143–144wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && ->exists() && !$parsed_args144–145wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && !->exists() && ->mkdir() && $parsed_args145–146wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$parsed_args146–147wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && $parsed_args146–147wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$parsed_args147–148wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && !->exists() && ->mkdir() && $parsed_args148–149wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && $parsed_args149–150wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$parsed_args150–151wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && !->exists() && ->mkdir() && $parsed_args152–153wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && ->exists() && !$language_updates && $result === false && !$parsed_args170–172wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && !$language_updates && $result === false && $parsed_args172–174wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && ->exists() && !$language_updates && $result === false && !$parsed_args173–175wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && !$language_updates && $result === false && !$parsed_args174–176wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && !$language_updates && $result === false && $parsed_args175–177wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$language_updates && $result === false && !$parsed_args176–178wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && !$language_updates && $result === false && $parsed_args176–178wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && ->exists() && !$language_updates && $result === false && !$parsed_args177–179wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && !->exists() && ->mkdir() && !$language_updates && $result === false && $parsed_args178–180wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$language_updates && $result === false && !$parsed_args179–181wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && ->exists() && !$language_updates && $result === false && $parsed_args179–181wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$language_updates && $result === false && !$parsed_args180–182wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && !->exists() && ->mkdir() && !$language_updates && $result === false && $parsed_args181–183wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$language_updates && $result === false && $parsed_args182–184wp_parse_args(), ->init(), ->upgrade_strings(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()
!empty($language_updates) && !->exists() && ->mkdir() && !$language_updates && $result === false && !$parsed_args183–185wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer()
!empty($language_updates) && !->exists() && ->mkdir() && !$language_updates && $result === false && $parsed_args185–187wp_parse_args(), ->init(), ->upgrade_strings(), wp_get_translation_updates(), current_filter(), ->feedback(), remove_all_filters(), remove_all_filters(), remove_all_filters(), remove_all_filters(), ->header(), ->find_folder(), ->exists(), ->mkdir(), ->run(), remove_action(), remove_action(), remove_action(), remove_action(), update(), add_action(), add_action(), add_action(), add_action(), ->bulk_footer(), ->footer(), wp_clean_update_cache()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 233 instructions, 34–187 executed per call, 13 branches. The work does not change between versions.

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.

Hooks and filters fired · 1

One hook fires while Language_Pack_Upgrader::bulk_upgrade() runs, in this order:

  1. do_action( upgrader_process_complete )actionline 280 (+113 into the body)

    Fires when the upgrader process is complete.

Uses · 15

Show all 15

Used by · 1

Source code

	public function bulk_upgrade( $language_updates = array(), $args = array() ) {		global $wp_filesystem; 		$defaults    = array(			'clear_update_cache' => true,		);		$parsed_args = wp_parse_args( $args, $defaults ); 		$this->init();		$this->upgrade_strings(); 		if ( ! $language_updates ) {			$language_updates = wp_get_translation_updates();		} 		if ( empty( $language_updates ) ) {			$this->skin->header();			$this->skin->set_result( true );			$this->skin->feedback( 'up_to_date' );			$this->skin->bulk_footer();			$this->skin->footer();			return true;		} 		if ( 'upgrader_process_complete' === current_filter() ) {			$this->skin->feedback( 'starting_upgrade' );		} 		// Remove any existing upgrade filters from the plugin/theme upgraders #WP29425 & #WP29230.		remove_all_filters( 'upgrader_pre_install' );		remove_all_filters( 'upgrader_clear_destination' );		remove_all_filters( 'upgrader_post_install' );		remove_all_filters( 'upgrader_source_selection' ); 		add_filter( 'upgrader_source_selection', array( $this, 'check_package' ), 10, 2 ); 		$this->skin->header(); 		// Connect to the filesystem first.		$res = $this->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );		if ( ! $res ) {			$this->skin->footer();			return false;		} 		$results = array(); 		$this->update_count   = count( $language_updates );		$this->update_current = 0; 		/*		 * The filesystem's mkdir() is not recursive. Make sure WP_LANG_DIR exists,		 * as we then may need to create a /plugins or /themes directory inside of it.		 */		$remote_destination = $wp_filesystem->find_folder( WP_LANG_DIR );		if ( ! $wp_filesystem->exists( $remote_destination ) ) {			if ( ! $wp_filesystem->mkdir( $remote_destination, FS_CHMOD_DIR ) ) {				return new WP_Error( 'mkdir_failed_lang_dir', $this->strings['mkdir_failed'], $remote_destination );			}		} 		$language_updates_results = array(); 		foreach ( $language_updates as $language_update ) { 			$this->skin->language_update = $language_update; 			$destination = WP_LANG_DIR;			if ( 'plugin' === $language_update->type ) {				$destination .= '/plugins';			} elseif ( 'theme' === $language_update->type ) {				$destination .= '/themes';			} 			++$this->update_current; 			$options = array(				'package'                     => $language_update->package,				'destination'                 => $destination,				'clear_destination'           => true,

Changelog

Introduced in 3.7.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.0.4 tag, from src/wp-admin/includes/class-language-pack-upgrader.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.