2

My site is not loading, as I get this error message when type in the URL:

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

Does any one familiar with what could be wrong here?

7ochem
7,61516 gold badges54 silver badges82 bronze badges
asked Jan 27, 2015 at 2:08

5 Answers 5

4

If you look at the file to which magento points out, you can find the below line which comes inside dispatch method

File : app/code/core/Mage/Core/Controller/Varien/Front.php

$this->_getRequestRewriteController()->rewrite();

The error says rewrite() is calling on a non-object. This means that, $this->_getRequestRewriteController() provides you a non-object (most probably it returns an empty value).

Why $this->_getRequestRewriteController() gives you a non-object ? In order to find the reason, let us have a look on this method definition.

protected function _getRequestRewriteController()
{
 $className = (string)Mage::getConfig()->getNode('global/request_rewrite/model');
 return Mage::getSingleton('core/factory')->getModel($className, array(
 'routers' => $this->getRouters(),
 ));
}

The method just trying to create a model instance of $className. Here $className holds a value which is returned by $className = (string)Mage::getConfig()->getNode('global/request_rewrite/model');. The default value which return by this call is core/url_rewrite_request. This means the method _getRequestRewriteController() is supposed to return an instance of model class Mage_Core_Model_Url_Rewrite_Request by defalt.

Based on this analysis, the error may be caused due to

  1. You may have a wrong class name in the above specified node. app/code/core/Mage/Core/etc/config.xml is used to define this node value. Since it is a core file, alternation happens here may be a rare chance. There is a possibility of rewriting this node by any external plugins. So this should be validated first.

  2. Ultimately your magento application do not have the file which defines this class Mage_Core_Model_Url_Rewrite_Request which normally appers at app/code/core/Mage/Core/Model/Url/Rewrite/Request.php

  3. I have found out some threads, which gives a hint that permission problems on var/cache directory may also cause this weird issue.

Hope that helps.

answered Jan 27, 2015 at 3:48
3

I had exactly the same issue and I found that going into var/cache and deleting everything in there worked for me.

David Manners
27.3k9 gold badges78 silver badges220 bronze badges
answered Aug 24, 2015 at 13:24
1

Just thought I'd share this with everyone: I got stuck in a situation like this. There was a problem with one of my mysql upgrade scripts and even though I had var folder and used apc.php to try and flush that cache out I was still hitting this problem. I finally got out of it by placing an apc_clear_cache ('user'); command at the beginning of my index.php file which then allowed me to work through the upgrade script problems of which I had three. I then put my index.php back to what it was.

http://php.net/manual/en/function.apc-clear-cache.php

answered Feb 20, 2015 at 14:33
1

I had the same issue, but i'm using redis, "flushall" from redis-cli did the trick

answered Aug 26, 2015 at 14:38
1

This issue generally occurs when we upgrade Magento version. By the way for any reason if you have this issue, then first of all you should do this:

Clear cache

rm -rf var/cache/*
Teja Bhagavan Kollepara
3,8275 gold badges33 silver badges69 bronze badges
answered Jun 2, 2017 at 10:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.