Skip to content

Fix flaky timezone test fixture (GH-18624)#21665

Closed
hakre wants to merge 1 commit intophp:PHP-8.4from
hakre:patch-20028-8.3-ext-date
Closed

Fix flaky timezone test fixture (GH-18624)#21665
hakre wants to merge 1 commit intophp:PHP-8.4from
hakre:patch-20028-8.3-ext-date

Conversation

@hakre
Copy link
Copy Markdown
Contributor

@hakre hakre commented Apr 7, 2026

As documented in RunningTests, tests have to be written to be independent of any php.ini file.

Without specifying the timezone, the var_dump() will make use of the default timezone that may not be the expected "UTC" timezone.

This renders the test-cases flaky and will make them fail if the date.timezone is different from the string "UTC".

Fix is to interpolate the timezone in the test fixture or to set date.timezone to UTC.

fix-up-of: GH-18624

As documented in [RunningTests], tests have to be written to be
independent of any php.ini file.

Without specifying the timezone, the var_dump() will make use of the
default timezone that may not be the expected "UTC" timezone.

This renders the test-cases flaky and will make them fail if the
`date.timezone` is different from the string "UTC".

Fix is to interpolate the timezone in the test fixture or to set
`date.timezone` to `UTC`.

[RunningTests]: docs/source/miscellaneous/running-tests.rst
fix-up-of: phpGH-18624
@hakre
Copy link
Copy Markdown
Contributor Author

hakre commented Apr 7, 2026

@derickr This is the ext/date part from #20035, rebased. You had approved this previously – could you take another look? Thanks.

@iluuu1994
Copy link
Copy Markdown
Member

I see there's this:

php-src/run-tests.php

Lines 187 to 190 in d34c09f

// If timezone is not set, use UTC.
if (ini_get('date.timezone') == '') {
date_default_timezone_set('UTC');
}

But that's not effective for the processes spawned from run-tests.php. Maybe that should just be added to the $ini_overwrites array here:

$ini_overwrites = [

@hakre
Copy link
Copy Markdown
Contributor Author

hakre commented Apr 11, 2026

@iluuu1994 thank you for looking. hmm, I only now specifically about

https://github.com/php/php-src/blob/d34c09fd3294e2194d5034138ab9178df20552a9/run-tests.php#L275C10-L275C36

having a RFC vote for it's default value in run-tests.php (ref: "If fatal_error_backtraces defaults to 1, default value in run-tests.php" in https://wiki.php.net/rfc/error_backtraces_v2#proposed_voting_choices) for that value "0".

and thinking: instead of patching individual tests the $ini_overwrites is likely a better approach for automated testing. The docs could reflect that, too, because of them I was a bit under the impression this "needs" to be done on the individual test-case, but UTC for default test-output sounds reasonable to me - especially if individual test cases can override it again (I need to double-check that, which I could do on my box both happy and counter-check with the test-case here).

And while I just wanted to ask about the branch to PR against the change of $ini_overwrites, I'm seeing I've mixed it up here again for this patch which should be PHP-8.3. Fixing that now and then see how far I'm coming.

@hakre hakre changed the base branch from master to PHP-8.3 April 11, 2026 20:17
@iluuu1994
Copy link
Copy Markdown
Member

IMO, $ini_overwrites is the right fix. I think this should target 8.4. 8.3 is in security mode and while we do now backport test fixes to keep CI happy, this doesn't fall into that category.

@hakre hakre changed the base branch from PHP-8.3 to PHP-8.4 April 11, 2026 20:55
hakre added a commit to hakre/php-src that referenced this pull request Apr 11, 2026
add date.timezone=UTC to the INI overwrites in run-tests.php.

refs: php#21665
@hakre
Copy link
Copy Markdown
Contributor Author

hakre commented Apr 11, 2026

closing in favor of #21729

@hakre hakre closed this Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants