tzyganu / GridEnhancer

Magento Grid Enhancer
MIT License
12 stars 0 forks source link

PHP Fatal error: Call to a member function getId() on a non-object in #1

Open gfrizzell opened 10 years ago

gfrizzell commented 10 years ago

Hi There,

I hope you are able to shed some light on a small issue we have. The extension has been installed and when going to Catalog - Products the Manage Columns button is not visible and in the logs we have the following:-

PHP Fatal error: Call to a member function getId() on a non-object in /home/website/htdocs/en/releases/2014_02_07_14_05_03_branch_master/app/code/community/Easylife/GridEnhancer/Model/Observer/Abstract.php on line 260

Just wondering if you could point us in the right direction as to what might cause this kind of error to be recorded.

We have the extension installed on the same site in our offices and it works fine, the version that is not working is installed in a cluster environment with nginx and varnish running in case that has any bearing... we are trying to work out a solution to the issue but would be great if you could point us towards the right direction based on what the extension is trying to do at the break point there.

Thanks in advance for your help Best regards Garry

tzyganu commented 10 years ago

@gfrizzell This is a strange issue. I can't even imagine how to reproduce it. The line in question is this Mage::getSingleton('admin/session')->getUser()->getId(), the method that uses it is:

    protected function _getAdminSettings(){
        if (is_null($this->_adminSettings)){
            $this->_adminSettings = $settings = Mage::getModel('easylife_gridenhancer/settings')
                ->loadByAdmin(
                    Mage::getSingleton('admin/session')->getUser()->getId(),
                    $this->getGridIdentifier()
                );
        }
        return $this->_adminSettings;
    }

What this does (should do) is to load the current configuration for a grid for the current logged in admin user.

If the error is Call to a member function getId() on a non-object it means that Mage::getSingleton('admin/session')->getUser() is not an object which means that there is no admin authenticated. Since the code should be executed only when looking at a certain admin grid.

In conclusion, the code should be executed only when there is an admin logged in, the error happens because there is no admin logged in. so...huh?
I would shoot in the dark here and say that there is probably something wrong with your sessions but I'm not really sure. I will try to reproduce the issue and post a solution here if I find one. but please do the same, I'm really curious about this.