Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't fail date validation on PHP >= 8.2 #2030

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

makise-homura
Copy link
Contributor

As specified here, before PHP 8.2.0, DateTime::getLastErrors() did not return false when there were no warnings or errors. Instead, it would always return the documented array structure. But on PHP 8.2.0 and newer, it actually may be false, and using array_sum() on it shall cause an error like:

[2024-02-13 19:47:40] production.ERROR: array_sum(): Argument #1 ($array) must be of type array, false given {"userId":1,"exception":"[object] (TypeError(code: 0): array_sum(): Argument #1 ($array) must be of type array, false given at /opt/CDash/app/cdash/app/Controller/Api/ResultsApi.php:84)
[stacktrace]
#0 /opt/CDash/app/cdash/app/Controller/Api/ResultsApi.php(84): array_sum()
#1 /opt/CDash/app/cdash/app/Controller/Api/ResultsApi.php(153): CDash\\Controller\\Api\\ResultsApi->validateDateString()
...

And this leads to complete unusable build results pages except the one for current date.

This PR fixes it.

@makise-homura makise-homura force-pushed the datetime-php8.2 branch 7 times, most recently from dfa70fd to faa4d5e Compare February 14, 2024 19:25
@josephsnyder josephsnyder self-requested a review February 16, 2024 21:09
@codeling
Copy link

codeling commented Mar 3, 2024

This is the only fix required for running CDash 3.2.3/3.3.0 on PHP 8.2 as far as I can tell, thanks!
Considering that PHP 8.1 is already in "security fixes only" mode I would really love for this fix to be included in the next release!

Copy link
Member

@josephsnyder josephsnyder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I haven't been able to get the error to appear in the log as reported, this nicely accounts for the new return type. LGTM!

@josephsnyder josephsnyder added this pull request to the merge queue Mar 4, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 4, 2024
@williamjallen williamjallen added this pull request to the merge queue Mar 4, 2024
Merged via the queue into Kitware:master with commit 10611e0 Mar 4, 2024
2 checks passed
@makise-homura makise-homura deleted the datetime-php8.2 branch March 6, 2024 21:12
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.

4 participants