Magento – Template not found: ‘include(): Filename cannot be empty’ when viewing order details

backenderrormagento-1.9template

I am trying to set up a webshop with Magento 1.9.2.4.
So far creating orders seems to work on the frontend. However, when I try to view the orders in the admin backend (Sales > Orders > clicking on the order) I get an error dump on the screen (see below). Also when I try to view the order statistics in Report > Sales > Orders, I always get "No records found.", whatever I try (including a refresh of last day's statistics). I installed the "Delete Order" module/extension from Magehit and could delete all orders, hoping that might fix the database, but after I create a new order, the same error dump is shown (see below).

I tried so far:

  • Flushing the cache
  • Disabling all modules, which I installed
  • Run the compilation process

All without success 🙁

I had upgraded from a previous version of Magento. Can it be that something went wrong at that time, which spoiled my database? Shall I try to repair the database with Magento's database repair tool? Or better start with a clean install to avoid any risk before going into real world operation?

Could someone please be so kind to give me a hit, what is going wrong or how I can try to understand and solve the problem?

Error dump:

Warning: include(): Filename cannot be empty  in includes/src/__default.php on line 3418

#0 includes/src/__default.php(3418): mageCoreErrorHandler(2, 'include(): File...', '/var/www/magent...', 3418, Array)
#1 includes/src/__default.php(3418): Mage_Core_Block_Template->fetchView()
#2 includes/src/__default.php(3449): Mage_Core_Block_Template->fetchView('adminhtml/base/...')
#3 includes/src/__default.php(3463): Mage_Core_Block_Template->renderView()
#4 includes/src/Mage_Adminhtml_Block_Template.php(81): Mage_Core_Block_Template->_toHtml()
#5 includes/src/__default.php(2613): Mage_Adminhtml_Block_Template->_toHtml()
#6 includes/src/__default.php(2331): Mage_Core_Block_Abstract->toHtml()
#7 includes/src/__default.php(2275): Mage_Core_Block_Abstract->_getChildHtml('order_info', true)
#8 app/design/adminhtml/default/default/template/sales/order/view/tab/info.phtml(33): 
   Mage_Core_Block_Abstract->getChildHtml    ('order_info')
#9 includes/src/__default.php(3418): include('/var/www/magent...')
#10 includes/src/__default.php(3449): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#11 includes/src/__default.php(3463): Mage_Core_Block_Template->renderView()
#12 includes/src/Mage_Adminhtml_Block_Template.php(81): Mage_Core_Block_Template->_toHtml()
#13 includes/src/__default.php(2613): Mage_Adminhtml_Block_Template->_toHtml()
#14 includes/src/Mage_Adminhtml_Block_Widget_Tabs.php(303): Mage_Core_Block_Abstract->toHtml()
#15 app/design/adminhtml/default/default/template/widget/tabs.phtml(38): 
    Mage_Adminhtml_Block_Widget_Tabs->getTabContent(Object  (Mage_Adminhtml_Block_Sales_Order_View_Tab_Info))
#16 includes/src/__default.php(3418): include('/var/www/magent...')
#17 includes/src/__default.php(3449): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#18 includes/src/__default.php(3463): Mage_Core_Block_Template->renderView()
#19 includes/src/Mage_Adminhtml_Block_Template.php(81): Mage_Core_Block_Template->_toHtml()
#20 includes/src/__default.php(2613): Mage_Adminhtml_Block_Template->_toHtml()
#21 includes/src/__default.php(13851): Mage_Core_Block_Abstract->toHtml()
#22 includes/src/__default.php(2613): Mage_Core_Block_Text_List->_toHtml()
#23 includes/src/__default.php(2331): Mage_Core_Block_Abstract->toHtml()
#24 includes/src/__default.php(2275): Mage_Core_Block_Abstract->_getChildHtml('left', true)
#25 app/design/adminhtml/default/default/template/page.phtml(58): Mage_Core_Block_Abstract->getChildHtml('left')
#26 includes/src/__default.php(3418): include('/var/www/magent...')
#27 includes/src/__default.php(3449): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#28 includes/src/__default.php(3463): Mage_Core_Block_Template->renderView()
#29 includes/src/Mage_Adminhtml_Block_Template.php(81): Mage_Core_Block_Template->_toHtml()
#30 includes/src/__default.php(2613): Mage_Adminhtml_Block_Template->_toHtml()
#31 includes/src/__default.php(28708): Mage_Core_Block_Abstract->toHtml()
#32 includes/src/__default.php(14244): Mage_Core_Model_Layout->getOutput()
#33 app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(128):
    Mage_Core_Controller_Varien_Action->renderLayout()
#34 includes/src/__default.php(14272): Mage_Adminhtml_Sales_OrderController->viewAction()
#35 includes/src/__default.php(18750): Mage_Core_Controller_Varien_Action->dispatch('view')
#36 includes/src/__default.php(18280):
    Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#37 includes/src/__default.php(21176): Mage_Core_Controller_Varien_Front->dispatch()
#38 app/Mage.php(684): Mage_Core_Model_App->run(Array)
#39 index.php(84): Mage::run('', 'store')
#40 {main}

UPDATE:
Below the error dump when compiling is disabled:

Warning: include(): Filename cannot be empty  in app/code/core/Mage/Core/Block/Template.php on line 241

#0 app/code/core/Mage/Core/Block/Template.php(241): mageCoreErrorHandler(2, 'include(): File...', '/var/www/magent...', 241, Array)
#1 app/code/core/Mage/Core/Block/Template.php(241): Mage_Core_Block_Template->fetchView()
#2 app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/base/...')
#3 app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#4 app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#5 app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#6 app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#7 app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('order_info', true)
#8 app/design/adminhtml/default/default/template/sales/order/view/tab/info.phtml(33):
 Mage_Core_Block_Abstract->getChildHtml('order_info')
#9 app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/magent...')
#10 app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#11 app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#12 app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#13 app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#14 app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php(303): Mage_Core_Block_Abstract->toHtml()
#15 app/design/adminhtml/default/default/template/widget/tabs.phtml(38):
 Mage_Adminhtml_Block_Widget_Tabs->getTabContent(Object(Mage_Adminhtml_Block_Sales_Order_View_Tab_Info))
#16 app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/magent...')
#17 app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#18 app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#19 app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#20 app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#21 app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#22 app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Core_Block_Text_List->_toHtml()
#23 app/code/core/Mage/Core/Block/Abstract.php(637): Mage_Core_Block_Abstract->toHtml()
#24 app/code/core/Mage/Core/Block/Abstract.php(581): Mage_Core_Block_Abstract->_getChildHtml('left', true)
#25 app/design/adminhtml/default/default/template/page.phtml(58): Mage_Core_Block_Abstract->getChildHtml('left')
#26 app/code/core/Mage/Core/Block/Template.php(241): include('/var/www/magent...')
#27 app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('adminhtml/defau...')
#28 app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#29 app/code/core/Mage/Adminhtml/Block/Template.php(81): Mage_Core_Block_Template->_toHtml()
#30 app/code/core/Mage/Core/Block/Abstract.php(919): Mage_Adminhtml_Block_Template->_toHtml()
#31 app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#32 app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#33 app/code/core/Mage/Adminhtml/controllers/Sales/OrderController.php(128):
 Mage_Core_Controller_Varien_Action->renderLayout()
#34 app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Adminhtml_Sales_OrderController->viewAction()
#35 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254):
 Mage_Core_Controller_Varien_Action->dispatch('view')
#36 app/code/core/Mage/Core/Controller/Varien/Front.php(172):
 Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#37 app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#38 app/Mage.php(684): Mage_Core_Model_App->run(Array)
#39 index.php(84): Mage::run('', 'store')
#40 {main}

Best Answer

The problem

This is an error from PHP's include

Warning: include(): Filename cannot be empty

The filename passed to include is an empty string "".

This is caused in app/code/core/Mage/Core/Block/Template.php on line 241 inside the method Mage_Core_Block_Template::fetchView($fileName).

The method takes the template $fileName and runs this through realpath() and then does the include:

$includeFilePath = realpath($this->_viewDir . DS . $fileName)
// and after that:
include $includeFilePath;

The PHP docs say about realpath()'s return value:

realpath() returns FALSE on failure, e.g. if the file does not exist.

So the passed template in $fileName does not exist and $includePath holds an empty string

How to solve?

To solve this, you have to find which template it is that does not exists (or is not readable).

Now copy app/code/core/Mage/Core/Block/Template.php to the local code pool as app/code/local/Mage/Core/Block/Template.php (notice the local part).

Now before the line where realpath() is being used (line 239), add:

if (!file_exists($this->_viewDir . DS . $fileName)) {
    Mage::log(__METHOD__ . "(): Template file '" . $this->_viewDir . DS . $fileName . "' does not exist!", Zend_Log::DEBUG, '', true);
} elseif (!is_readable($this->_viewDir . DS . $fileName)) {
    Mage::log(__METHOD__ . "(): Template file '" . $this->_viewDir . DS . $fileName . "' is not readable!", Zend_Log::DEBUG, '', true);
}

Now check your log file var/log/system.log for any entries

Related Topic