12

We tried to upgrade our Magento installation from 1.7.0.2 to 1.8.0.0. Now we got the following error on all pages:

Fatal error: Call to a member function rewrite() on a non-object in /home/clientname/domains/domain.com/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php on line 165

We tried to clear all caches, disable and recompile the compiler and reindex the indexer. Earlier today everything went well on our local installation. This is the same installation except some orders and client data.

When the compiler is enabled the error changes in:

Fatal error: Call to a member function rewrite() on a non-object in /home/clientname/domains/domain.com/public_html/includes/src/__default.php on line 17761

How we can debug this error?

  • I too upgraded to 1.8 magento Mine has some same problem but the error i am getting is not in the varien...see the error as below: > Fatal error: Call to a member function getProductAttribute() on a > non-object in > /home/shopk3if/public_html/app/design/frontend/base/default/template/catalog/product/price.phtml > on line 50 plz help me for the code as I'm not the developer... – user3391 Sep 28 '13 at 15:17
  • Are you sure that you have compilation turned off? – brentwpeterson Sep 28 '13 at 21:46
  • @MichaelvanEijden Were you able to track down the root cause of this? – Alan Storm Sep 30 '13 at 3:37
  • 1
    @AlanStorm For some reason, there was only a part of the files transfered during the upgrade. Your answer brought me to the right place though. Thanks! – Michael Sep 30 '13 at 6:30
  • I have the same issue..... but I now tried to overwrite all files with the contents of the magento ZIP installation archive.... but it didn´t help. That´s going to become a loooong debug session! NO update of Magento up to now worked for me without problems! – cljk Nov 11 '13 at 14:06
5

Looking at line 165

#File: app/code/core/Mage/Core/Controller/Varien/Front.php
$this->_getRequestRewriteController()->rewrite();

The method _getRequestRewriteController should return an object. For some reason, it's not returning an object in your system.

Taking a look at that method definition, we see the following

protected function _getRequestRewriteController()
{
    $className = (string)Mage::getConfig()->getNode('global/request_rewrite/model');

    return Mage::getSingleton('core/factory')->getModel($className, array(
        'routers' => $this->getRouters(),
    ));
}

Mage looks at the global/request_rewrite/model configuration node to find a class alias. In a store system this should be

core/url_rewrite_request

Which Magento then uses to instantiate a model. My two guesses are

  1. There's a module with a different, invalid class name here, which prevents Magento from instantiating the object.

  2. Your system is missing the Mage_Core_Model_Url_Rewrite_Request class file (at app/code/core/Mage/Core/Model/Url/Rewrite/Request.php), which is new in Magento 1.8

  • 1
    Also, see the answer/comments from @navotjer below. – Alan Storm Dec 12 '13 at 23:10
7

I had the same issue, and beside clearing the cache, I had to set folder permissions on /var and subdirectories to 777 (don't worry, the .htaccess file in /var prevents everything to be "human" readable).

  • 1
    Ran into this today and seconding this answer — untaring a new Magento codebase can change the permissions on your var folder, which means Magneto may revert to a system var folder that has an old cached configuration. – Alan Storm Dec 12 '13 at 23:10
  • +1 You saved my day! Was upgrading from 1.6.0.1 to 1.9.0.1 – toesslab Sep 16 '14 at 12:06
2

If you have a cache server like memcached try to restart it as well. I had the same issue and I resolved this way.

  • Or if Redis: redis-cli flushall – kiatng May 6 '15 at 3:39
2

Clear redis cache;

redis-cli

FLUSHALL

Its solved problem.

2

I tried to follow the explanation by @AlanStorm, but ultimately found it was a caching issue. I just had to rm -rf * all the files in ~/public_html/var/cache and I found that the site loaded correctly.

  • Simple like this. I had the same problem when upgrading from 1.7 to 1.9, but forgot to clear cache folder. – Ricardo Martins Feb 17 '15 at 13:16
1

I have the same issue

Fatal error: Call to a member function rewrite() on a non-object in /home/clientname/domains/domain.com/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php on line 165

Deleting all in /var/cache solves the problem

0

Deleting everything in var/cache solved the problem for me as well.

Also had to delete the maintenance.flag file before this problem occurred, as a maintenance page was present.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.