wppaste
WordPress

WP_Site_Health::get_test_php_extensions(): array

Since
5.2.0
Source
wp-admin/includes/class-wp-site-health.php:903
Tests if required PHP modules are installed on the host.

Description

This test builds on the recommendations made by the WordPress Hosting Team as seen at https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions

Compatibility

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

Performance profile

How much work a call to WP_Site_Health::get_test_php_extensions() 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
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

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

Instructions
59–83

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

Plugin surface
1 hook

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

Called by
0

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

What it touches

  • hookthird-party callbacksapply_filters()called directly

Further down the call graph this can also reach query, option, cache, 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 · 3 distinct outcomes

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

WhenInstructionsCalls it makes
always59–73__(), __(), __(), __(), __(), esc_url(), __(), sprintf(), apply_filters()
always72–78__(), __(), __(), __(), __(), esc_url(), __(), sprintf(), apply_filters(), __()
always77–83__(), __(), __(), __(), __(), esc_url(), __(), sprintf(), apply_filters(), __(), __()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev18359–8320
8.518359–8320
8.418359–83202 fewer instructions than PHP 8.3
8.318560–8420
8.218560–8420
8.118560–84204 fewer instructions than PHP 7.4
7.418960–8420

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 WP_Site_Health::get_test_php_extensions() runs, in this order:

  1. apply_filters( site_status_test_php_modules )filterline 1050 (+147 into the body)

    Filters the array representing all the modules we wish to test for.

Uses · 4

Source code

	public function get_test_php_extensions() {		$result = array(			'label'       => __( 'Required and recommended modules are installed' ),			'status'      => 'good',			'badge'       => array(				'label' => __( 'Performance' ),				'color' => 'blue',			),			'description' => sprintf(				'<p>%s</p><p>%s</p>',				__( 'PHP modules perform most of the tasks on the server that make your site run. Any changes to these must be made by your server administrator.' ),				sprintf(					/* translators: 1: Link to the hosting group page about recommended PHP modules. 2: Additional link attributes. 3: Accessibility text. */					__( 'The WordPress Hosting Team maintains a list of those modules, both recommended and required, in <a href="%1$s" %2$s>the team handbook%3$s</a>.' ),					/* translators: Localized team handbook, if one exists. */					esc_url( __( 'https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions' ) ),					'target="_blank"',					sprintf(						'<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',						/* translators: Hidden accessibility text. */						__( '(opens in a new tab)' )					)				)			),			'actions'     => '',			'test'        => 'php_extensions',		); 		$modules = array(			'curl'      => array(				'function' => 'curl_version',				'required' => false,			),			'dom'       => array(				'class'    => 'DOMNode',				'required' => false,			),			'exif'      => array(				'function' => 'exif_read_data',				'required' => false,			),			'fileinfo'  => array(				'function' => 'finfo_file',				'required' => false,			),			'hash'      => array(				'function' => 'hash',				'required' => true,			),			'imagick'   => array(				'extension' => 'imagick',				'required'  => false,			),			'json'      => array(				'function' => 'json_last_error',				'required' => true,			),			'mbstring'  => array(				'function' => 'mb_check_encoding',				'required' => false,			),			'mysqli'    => array(				'function' => 'mysqli_connect',				'required' => false,			),			'libsodium' => array(				'constant'            => 'SODIUM_LIBRARY_VERSION',				'required'            => false,				'php_bundled_version' => '7.2.0',			),			'openssl'   => array(				'function' => 'openssl_encrypt',				'required' => false,			),			'pcre'      => array(				'function' => 'preg_match',				'required' => false,			),			'mod_xml'   => array(				'extension' => 'libxml',

Changelog

Introduced in 5.2.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 6.9.7 tag, from src/wp-admin/includes/class-wp-site-health.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.