4

Simple example tested on magento 1.7.0.2

Created overloaded controller for Mage_Cms_IndexController

<routers>
  <cms>
<args>
  <modules>
    <My_Extension before="Mage_Cms">My_Extension</My_Extension>
  </modules>
</args>
  </cms>
</routers>

In my controller I have two methods

testOneAction and testTwoAction

I can confirm that they work my just going into /cms/index/testOne and /cms/index/testTwo

Now the fun part

Created third method

public function testThirdAction() {
    $this->_forward('testOne');
}

When compiler is DISABLED going into /cms/index/testThird I can see data from testOne

When compiler is ENABLED - got blank page

Even with display_errors, developer mode, full error reporting, there is absolutely nothing in magento logs, web server logs or php error logs.

Tried xdebug and it pointed me into direction that request is not marked as dispatched and then it dies silently.

What I found so far: In includes/src/Varien_Autoload.php

/**
 * Register autoload scope
 * This process allow include scope file which can contain classes
 * definition which are used for this scope
 *
 * @param string $code scope code
 */
static public function registerScope($code)
{
    self::$_scope = $code;
    if (defined('COMPILER_INCLUDE_PATH')) {
        @include COMPILER_INCLUDE_PATH . DIRECTORY_SEPARATOR . self::SCOPE_FILE_PREFIX.$code.'.php';
    }
}

Looks like @ makes it to die silently, if I change it to include_once, everything works great

Anyone can help?

4

This is a bug which is related with magento compiler. I will give you a short glance of what is actually happens here.

During compilation enabled, magento uses a copy of every files inside the directory include/src. Since every file have a corresponding copy in single directory and magento uses this single directory while coimpilation enabled, magento performs faster.

When you do $this->_forward('testOne'), magento now process router match processing one more time. As module didnt change, Mage_Core_Controller_Varien_Action::preDispatch method intents to make Varien_Autoload to load the the include/src/Mage_Cms_IndexController.php again. This is what failing here. Why it fails ? You have found out the answer. It is the bug which is present in includes\src\Varien_Autoload::registerScope()

static public function registerScope($code)
  {
    self::$_scope = $code;
    if (defined('COMPILER_INCLUDE_PATH')) {
      // Change to include_once to prevent including multiple times !!!
      //@include COMPILER_INCLUDE_PATH . DIRECTORY_SEPARATOR . self::SCOPE_FILE_PREFIX.$code.'.php';
      @include COMPILER_INCLUDE_PATH . DIRECTORY_SEPARATOR . self::SCOPE_FILE_PREFIX.$code.'.php';
    }
}

The last line of code is failing in this particular case. This is because, magento is trying to load the same Mage_Cms_IndexController which is avialble in includes/src when you perform a _forward action.

So if you use include_once instead of include, then it will resolve the issue.

For more info, use this

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.