soberwp/controller

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

dividemysky opened this issue · 2 comments

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!

I see this has been reported by others - closing!

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