wppaste
WordPress

WP_Site_Health::get_test_file_uploads(): array

Since
5.5.0
Source
wp-admin/includes/class-wp-site-health.php:2304
Tests if 'file_uploads' directive in PHP.ini is turned off.

Compatibility

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

Return value

array
The test results.

Performance profile

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

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
43–73

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

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 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_Site_Health::get_test_file_uploads() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always43__(), __(), __(), sprintf(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes()
always73__(), __(), __(), sprintf(), ini_get(), ini_get(), wp_convert_hr_to_bytes(), wp_convert_hr_to_bytes(), __(), sprintf(), wp_convert_hr_to_bytes(), __(), sprintf()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev8843–732
8.58843–732
8.48843–7323 fewer instructions than PHP 8.3
8.39144–752
8.29144–752
8.19144–752
7.49144–752

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 get_test_file_uploads() {		$result = array(			'label'       => __( 'Files can be uploaded' ),			'status'      => 'good',			'badge'       => array(				'label' => __( 'Performance' ),				'color' => 'blue',			),			'description' => sprintf(				'<p>%s</p>',				sprintf(					/* translators: 1: file_uploads, 2: php.ini */					__( 'The %1$s directive in %2$s determines if uploading files is allowed on your site.' ),					'<code>file_uploads</code>',					'<code>php.ini</code>'				)			),			'actions'     => '',			'test'        => 'file_uploads',		); 		if ( empty( ini_get( 'file_uploads' ) ) ) {			$result['status']       = 'critical';			$result['description'] .= sprintf(				'<p>%s</p>',				sprintf(					/* translators: 1: file_uploads, 2: 0 */					__( '%1$s is set to %2$s. You won\'t be able to upload files on your site.' ),					'<code>file_uploads</code>',					'<code>0</code>'				)			);			return $result;		} 		$post_max_size       = ini_get( 'post_max_size' );		$upload_max_filesize = ini_get( 'upload_max_filesize' ); 		if ( wp_convert_hr_to_bytes( $post_max_size ) < wp_convert_hr_to_bytes( $upload_max_filesize ) ) {			$result['label'] = sprintf(				/* translators: 1: post_max_size, 2: upload_max_filesize */				__( 'The "%1$s" value is smaller than "%2$s"' ),				'post_max_size',				'upload_max_filesize'			);			$result['status'] = 'recommended'; 			if ( 0 === wp_convert_hr_to_bytes( $post_max_size ) ) {				$result['description'] = sprintf(					'<p>%s</p>',					sprintf(						/* translators: 1: post_max_size, 2: upload_max_filesize */						__( 'The setting for %1$s is currently configured as 0, this could cause some problems when trying to upload files through plugin or theme features that rely on various upload methods. It is recommended to configure this setting to a fixed value, ideally matching the value of %2$s, as some upload methods read the value 0 as either unlimited, or disabled.' ),						'<code>post_max_size</code>',						'<code>upload_max_filesize</code>'					)				);			} else {				$result['description'] = sprintf(					'<p>%s</p>',					sprintf(						/* translators: 1: post_max_size, 2: upload_max_filesize */						__( 'The setting for %1$s is smaller than %2$s, this could cause some problems when trying to upload files.' ),						'<code>post_max_size</code>',						'<code>upload_max_filesize</code>'					)				);			} 			return $result;		} 		return $result;	}

Changelog

Introduced in 5.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-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.