WP_Debug_Data::get_wp_media(): array<string,
- Since
- 6.7.0
- Source
wp-admin/includes/class-wp-debug-data.php:630
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
- Scaling
- Scales with input
- Instructions
- 194–213
- Plugin surface
- None
- Called by
- 1
Only touches the object cache, via wp_cache_get().
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 487.
Nothing here hands control to plugin code.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()one call below WP_Debug_Data::get_wp_media() - cacheobject cache
wp_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.
| When | Instructions | Calls 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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 469 | 192–211 | 37 | 18 fewer instructions than PHP 8.5 |
| 8.5 | 487 | 194–213 | 37 | |
| 8.4 | 487 | 194–213 | 37 | 21 fewer instructions than PHP 8.3 |
| 8.3 | 508 | 199–224 | 37 | |
| 8.2 | 508 | 199–224 | 37 | 3 fewer instructions than PHP 8.1 |
| 8.1 | 511 | 202–227 | 37 | 4 fewer instructions than PHP 7.4 |
| 7.4 | 515 | 202–229 | 37 |
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
- __()Retrieves the translation of $text.
- _wp_image_editor_choose()Tests which editors are capable of supporting the request.
- wp_convert_hr_to_bytes()Converts a shorthand byte value to an integer byte value.
- size_format()Converts a number of bytes to the largest unit the bytes will fit into.
- wp_get_image_editor_output_format()Determines the output format for the image editor.
- Imagick::__construct()
- Imagick::queryFormats()
Used by · 1
- WP_Debug_Data::debug_data()Static function for generating site debug data when required.
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.
Signature, return type and hooks compared across 5 parsed releases.
array to array<string,.verified against sourceAbout 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.