Skip to content

Warning: array_sum(): Addition is not supported on type array #20

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

Open
kekstlt opened this issue Aug 1, 2024 · 1 comment
Open

Warning: array_sum(): Addition is not supported on type array #20

kekstlt opened this issue Aug 1, 2024 · 1 comment

Comments

@kekstlt
Copy link

kekstlt commented Aug 1, 2024

Problem with migration to PHP8.3

In RowEvent.php line 728:
                                                                 
  [ErrorException]                                               
  Warning: array_sum(): Addition is not supported on type array 

$dateLastErrors in this case is

array (
  'warning_count' => 1,
  'warnings' => 
  array (
    12 => 'The parsed date was invalid',
  ),
  'error_count' => 0,
  'errors' => 
  array (
  ),
)

So arrays now cant be summed with arrays

@kekstlt
Copy link
Author

kekstlt commented Aug 1, 2024

Patch

diff --git a/src/MySQLReplication/Event/RowEvent/RowEvent.php b/src/MySQLReplication/Event/RowEvent/RowEvent.php
index e20c6e9..607b387 100644
--- a/src/MySQLReplication/Event/RowEvent/RowEvent.php
+++ b/src/MySQLReplication/Event/RowEvent/RowEvent.php
@@ -683,7 +683,7 @@ class RowEvent extends EventCommon

         $date = DateTime::createFromFormat('YmdHis', $value)->format('Y-m-d H:i:s');
         $dateLastErrors = DateTime::getLastErrors();
-        if ($dateLastErrors && array_sum($dateLastErrors) > 0) {
+        if ($dateLastErrors && ($dateLastErrors['warning_count'] + $dateLastErrors['error_count']) > 0) {
             return null;
         }

@@ -725,7 +725,7 @@ class RowEvent extends EventCommon
             return null;
         }
         $dateLastErrors = DateTime::getLastErrors();
-        if ($dateLastErrors && array_sum($dateLastErrors) > 0) {
+        if ($dateLastErrors && ($dateLastErrors['warning_count'] + $dateLastErrors['error_count']) > 0) {
             return null;
         }


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

1 participant