Skip to content

[v5.1.0] BC Break -- array_diff_assoc vs array_diff -- Array to string conversion #826

@stevebauman

Description

@stevebauman

PHP Version: 8.0.25
Laravel Version: 9.41.0
Query Builder Version: 5.1.0

After updating from v5.0.3 to v5.1.0, all of my tests with this package broke, with the below exception:

Exception Screenshot Screenshot 2022-11-28 at 12 43 42 PM

This is because several of my filters contain multi-dimensional associative arrays, and not just key-value pairs.

For further context, we've built a condition system with this package. Dumping $value here:

if (is_array($value)) {
$remainingProperties = array_diff($value, $this->ignored->toArray());
return ! empty($remainingProperties) ? $remainingProperties : null;
}

Results in:

array:1 [▼
  0 => array:2 [▼
    "attribute" => "name"
    "operator" => "equals"
    "value" => "John Doe"    
  ]
]

However, it appears array_diff does not support multi-dimensional arrays, breaking the value resolution function and throwing the above exception.

Let me know if you require further information. I'll work on a PR in the meantime, along with a test case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions