Make WordPress Core

Changeset 56622


Ignore:
Timestamp:
09/19/2023 04:41:22 PM (12 months ago)
Author:
costdev
Message:

Build/Test Tools: Add sys_get_temp_dir() to open_basedir tests.

In PHPUnit 10.3.5, 9.6.13 and 8.5.34, the child processes used for process isolation now use temporary files to communicate their result to the parent process.

This caused a failure in some tests that set the open_basedir PHP directive to a value that did not include sys_get_temp_dir().

This adds sys_get_temp_dir() to the open_basedir value set by the tests to ensure that permission is still granted for the temporary directory.

PHPUnit uses sys_get_temp_dir(). To ensure the result is the same, Core's get_temp_dir() function is not used.

References:

Props desrosj, mukesh27, SergeyBiryukov, costdev.
Fixes #59394.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/admin/wpAutomaticUpdater.php

    r56559 r56622  
    611611        $open_basedir_backup = ini_get( 'open_basedir' );
    612612        // Allow access to the directory one level above the repository.
    613         ini_set( 'open_basedir', wp_normalize_path( $abspath_grandparent ) );
     613        ini_set( 'open_basedir', sys_get_temp_dir() . PATH_SEPARATOR . wp_normalize_path( $abspath_grandparent ) );
    614614
    615615        // Checking an allowed directory should succeed.
     
    646646        $open_basedir_backup = ini_get( 'open_basedir' );
    647647        // Allow access to the directory one level above the repository.
    648         ini_set( 'open_basedir', wp_normalize_path( $abspath_grandparent ) );
     648        ini_set( 'open_basedir', sys_get_temp_dir() . PATH_SEPARATOR . wp_normalize_path( $abspath_grandparent ) );
    649649
    650650        // Checking a directory not within the allowed path should trigger an `open_basedir` warning.
Note: See TracChangeset for help on using the changeset viewer.