'Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

I'm trying to migrate from my old PHP 5.4.45 + Smarty 2.6.28 to my new PHP 7.2.25 + Smarty 3.1.33.

I'm tuning some small pieces of code, it works in most of webpages, but suddenly it stop working in some PHP pages, returning the following error message:

Notice: Undefined property: Smarty_Internal_Undefined::$objMap in /home/www/libs/Smarty-3.1.33/libs/sysplugins/smarty_internal_extension_handler.php on line 132
Fatal error: Uncaught --> Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars' <-- thrown in /home/www/libs/Smarty-3.1.33/libs/sysplugins/smarty_internal_undefined.php on line 62

I can not figure out which PHP code is causing this error message, since I do not see within it any line position to analyze. It seems that the PHP code of these pages are very similar to the pages which work ok. I've read on the Internet that this error may be caused by 'register_object' in PHP. I've just checked my PHP files, and there is no 'register_object' within them.

In the not-working PHP pages (as in the working ones), additionally to the rest of the PHP operations, I do just:

$myTemplate = new Smarty();
$myTemplate->compile_dir = $mypath . "/templates_c";
$myTemplate->template_dir = $mypath . "/templates";
$myTemplate->assign("myvarible", $foo);
$myTemplate->display("mytemplate.html");

Any help is appreciated. Thank you very much.



Solution 1:[1]

Found a solution as I was struggling with the same issue while upgrading to Smarty 3.1.36: the method has been renamed.

Replace $yourSmartyObject->get_template_vars()

  • with $yourSmartyObject->getTemplateVars()

Solution 2:[2]

Finally I found that, apart from the previous operations with '$myTemplate', I do the following one:

$myTemplate->get_template_vars('fooVar')

Now, I'll try to find why 'get_template_vars' causes this error.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Oliver
Solution 2 Hookstark