Smarty upgrade to 3.1.3

While working with templates in OJS3 I have noticed that it uses syntax of Smarty 2. Is it possible to make upgrade to support Smarty 3+? Found files in: lib\pkp\lib\vendor\smarty. After upgrade and following changes in file: lib/pkp/classes/template/
class PKPTemplateManager extends SmartyBC (was extended Smarty)
and change require statement appropriately I get the following fatal error:

PHP Fatal error: Uncaught Error: Call to a member function _mergeVars() on boolean in C:\\xampp\\htdocs\\site\\lib\\pkp\\lib\\vendor\\smarty\\smarty\\libs\\sysplugins\\smarty_internal_data.php:226\nStack trace:\n#0 C:\\xampp\\htdocs\\site\\lib\\pkp\\lib\\vendor\\smarty\\smarty\\libs\\sysplugins\\smarty_internal_templatebase.php(195): Smarty_Internal_Data->_mergeVars()\n#1 C:\\xampp\\htdocs\\site\\lib\\pkp\\lib\\vendor\\smarty\\smarty\\libs\\sysplugins\\smarty_internal_templatebase.php(99): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, 'e0358315fa46b03...', true, 0)\n#2 C:\\xampp\\htdocs\\site\\lib\\pkp\\classes\\template\\ Smarty_Internal_TemplateBase->fetch('frontend/pages/...', NULL, 'e0358315fa46b03...', true)\n#3 C:\\xampp\\htdocs\\site\\lib\\pkp\\classes\\template\\ PKPTemplateManager->fetch('frontend/pages/...', NULL, 'e0358315fa46b03...', true)\n#4 C:\\xampp\\htdocs\\site\\pages\\article\\ PKPTemplateManager->display('frontend/pages/...')\n#5 C:\\xampp\\htdocs\\s in C:\\xampp\\htdocs\\site\\lib\\pkp\\lib\\vendor\\smarty\\smarty\\libs\\sysplugins\\smarty_internal_data.php on line 226

inside ArticleHandler it refers to this line:

if (!HookRegistry::call('ArticleHandler::view', array(&$request, &$issue, &$article))) {
	return $templateMgr->display('frontend/pages/article.tpl');

I am wondering, why it cannot find this page? Is there a need to additionally specify path to template directory somewhere?

Hi @Vitaliy,

I’ve experimented a little with upgrading to Smarty3 and as I recall I got most things working. Check this Bugzilla entry.

Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

OK, site front-end works fine on Smarty 3. But I got an endless spinner in the admin dashboard header and problems with loading pages after pressing on tabs there.

modified, including the part with path to templates:

Fatal error upon pressing the tab:

[Thu Dec 14 16:36:28.571675 2017] [php7:error] [pid 11908:tid 1984] [client] PHP Fatal error: Uncaught --> Smarty: template property '_tag_stack' does not exist. <-- \n thrown in C:\\xampp\\htdocs\\ojs-3.1.0-1\\lib\\pkp\\lib\\vendor\\smarty\\smarty\\libs\\sysplugins\\smarty_internal_template.php on line 680, referer: http://localhost/index.php/psp/management/settings/website

Didn’t find any mention of _tag_stack method in the OJS 3 code.

Several notices on undified variables in Smarty:

Undefined variable: name
Undefined index: refreshOn
Undefined index: hasSystemNotifications
Undefined index: requestOptions

Hi @Vitaliy,

Can you create a pull request? That way I can make comments on individual lines of code. Also, make sure your editor is set to indent with tabs rather than spaces. When the PR is ready and open, I’ll try it out and see if I can figure out what the problem is. (I’d also suggest using a feature branch for your own organizational purposes, rather than working directly off master, but that’s up to you!)

Alec Smecher
Public Knowledge Project Team

Have created.

Several commentaries on the code:

  • SmartyBC class was used because of {php} tags inside templates.

  • When you point the lines: $this->app_template_dir, $this->core_template_dir inside the constructor, where are those object properties you are referring to? I didn’t find them inside parent (Smarty) class. So, had added them.

  • Without explicit pointing the path to theme templates (theme_template_dir), theme’s templates are not loading.

(Note that this work continues over at