From cddaa30f95d9173c48e051a4d382982789aa0f25 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 21 Aug 2024 22:23:16 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@58921 git-svn-id: http://core.svn.wordpress.org/trunk@58317 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-site-health-auto-updates.php | 10 ++++++++-- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/class-wp-site-health-auto-updates.php b/wp-admin/includes/class-wp-site-health-auto-updates.php index 85decaaad2..581fc44600 100644 --- a/wp-admin/includes/class-wp-site-health-auto-updates.php +++ b/wp-admin/includes/class-wp-site-health-auto-updates.php @@ -224,12 +224,18 @@ class WP_Site_Health_Auto_Updates { } $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 ) { - // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition,Squiz.PHP.DisallowMultipleAssignments - if ( $checkout = @is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ) ) { + if ( ! $updater->is_allowed_dir( $check_dir ) ) { + continue; + } + + $checkout = is_dir( rtrim( $check_dir, '\\/' ) . "/$vcs_dir" ); + if ( $checkout ) { break 2; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index a4ec5965e9..28f00871ae 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-alpha-58920'; +$wp_version = '6.7-alpha-58921'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.