Skip to content

Commit 84332c9

Browse files
Site Health: Check if the directories are allowed when testing for a VCS checkout.
As part of determining whether to perform automatic updates, WordPress checks if it is running within a version-controlled environment, recursively looking up the filesystem to the top of the drive, looking for a Subversion, Git, Mercurial, or Bazaar directory, erring on the side of detecting a VCS checkout somewhere. This commit reuses `WP_Automatic_Updater::is_allowed_dir()` in the Site Health test to avoid a PHP warning if the `open_basedir` directive is in use and any of the directories checked in the process are not allowed: {{{ is_dir(): open_basedir restriction in effect. File(/.git) is not within the allowed path(s) }}} Follow-up to [44986], [55425]. Props Keffr3n, narenin. Fixes #61834. git-svn-id: https://develop.svn.wordpress.org/trunk@58921 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 04eec0c commit 84332c9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/wp-admin/includes/class-wp-site-health-auto-updates.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,18 @@ public function test_vcs_abspath() {
224224
}
225225

226226
$check_dirs = array_unique( $check_dirs );
227+
$updater = new WP_Automatic_Updater();
228+
$checkout = false;
227229

228230
// Search all directories we've found for evidence of version control.
229231
foreach ( $vcs_dirs as $vcs_dir ) {
230232
foreach ( $check_dirs as $check_dir ) {
231-
// phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments
232-
if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) {
233+
if ( ! $updater->is_allowed_dir( $check_dir ) ) {
234+
continue;
235+
}
236+
237+
$checkout = is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" );
238+
if ( $checkout ) {
233239
break 2;
234240
}
235241
}

0 commit comments

Comments
 (0)