soberwp / controller

Composer package to enable a controller when using Blade with Sage 9
MIT License
368 stars 43 forks source link

Warning in 'setDatafromModuleAcf' when 'setDataReturnFormat' doesn't return an array #107

Closed dividemysky closed 5 years ago

dividemysky commented 5 years ago

Hello -

I'm running into an issue where a lot of Warning spam is being created by the setDatafromModuleAcf and setDataFromFilter methods when the data returned by $this->classAcf->getData() is not an array, e.g.:

[23-Oct-2018 19:52:07 UTC] PHP Warning:  array_merge(): Argument #2 is not an array in /vendor/soberwp/controller/src/Controller.php on line 151
[23-Oct-2018 19:52:07 UTC] PHP Warning:  array_merge(): Argument #1 is not an array in /vendor/soberwp/controller/src/Controller.php on line 163

I'm running PHP 7.1.12 - not sure if that is why I'm seeing all these warnings.

I was able to resolve by wrapping the data set in __setDatafromModuleAcf with a check for an array, but wasn't sure if that was ideal, e.g.:

// Merge the data from Acf module
// $this->data = array_merge($this->classAcf->getData(), $this->data);
if (is_array($this->classAcf->getData())) {
  $this->data = array_merge($this->data, $this->classAcf->getData());
}

Let me know if I can provide more information!

dividemysky commented 5 years ago

I see this has been reported by others - closing!

darrenjacoby commented 5 years ago

Thanks @dividemysky , I will get this tagged soon, it's been a busy month for me, but latest 1st November.