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

Argument #1 ($array) must be of type array, bool given #110

Closed
dominiquegerber opened this issue Mar 5, 2024 · 5 comments
Closed

Argument #1 ($array) must be of type array, bool given #110

dominiquegerber opened this issue Mar 5, 2024 · 5 comments

Comments

@dominiquegerber
Copy link
Contributor

dominiquegerber commented Mar 5, 2024

Please provide the following details.

  • Operating System: Linux
  • PHP Version: 8.2.15
  • php-mysql-replication Version: <7.0.1>
  • *mysql version (SELECT VERSION();): 10.3.39-MariaDB-0ubuntu0.20.04.2-log

Steps required to reproduce the problem.

Decoding of a date field.

Expected Result.

The decoded date field

Actual Result.

  • Argument new code #1 ($array) must be of type array, bool given in Event/RowEvent/RowEvent.php:718*

Analysis

The offending line in RowEvent.php :
if (array_sum(DateTime::getLastErrors()) > 0) {

which produces the (fatal) error

> array_sum expects its parameter to be an array
> DateTime::getLastErrors() on the other hand returns either an array, or a boolean (false).
> 

This is due to a change in the return type of DateTime::getLastErrors in PHP8.2 as indicated in the official documentation:
(https://www.php.net/manual/en/datetimeimmutable.getlasterrors.php) :

8.2.0 Before PHP 8.2.0, this function did not return false when there were no warnings or errors. Instead, it would always return the documented array structure.

I imagine that a simple cast to array should solve this issue, (array )false produces an empty array which would "array_sum" to 0.

@DZunke
Copy link
Contributor

DZunke commented Mar 12, 2024

I had this too, but it was fixed within the current version 8 of the library.

@dominiquegerber
Copy link
Contributor Author

Good to know thanks. Unfortunately version 8 of the lib requires to use symphony 7 as well, which we haven't migrated to yet. Ahh damn domino effect !

@DZunke
Copy link
Contributor

DZunke commented Mar 13, 2024

Yeah and i do not fully understand why the compatibility to Symfony 6 should not be there anymore 🤔 Maybe one should try it with symfony constraints to ^6.0|^7.0 in composer file and if it works open a PR to re-enable wider symfony version constraints.

@DZunke
Copy link
Contributor

DZunke commented Mar 13, 2024

Ok. I did it.

#113

Let's see if it gets merged.

@krowinski
Copy link
Owner

merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants