From 33b6dcc97618fc3d0f94bdd3a60a9d5d3c776dfb Mon Sep 17 00:00:00 2001 From: Colin Stewart Date: Tue, 19 Sep 2023 17:13:35 +0000 Subject: [PATCH] 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: - https://github.com/sebastianbergmann/phpunit/issues/5356 Props desrosj, mukesh27, SergeyBiryukov, costdev. Merges [56622] to the 6.3 branch. See #59394. git-svn-id: https://develop.svn.wordpress.org/branches/6.3@56624 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/admin/wpAutomaticUpdater.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/admin/wpAutomaticUpdater.php b/tests/phpunit/tests/admin/wpAutomaticUpdater.php index eb91a97c09e5b..f53e9dbea36bf 100644 --- a/tests/phpunit/tests/admin/wpAutomaticUpdater.php +++ b/tests/phpunit/tests/admin/wpAutomaticUpdater.php @@ -610,7 +610,7 @@ public function test_is_allowed_dir_should_return_true_if_open_basedir_is_set_an $open_basedir_backup = ini_get( 'open_basedir' ); // Allow access to the directory one level above the repository. - ini_set( 'open_basedir', wp_normalize_path( $abspath_grandparent ) ); + ini_set( 'open_basedir', sys_get_temp_dir() . PATH_SEPARATOR . wp_normalize_path( $abspath_grandparent ) ); // Checking an allowed directory should succeed. $actual = self::$updater->is_allowed_dir( wp_normalize_path( ABSPATH ) ); @@ -645,7 +645,7 @@ public function test_is_allowed_dir_should_return_false_if_open_basedir_is_set_a $open_basedir_backup = ini_get( 'open_basedir' ); // Allow access to the directory one level above the repository. - ini_set( 'open_basedir', wp_normalize_path( $abspath_grandparent ) ); + ini_set( 'open_basedir', sys_get_temp_dir() . PATH_SEPARATOR . wp_normalize_path( $abspath_grandparent ) ); // Checking a directory not within the allowed path should trigger an `open_basedir` warning. $actual = self::$updater->is_allowed_dir( '/.git' );