wppaste
WordPress

WP_Site_Health::get_test_autoloaded_options(): array

Since
6.6.0
Source
wp-admin/includes/class-wp-site-health.php:2679
Tests the number of autoloaded options.

Compatibility

WordPress
since 6.6.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_autoloaded_options() 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

Only touches the object cache, via wp_cache_get().

Scaling
Constant

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

Instructions
51–110

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

Plugin surface
3 hooks

Third-party callbacks on 'site_status_autoloaded_options_size_limit', 'site_status_autoloaded_options_limit_description', 'site_status_autoloaded_options_action_to_perform' 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
  • cacheobject cachewp_cache_get()one call below WP_Site_Health::get_test_autoloaded_options()

Further down the call graph this can also reach option, serialize, query 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 · 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_autoloaded_options() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
$autoloaded_options_size51->get_autoloaded_options_size(), wp_load_alloptions(), __(), __(), __(), esc_html(), __(), size_format(), sprintf(), apply_filters()
!$autoloaded_options_size110->get_autoloaded_options_size(), wp_load_alloptions(), __(), __(), __(), esc_html(), __(), size_format(), sprintf(), apply_filters(), __(), esc_html(), __(), size_format(), sprintf(), apply_filters(), __(), esc_url(), __(), sprintf(), apply_filters()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 111 instructions, 51–110 executed per call, 1 branch. 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 · 3

3 hooks fire while WP_Site_Health::get_test_autoloaded_options() runs, in this order:

  1. apply_filters( site_status_autoloaded_options_size_limit )filterline 2709 (+30 into the body)

    Filters max bytes threshold to trigger warning in Site Health.

  2. apply_filters( site_status_autoloaded_options_limit_description )filterline 2731 (+52 into the body)

    Filters description to be shown on Site Health warning when threshold is met.

  3. apply_filters( site_status_autoloaded_options_action_to_perform )filterline 2747 (+68 into the body)

    Filters actionable information to tackle the problem. It can be a link to an external guide.

Uses · 7

Source code

	public function get_test_autoloaded_options() {		$autoloaded_options_size  = $this->get_autoloaded_options_size();		$autoloaded_options_count = count( wp_load_alloptions() ); 		$base_description = __( 'Autoloaded options are configuration settings for plugins and themes that are automatically loaded with every page load in WordPress. Having too many autoloaded options can slow down your site.' ); 		$result = array(			'label'       => __( 'Autoloaded options are acceptable' ),			'status'      => 'good',			'badge'       => array(				'label' => __( 'Performance' ),				'color' => 'blue',			),			'description' => sprintf(				/* translators: 1: Number of autoloaded options, 2: Autoloaded options size. */				'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which is acceptable.' ) . '</p>',				$autoloaded_options_count,				size_format( $autoloaded_options_size )			),			'actions'     => '',			'test'        => 'autoloaded_options',		); 		/**		 * Filters max bytes threshold to trigger warning in Site Health.		 *		 * @since 6.6.0		 *		 * @param int $limit Autoloaded options threshold size. Default 800000.		 */		$limit = apply_filters( 'site_status_autoloaded_options_size_limit', 800000 ); 		if ( $autoloaded_options_size < $limit ) {			return $result;		} 		$result['status']      = 'critical';		$result['label']       = __( 'Autoloaded options could affect performance' );		$result['description'] = sprintf(			/* translators: 1: Number of autoloaded options, 2: Autoloaded options size. */			'<p>' . esc_html( $base_description ) . ' ' . __( 'Your site has %1$s autoloaded options (size: %2$s) in the options table, which could cause your site to be slow. You can review the options being autoloaded in your database and remove any options that are no longer needed by your site.' ) . '</p>',			$autoloaded_options_count,			size_format( $autoloaded_options_size )		); 		/**		 * Filters description to be shown on Site Health warning when threshold is met.		 *		 * @since 6.6.0		 *		 * @param string $description Description message when autoloaded options bigger than threshold.		 */		$result['description'] = apply_filters( 'site_status_autoloaded_options_limit_description', $result['description'] ); 		$result['actions'] = sprintf(			/* translators: 1: HelpHub URL, 2: Link description. */			'<p><a target="_blank" href="%1$s">%2$s</a></p>',			esc_url( __( 'https://developer.wordpress.org/advanced-administration/performance/optimization/#autoloaded-options' ) ),			__( 'More info about optimizing autoloaded options' )		); 		/**		 * Filters actionable information to tackle the problem. It can be a link to an external guide.		 *		 * @since 6.6.0		 *		 * @param string $actions Call to Action to be used to point to the right direction to solve the issue.		 */		$result['actions'] = apply_filters( 'site_status_autoloaded_options_action_to_perform', $result['actions'] );		return $result;	}

Changelog

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