Why did smarty registerPlugin() stop workgin somewhere around v3.1.30?

86 views Asked by At

I migrated from smarty v3.1.29 to v3.1.33 and my registered plugins stopped working. Why?

I used this syntax:

$this -> registerPlugin ( "function", "tpl_func", "php_func" );

The behaviour goes wrong only with php 7.0. With php 7.3.14 it still works fine.

1

There are 1 answers

0
Csongor Halmai On

The problem is not where you call the function but where you define it.

In older versions of smarty the following syntax did work:

function php_func($params, &$smarty) {
    return "blah";
}

In the newer versions this is incorrect. You should use this one (remove the & from the second argument):

function php_func($params, $smarty) {
    return "blah";
}

The same holds for smarty blocks and smarty functions as well.