wppaste
WordPress

WP_Debug_Data::get_wp_media(): array<string,

Since
6.7.0
Source
wp-admin/includes/class-wp-debug-data.php:630
Gets the WordPress media section of the debug data.

Compatibility

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

Return value

array<string,
string|array> The media handling debug data.

Performance profile

How much work a call to WP_Debug_Data::get_wp_media() 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_get().

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
194–213

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

Plugin surface
None

Nothing here hands control to plugin code.

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 callbacksapply_filters()one call below WP_Debug_Data::get_wp_media()
  • cacheobject cachewp_cache_get()one call below WP_Debug_Data::get_wp_media()

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

What one call costs · 8 distinct outcomes

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

WhenInstructionsCalls it makes
!is_array($imagemagick_version) && empty($mappings) && !function_exists() && empty($gd_image_formats)194–202__(), __(), _wp_image_editor_choose(), __(), __(), __(), phpversion(), __(), __(), ini_get(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), __(), __(), __(), __(), size_format(), __(), _wp_image_editor_choose(), wp_get_image_editor_output_format(), __(), __(), function_exists(), __(), exec(), __(), __()
!is_array($imagemagick_version) && !empty($mappings) && !function_exists() && empty($gd_image_formats)195–202__(), __(), _wp_image_editor_choose(), __(), __(), __(), phpversion(), __(), __(), ini_get(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), __(), __(), __(), __(), size_format(), __(), _wp_image_editor_choose(), wp_get_image_editor_output_format(), __(), function_exists(), __(), exec(), __(), __()
!is_array($imagemagick_version) && empty($mappings) && function_exists() && empty($gd_image_formats)197–204__(), __(), _wp_image_editor_choose(), __(), __(), __(), phpversion(), __(), __(), ini_get(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), __(), __(), __(), __(), size_format(), __(), _wp_image_editor_choose(), wp_get_image_editor_output_format(), __(), __(), function_exists(), gd_info(), __(), exec(), __(), __()
!is_array($imagemagick_version) && !empty($mappings) && function_exists() && empty($gd_image_formats)198–205__(), __(), _wp_image_editor_choose(), __(), __(), __(), phpversion(), __(), __(), ini_get(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), __(), __(), __(), __(), size_format(), __(), _wp_image_editor_choose(), wp_get_image_editor_output_format(), __(), function_exists(), gd_info(), __(), exec(), __(), __()
!is_array($imagemagick_version) && empty($mappings) && !function_exists() && !empty($gd_image_formats)202–210__(), __(), _wp_image_editor_choose(), __(), __(), __(), phpversion(), __(), __(), ini_get(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), __(), __(), __(), __(), size_format(), __(), _wp_image_editor_choose(), wp_get_image_editor_output_format(), __(), __(), function_exists(), __(), __(), exec(), __(), __()
!is_array($imagemagick_version) && !empty($mappings) && !function_exists() && !empty($gd_image_formats)203–210__(), __(), _wp_image_editor_choose(), __(), __(), __(), phpversion(), __(), __(), ini_get(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), __(), __(), __(), __(), size_format(), __(), _wp_image_editor_choose(), wp_get_image_editor_output_format(), __(), function_exists(), __(), __(), exec(), __(), __()
!is_array($imagemagick_version) && empty($mappings) && function_exists() && !empty($gd_image_formats)205–212__(), __(), _wp_image_editor_choose(), __(), __(), __(), phpversion(), __(), __(), ini_get(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), __(), __(), __(), __(), size_format(), __(), _wp_image_editor_choose(), wp_get_image_editor_output_format(), __(), __(), function_exists(), gd_info(), __(), __(), exec(), __(), __()
!is_array($imagemagick_version) && !empty($mappings) && function_exists() && !empty($gd_image_formats)206–213__(), __(), _wp_image_editor_choose(), __(), __(), __(), phpversion(), __(), __(), ini_get(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), __(), __(), __(), __(), size_format(), __(), _wp_image_editor_choose(), wp_get_image_editor_output_format(), __(), function_exists(), gd_info(), __(), __(), exec(), __(), __()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev469192–2113718 fewer instructions than PHP 8.5
8.5487194–21337
8.4487194–2133721 fewer instructions than PHP 8.3
8.3508199–22437
8.2508199–224373 fewer instructions than PHP 8.1
8.1511202–227374 fewer instructions than PHP 7.4
7.4515202–22937

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 · 7

Used by · 1

Source code

	private static function get_wp_media(): array {		// Spare few function calls.		$not_available = __( 'Not available' ); 		// Populate the media fields.		$fields['image_editor'] = array(			'label' => __( 'Active editor' ),			'value' => _wp_image_editor_choose(),		); 		// Get ImageMagic information, if available.		if ( class_exists( 'Imagick' ) ) {			// Save the Imagick instance for later use.			$imagick             = new Imagick();			$imagemagick_version = $imagick->getVersion();		} else {			$imagemagick_version = __( 'Not available' );		} 		$fields['imagick_module_version'] = array(			'label' => __( 'ImageMagick version number' ),			'value' => ( is_array( $imagemagick_version ) ? $imagemagick_version['versionNumber'] : $imagemagick_version ),		); 		$fields['imagemagick_version'] = array(			'label' => __( 'ImageMagick version string' ),			'value' => ( is_array( $imagemagick_version ) ? $imagemagick_version['versionString'] : $imagemagick_version ),		); 		$imagick_version = phpversion( 'imagick' ); 		$fields['imagick_version'] = array(			'label' => __( 'Imagick version' ),			'value' => ( $imagick_version ) ? $imagick_version : __( 'Not available' ),		); 		// Get the PHP ini directive values.		$file_uploads        = ini_get( 'file_uploads' );		$post_max_size       = ini_get( 'post_max_size' );		$upload_max_filesize = ini_get( 'upload_max_filesize' );		$max_file_uploads    = ini_get( 'max_file_uploads' );		$effective           = min( wp_convert_hr_to_bytes( $post_max_size ), wp_convert_hr_to_bytes( $upload_max_filesize ) ); 		// Add info in Media section.		$fields['file_uploads']        = array(			'label' => __( 'File uploads' ),			'value' => $file_uploads ? __( 'Enabled' ) : __( 'Disabled' ),			'debug' => $file_uploads,		);		$fields['post_max_size']       = array(			'label' => __( 'Max size of post data allowed' ),			'value' => $post_max_size,		);		$fields['upload_max_filesize'] = array(			'label' => __( 'Max size of an uploaded file' ),			'value' => $upload_max_filesize,		);		$fields['max_effective_size']  = array(			'label' => __( 'Max effective file size' ),			'value' => size_format( $effective ),		);		$fields['max_file_uploads']    = array(			'label' => __( 'Max simultaneous file uploads' ),			'value' => $max_file_uploads,		); 		// If Imagick is used as our editor, provide some more information about its limitations.		if ( 'WP_Image_Editor_Imagick' === _wp_image_editor_choose() && isset( $imagick ) && $imagick instanceof Imagick ) {			$limits = array(				'area'   => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : $not_available ),				'disk'   => ( defined( 'imagick::RESOURCETYPE_DISK' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_DISK ) : $not_available ),				'file'   => ( defined( 'imagick::RESOURCETYPE_FILE' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_FILE ) : $not_available ),				'map'    => ( defined( 'imagick::RESOURCETYPE_MAP' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MAP ) ) : $not_available ),				'memory' => ( defined( 'imagick::RESOURCETYPE_MEMORY' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_MEMORY ) ) : $not_available ),				'thread' => ( defined( 'imagick::RESOURCETYPE_THREAD' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_THREAD ) : $not_available ),				'time'   => ( defined( 'imagick::RESOURCETYPE_TIME' ) ? $imagick->getResourceLimit( imagick::RESOURCETYPE_TIME ) : $not_available ),			); 			$limits_debug = array(				'imagick::RESOURCETYPE_AREA'   => ( defined( 'imagick::RESOURCETYPE_AREA' ) ? size_format( $imagick->getResourceLimit( imagick::RESOURCETYPE_AREA ) ) : 'not available' ),

Changelog

Introduced in 6.7.0. One change between 6.7.7 and 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.

7.0.4
Return type changed from array to array<string,.verified against source
6.7.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-admin/includes/class-wp-debug-data.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.