php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24939 Variable method names have become less flexible
Submitted: 2003-08-04 13:41 UTC Modified: 2003-11-29 01:21 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: hans at velum dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.0.0b1 (beta1) OS: Linux (Debian)
Private report: No CVE-ID: None
 [2003-08-04 13:41 UTC] hans at velum dot net
Description:
------------
Smarty uses a rather complex variable method name replacement system.  In the "compiled" Smarty templates there is code like this:

  $this->_plugins['function']['assign'][0](/* params */)

Which works fine in PHP4, but PHP5 issues a fatal error:

  "Fatal error: Method name must be a string"

Is this a PHP5 bug or an abuse of PHP syntax (and therefore a Smarty bug)?

Reproduce code:
---------------
A Smarty compiled template:

<?php $this->_load_plugins(array(
array('function', 'assign', 'sql/db-init/Control.tpl', 1, false),)); ?><?php echo $this->_plugins['function']['assign'][0](array('var' => 'fname','value' => "sql/db-init/".$this->_tpl_vars['targetDatabase']."/createdb.tpl"), $this) ; ?>

<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include($this->_tpl_vars['fname'], array());
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
~

Expected result:
----------------
No error.

Actual result:
--------------
Fatal error: Method name must be a string in templates_c/%%-16/%%-1662958972/Control.tpl.php

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-28 20:58 UTC] sniper@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.


 [2003-11-29 01:21 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #25652

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Aug 16 11:01:27 2024 UTC