2

I'm seeing some weird behavior is a development system I upgraded from Magento CE 1.6 to Magento CE 1.8.1. Specifically, the site never gets page front controller dispatch due to the following error.

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

I traced this down to the following call failing to return an object.

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

For some reason, by global configuration does not have a request_rewrite node, even though I've cleared my cache, and this code exists on disk.

I recalls seeing similar reports in the past year since the release of 1.8.0.0. Does anyone know why this happens?

2
  • 1
    does it exist in more than 1 place? (that config path). Dec 12, 2013 at 22:54
  • @FlorinelChis Thanks for the suggestion, but that wasn't it. Real answer was far derpier. Dec 12, 2013 at 23:07

3 Answers 3

2

Self-help desk strikes again. When I un-tarred the new Magento codebase onto the old Magento codebase when updating the system, the file permissions on the

var
var/cache 

directory where changed such that my local web server couldn't write to this folder.

When this happens, Magento silently uses your computer's var and/or tmp directory space to store the cached files. Specifically, it chooses the system var dir here

#File: app/code/core/Mage/Core/Model/Config/Options.php
public function getVarDir()
{
    //$dir = $this->getDataSetDefault('var_dir', $this->getBaseDir().DS.'var');
    $dir = isset($this->_data['var_dir']) ? $this->_data['var_dir']
        : $this->_data['base_dir'] . DS . self::VAR_DIRECTORY;
    if (!$this->createDirIfNotExists($dir)) {
        $dir = $this->getSysTmpDir().DS.'magento'.DS.'var';
        if (!$this->createDirIfNotExists($dir)) {
            throw new Mage_Core_Exception('Unable to find writable var_dir');
        }
    }
    return $dir;
}

So, despite my clearing out of var/cache, Magento was still loading the cached configuration from 1.6.0.0 configuration. This version of Magento had no request_rewrite node, which is what led to the error.

1

I want to add that if you're using a shared memory solution such as APC or Memcached, Zend will store a "slow backend" file cache in the default system tmp directory.

This means you can clear magento_root/var/cache all you want and not see your changes take effect.

The reason is that (if Memcached is empty) Zend will default back to this file cache stored in /tmp/zend_cache--** and store a cached value in memcached.

Easiest way to clear this is to run rm -rf /tmp/zend_cache*

If you're on a server where your shell user doesn't have access to that directory, the below php script should do:

$files = glob("/tmp/zend_cache*"); foreach($files as $f) { unlink($f); }

1

Another Cause of this error is a new vhost configuration with a new magento or a migrated magento without restarting php-fpm, just experienced this. In a Rackspace cloud server environment.

Best of luck,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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