Magento 1.3.2.2: Fatal error: Call to a member function getUsername() on a non-object

In Magento 1.3.2.2 we get a fatal error:

Fatal error: Call to a member function getUsername() on a non-object in .../app/design/adminhtml/default/default/template/page/header.phtml on line 31

During an order confirmation, Magento should make a transition to the success page. But we are getting that error instead.

An Admin header is shown with this error. If I refresh, I get to the success page where I should have been taken if everything was ok.

-------------Problems Reply------------

This error happens because header.phtml on line 31 has entry:

$this->getUser()->getUsername();

But getUser() method didn't return valid object. This method pretty simple and looks like this:

return Mage::getSingleton('admin/session')->getUser();

So, you should debug only one place: app/code/core/Mage/Admin/Model/Session.php Only one method setUser() object to session

public function login($username, $password, $request = null) {
...
$this->setUser($user);

If user object loads and valid it is mean that you have problem with session it self:

  • check how cookies sets
  • cookies path and created time

It is not easy find the problem remotely without debugging. So I wish you success.

I had the same error and solved it as follows:

  1. Backup the var folder as (var-back)
  2. Create a new var directory
  3. Backup the locks folder as (locks-back) {if available}
  4. Create the locks directory

Refresh the URL

Category:php Views:0 Time:2012-01-26

Related post

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.214 (s). 11 q(s)