13

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?

brentwpeterson
  • 6,104
  • 7
  • 43
  • 81
Michael
  • 591
  • 3
  • 8
  • 22
  • 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...

    –  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? – Alana Storm Sep 30 '13 at 03: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 06: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

7 Answers7

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).

Teja Bhagavan Kollepara
  • 3,816
  • 5
  • 32
  • 69
navotjer
  • 176
  • 1
  • 3
  • 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. – Alana Storm Dec 12 '13 at 23:10
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

Alana Storm
  • 44,345
  • 35
  • 168
  • 353
2

Clear redis cache;

redis-cli

FLUSHALL

Its solved problem.

Knase
  • 152
  • 7
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.

cavbleu
  • 21
  • 1
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.

Haritha
  • 666
  • 5
  • 14
user3604
  • 21
  • 1
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

Krysis
  • 21
  • 2
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.

kelly
  • 1