WP_Site_Health_Auto_Updates::test_vcs_abspath(): array
- Since
- 5.2.0
- Source
wp-admin/includes/class-wp-site-health-auto-updates.php:216
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- The test results.
Performance profile
How much work a call to WP_Site_Health_Auto_Updates::test_vcs_abspath() 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
- Heavy
- Scaling
- Scales with input
- Instructions
- 22–60
- Plugin surface
- 1 hook
- Called by
- 1
Reads or writes the filesystem via is_dir().
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 94.
Third-party callbacks on 'automatic_updates_is_vcs_checkout' run inside this call, and their cost is not bounded by anything here.
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()called directly - filesystemfilesystem access
is_dir()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 · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Site_Health_Auto_Updates::test_vcs_abspath() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!is_dir() | 22–24 | array_unique(), __() |
apply_filters() | 30–32 | array_unique(), apply_filters(), __() |
is_dir() | 40–42 | array_unique(), apply_filters(), __(), sprintf() |
!$check_dirs && ->is_allowed_dir() | 41–42 | array_unique(), ->is_allowed_dir(), rtrim(), is_dir(), __() |
!$check_dirs && ->is_allowed_dir() && apply_filters() | 49–50 | array_unique(), ->is_allowed_dir(), rtrim(), is_dir(), apply_filters(), __() |
!$check_dirs && ->is_allowed_dir() && is_dir() | 59–60 | array_unique(), ->is_allowed_dir(), rtrim(), is_dir(), apply_filters(), __(), sprintf() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 94 | 22–60 | 13 | |
| 8.5 | 94 | 22–60 | 13 | |
| 8.4 | 94 | 22–60 | 13 | 4 fewer instructions than PHP 8.3 |
| 8.3 | 98 | 22–60 | 13 | |
| 8.2 | 98 | 22–60 | 13 | 1 more instruction than PHP 8.1 |
| 8.1 | 97 | 22–72 | 13 | |
| 7.4 | 97 | 22–72 | 13 |
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_Auto_Updates::test_vcs_abspath() runs, in this order:
- apply_filters( automatic_updates_is_vcs_checkout )filterline 254 (+38 into the body)
Filters whether the automatic updater should consider a filesystem location to be potentially managed by a version control system.
Uses · 3
- apply_filters()Calls the callback functions that have been added to a filter hook.
- __()Retrieves the translation of $text.
- WP_Automatic_Updater::__construct()
Used by · 1
- WP_Site_Health_Auto_Updates::run_tests()Runs tests to determine if auto-updates can run.
Source code
public function test_vcs_abspath() { $context_dirs = array( ABSPATH ); $vcs_dirs = array( '.svn', '.git', '.hg', '.bzr' ); $check_dirs = array(); foreach ( $context_dirs as $context_dir ) { // Walk up from $context_dir to the root. do { $check_dirs[] = $context_dir; // Once we've hit '/' or 'C:\', we need to stop. dirname will keep returning the input here. if ( dirname( $context_dir ) === $context_dir ) { break; } // Continue one level at a time. } while ( $context_dir = dirname( $context_dir ) ); } $check_dirs = array_unique( $check_dirs ); $updater = new WP_Automatic_Updater(); $checkout = false; // Search all directories we've found for evidence of version control. foreach ( $vcs_dirs as $vcs_dir ) { foreach ( $check_dirs as $check_dir ) { if ( ! $updater->is_allowed_dir( $check_dir ) ) { continue; } $checkout = is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ); if ( $checkout ) { break 2; } } } /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ if ( $checkout && ! apply_filters( 'automatic_updates_is_vcs_checkout', true, ABSPATH ) ) { return array( 'description' => sprintf( /* translators: 1: Folder name. 2: Version control directory. 3: Filter name. */ __( 'The folder %1$s was detected as being under version control (%2$s), but the %3$s filter is allowing updates.' ), '<code>' . $check_dir . '</code>', "<code>$vcs_dir</code>", '<code>automatic_updates_is_vcs_checkout</code>' ), 'severity' => 'info', ); } if ( $checkout ) { return array( 'description' => sprintf( /* translators: 1: Folder name. 2: Version control directory. */ __( 'The folder %1$s was detected as being under version control (%2$s).' ), '<code>' . $check_dir . '</code>', "<code>$vcs_dir</code>" ), 'severity' => 'warning', ); } return array( 'description' => __( 'No version control systems were detected.' ), 'severity' => 'pass', ); }Changelog
Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-admin/includes/class-wp-site-health-auto-updates.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.