Skip to content

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

Closed
@dominiquegerber

Description

@dominiquegerber

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions