Search code examples
phpmagento

Magento warning caused by Varien_Object $this->_data being an object but not an array


I got Magento 1.7 and I got this error Warning: array_keys() expects parameter 1 to be array, object given in ~/lib/Varien/Object.php on line 117. It's on a plugin that I installed, but I don't know how I can fix it.

The line is

$existedShortKeys = array_intersect($this->_syncFieldsMap, array_keys($this->_data));

but $this->_data is an object... So is it the plugin error or Magento's error ?
The plugin is Affiliate+ http://www.magestore.com/affiliateplus

===== FIX ====
So I managed to fix it, it's just a warning so we see this problem only in developer mode.
On the page app/code/local/Magestore/Affiliateplus/Block/Adminhtml/Banner/Edit/Tab/Form.phtml line 7

$data = array();
if(Mage::getSingleton('adminhtml/session')->getBannerData()){
    $data = Mage::getSingleton('adminhtml/session')->getBannerData();
    Mage::getSingleton('adminhtml/session')->setBannerData(null);
} elseif ( Mage::registry('banner_data')) {
    //$data =  Mage::registry('banner_data'); This line must be disabled
}
$obj = new Varien_Object($data);

That's it.


Solution

  • It is likely that it is the plugins error. Normally $this->_data is not an object but an arry.

    To get more details info you should post the name of the plugin, a link to the code and the backtrace of the error. Or contact the plugin's manufacturer.