Magento Missing argument 1 for Mage_Core_Block_Template ::setTemplate

Posted by Damodar Bashyal on April 04, 2016

 

If you are getting this magento error. It's easy to find why you are getting this error: Just need to add some debug code:

Open file app/code/core/Mage/Core/Block/Template.php and go to function setTemplate() (line 111 as shown in error log) and add these lines:

if(empty($template)){
	Mage::log(get_class($this));
	Mage::log($this->getNameInLayout());
	$e = new Exception;
	Mage::log(var_export($e->getTraceAsString(), true));
}

 

before this line:

$this->_template = $template;

One important thing you need to do for this to work is, you need to set error reporting to 0 (zero) in index.php.

 

This is what I got from above code:

# here required param template is not passed
2016-04-04T00:43:48+00:00 DEBUG (7): Mage_Newsletter_Block_Subscribe
2016-04-04T00:43:48+00:00 DEBUG (7): newsletter_popup
2016-04-04T00:43:48+00:00 DEBUG (7): '#0 [internal function]: Mage_Core_Block_Template->setTemplate()

# this one is ok though as it's passing NULL as template param.
2016-04-04T00:45:35+00:00 DEBUG (7): Magestore_Sociallogin_Block_Autosociallogin
2016-04-04T00:45:35+00:00 DEBUG (7): header.sociallogin
2016-04-04T00:45:35+00:00 DEBUG (7): '#0 app/code/local/Magestore/Sociallogin/Block/Autosociallogin.php(28): Mage_Core_Block_Template->setTemplate(NULL)

And the error I was getting was:

Magento Missing argument 1 for Mage_Core_Block_Template::setTemplate

 

Warning: Missing argument 1 for Mage_Core_Block_Template::setTemplate()  in app/code/core/Mage/Core/Block/Template.php on line 111
#0 app/code/core/Mage/Core/Block/Template.php(111): mageCoreErrorHandler(2, 'Missing argumen...', 'C://_projects//lo...', 111, Array)
#1 [internal function]: Mage_Core_Block_Template->setTemplate()
#2 app/code/core/Mage/Core/Model/Layout.php(348): call_user_func_array(Array, Array)
#3 app/code/core/Mage/Core/Model/Layout.php(214): Mage_Core_Model_Layout->_generateAction(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#4 app/code/core/Mage/Core/Model/Layout.php(206): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#5 app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#6 app/code/core/Mage/Core/Model/Layout.php(210): Mage_Core_Model_Layout->generateBlocks(Object(Mage_Core_Model_Layout_Element))
#7 app/code/core/Mage/Core/Controller/Varien/Action.php(344): Mage_Core_Model_Layout->generateBlocks()
#8 app/code/core/Mage/Cms/Helper/Page.php(113): Mage_Core_Controller_Varien_Action->generateLayoutBlocks()
#9 app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_IndexController), 'home')
#10 app/code/core/Mage/Cms/controllers/IndexController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_IndexController), 'home')
#11 app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Cms_IndexController->indexAction()
#12 app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#13 app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#14 app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#15 app/Mage.php(684): Mage_Core_Model_App->run(Array)
#16 index.php(86): Mage::run('', 'store')
#17 {main}

StanleyTips posted on - Saturday 28th of May 2016 07:09:02 AM

Thank you. Finally I found this fix.

Magento explorer posted on - Wednesday 31st of May 2017 01:45:15 AM

Thanks you, I also found this Magento error and thanks to your post, I finally find out how to debug and fix this issue
 
not published on website


QR Code: Magento Missing argument 1 for Mage_Core_Block_Template ::setTemplate