Skip to content

Commit c5497c6

Browse files
schlesseraclaude
andcommitted
Give the containers the host's PHP error settings
Test outcomes depend on how PHP reports errors. Without a php.ini, the containers reported E_ALL, which WP-CLI keeps while testing, whereas the CI runners report -1, which WP-CLI reduces to everything but deprecations. Scenarios running older WordPress versions on PHP 8 therefore failed in the containers on deprecation notices that the runners never print. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 325b181 commit c5497c6

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎utils/behat-parallel.php‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,21 @@ function wp_cli_tests_docker_mounts( $base_dir ) {
294294
}
295295
}
296296

297+
// Give the containers the PHP settings of the host for how errors are reported, as test
298+
// outcomes depend on them. WP-CLI, for example, only reports deprecations while testing
299+
// when error_reporting is exactly E_ALL, which a missing php.ini leads to, but not -1.
300+
$settings = [];
301+
foreach ( [ 'error_reporting', 'display_errors', 'display_startup_errors', 'log_errors', 'html_errors', 'zend.assertions', 'memory_limit', 'date.timezone' ] as $name ) {
302+
$value = ini_get( $name );
303+
// An empty value is a setting that is switched off, which has to be carried over as well.
304+
if ( false !== $value ) {
305+
$settings[] = $name . ' = ' . ( is_numeric( $value ) ? $value : '"' . addcslashes( $value, '"\\' ) . '"' );
306+
}
307+
}
308+
$ini = "{$base_dir}/php-host.ini";
309+
file_put_contents( $ini, implode( "\n", $settings ) . "\n" );
310+
$mounts[ $ini ] = '/usr/local/etc/php/conf.d/zz-wp-cli-tests-host.ini';
311+
297312
return $mounts;
298313
}
299314

0 commit comments

Comments
 (0)