Make WordPress Core


Ignore:
Timestamp:
08/21/2024 10:21:54 PM (7 weeks ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-site-health-auto-updates.php

    r56695 r58921  
    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                }
Note: See TracChangeset for help on using the changeset viewer.