Jeff-Lewis / smarty-php

Automatically exported from code.google.com/p/smarty-php
0 stars 0 forks source link

createTemplate(template, data) implementation causes notice level errors with empty data arrays #189

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Attempt to create whichever template using the createTemplate(template, 
data) version (as described in the api for that function) using empty array as 
the data parameter. 

What is the expected output? What do you see instead?

The function still outputs the template as it should, but it also produces to 
error log:
PHP Notice:  Array to string conversion in lib/smarty3/Smarty.class.php on line 
1211

With some templates I've gotten an additional
PHP Notice:  Array to string conversion in 
lib/smarty3/sysplugins/smarty_internal_template.php on line 643

It is certainly connected since it only occurs with the empty array 
construction, but I haven't singled out why some templates trigger it and some 
don't.

What version of the product are you using? On what operating system?

@version 3.1-DEV
$Id: Smarty.class.php 4694 2013-01-13 21:13:14Z

on Ubuntu 13.10

Please provide any additional information below.

This seems to be related to the manner how the function implements checking if 
the argument passed in as $cache_id is an array on line 1194. Because the 
builtin empty() function returns true for empty arrays, the check to see if the 
parameter is an array is omitted and the parameter is kept. This then causes 
the error when its value later is concatenated to a string. Suggest to check 
instead of empty() for !== null on both lines 1194 and 1198 to ensure intended 
behavior also when getting an empty array.

Original issue reported on code.google.com by samuli.k...@gmail.com on 18 Apr 2014 at 7:45

GoogleCodeExporter commented 9 years ago
This bug is now fixed in the SVN and will later be included in 3.1.19

Original comment by Uwe.Tews@googlemail.com on 19 Apr 2014 at 11:43