Custom distiller goes wrong with object

Issue #28 resolved
Former user created an issue

PHP Warning: array_keys() expects parameter 1 to be array, object given in /typo3conf/ext/nnrestapi/Classes/Distiller/AbstractDistiller.php line 49

Investigating AbstractDistiller->isAssoc($arr), I found the array to be an object which makes distilling break. Workaround: add the following lines at top of AbstractDistiller->processData():

if (is_object($data)) {$data = \nn\T3::Convert()->toArray($data); }
\nn\t3::debug(['$keysToKeep'=>$this->keysToKeep,'$data'=>$data]);

Comments (4)

  1. David Bascom

    Thanks for reporting!
    As an alternative: Would this also work in your case?

        public function processData( &$data = [] ) 
        {
            // Try this instead of using \nn\t3::Convert()
            if (is_object($data)) {
                $data = (array) $data;
            }
            // ...      
        }
    

  2. Log in to comment