[GH-ISSUE #125] Invalid argument supplied for foreach() #227

Open
opened 2026-03-07 20:42:14 +03:00 by kerem · 1 comment
Owner

Originally created by @kl3sk on GitHub (Nov 24, 2021).
Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/125

When using this package I have:

PHP Warning:  Invalid argument supplied for foreach() in vendor/dbdiff/dbdiff/src/DB/Data/ArrayDiff.php on line 47
PHP Warning:  Invalid argument supplied for foreach() in vendor/dbdiff/dbdiff/src/DB/Data/ArrayDiff.php on line 79
PHP Warning:  Invalid argument supplied for foreach() in vendor/dbdiff/dbdiff/src/DB/Data/ArrayDiff.php on line 88

PHP 7.4.25
10.6.5-MariaDB-1:10.6.5+maria~focal
WSL2 Debian

$data1 = $this->dbiterator1->next(ArrayDiff::$size); return a Collection and array_merge require an array.

Unless using $data1->toArray() others errors occurs.

Originally created by @kl3sk on GitHub (Nov 24, 2021). Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/125 When using this package I have: ```bash PHP Warning: Invalid argument supplied for foreach() in vendor/dbdiff/dbdiff/src/DB/Data/ArrayDiff.php on line 47 PHP Warning: Invalid argument supplied for foreach() in vendor/dbdiff/dbdiff/src/DB/Data/ArrayDiff.php on line 79 PHP Warning: Invalid argument supplied for foreach() in vendor/dbdiff/dbdiff/src/DB/Data/ArrayDiff.php on line 88 ``` PHP 7.4.25 10.6.5-MariaDB-1:10.6.5+maria~focal WSL2 Debian `$data1 = $this->dbiterator1->next(ArrayDiff::$size);` return a `Collection` and `array_merge` require an array. Unless using `$data1->toArray()` others errors occurs.
Author
Owner

@kl3sk commented on GitHub (Nov 24, 2021):

First patch attempt:

ArrayDiff.php line 40

    public function isKeyEqual( $entry1, $entry2 ) {
        // patch -->
        if ( null === $entry1 || null === $entry2 ) {
            return false;
        }
        // <- patch
        foreach ( $this->key as $key ) {
            if ( $entry1[ $key ] !== $entry2[ $key ] ) {
                return false;
            }
        }

        return true;
    }

It returns a larger file with more data.

<!-- gh-comment-id:978137700 --> @kl3sk commented on GitHub (Nov 24, 2021): First patch attempt: `ArrayDiff.php` line 40 ```php public function isKeyEqual( $entry1, $entry2 ) { // patch --> if ( null === $entry1 || null === $entry2 ) { return false; } // <- patch foreach ( $this->key as $key ) { if ( $entry1[ $key ] !== $entry2[ $key ] ) { return false; } } return true; } ``` It returns a larger file with more data.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/DBDiff#227
No description provided.