trouble with 1.3.2

From: Date: Wed, 18 Apr 2001 12:49:00 +0000
Subject: trouble with 1.3.2
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-550@lists.php.net to get a copy of this message
Is there any interest in getting Smarty work properly under error_reporting( E_ALL ) ? I've run Smarty-1.3.2/index.php with this setting, and got 50 something warnings. (Actually, this was _after_ I commented out that damn flock() call (FWIW, I'm running NT 5.0 Pro SP1, apache/1.3.20-dev from a two weeks old snapshot, and PHP 4.0.5 RC6). This diff (both inline and attached) makes Smarty::Smarty() "register_globals off"-aware. $global_assign can now take the following form: array( 'HTTP_SERVER_VARS'=>array('SCRIPT_NAME','PATH_TRANSLATED'), 'HTTP_ENV_VARS'=>array('HOSTNAME') ); --- smarty.class.php.orig Wed Apr 18 13:34:08 2001 +++ smarty.class.php Wed Apr 18 14:40:33 2001 @@ -54,7 +54,9 @@ var $global_assign = array('SCRIPT_NAME'); // variables from the GLOBALS array // that are implicitly assigned - // to all templates + // to all templates + var $undefined = 'null' // undefined variables in $global_assign will be + // created with this value var $compile_check = true; // whether to check for compiling step or not: // This is generally set to false once the // application is entered into production and @@ -122,9 +124,21 @@ \*======================================================================*/ function Smarty() { - foreach ($this->global_assign as $var_name) { - if(isset($GLOBALS[$var_name])) { - $this->assign($var_name, $GLOBALS[$var_name]); + foreach ($this->global_assign as $key => $var_name) { + if (is_array($var_name) { + foreach ($var_name as $var) { + if (isset($GLOBALS[$key][$var])) { + $this->assign($key, $GLOBALS[$key][$var]); + } else { + $this->assign($key, $this->undefined); + } + } + } else { + if (isset($GLOBALS[$var_name])) { + $this->assign($var_name, $GLOBALS[$var_name]); + } else { + $this->assign($var_name, $this->undefined); + } } } } cynic@mail.cz ------------- And the eyes of them both were opened and they saw that their files were world readable and writable, so they chmoded 600 their files. - Book of Installation chapt 3 sec 7

--- smarty.class.php.orig Wed Apr 18 13:34:08 2001 +++ smarty.class.php Wed Apr 18 14:40:33 2001 @@ -54,7 +54,9 @@ var $global_assign = array('SCRIPT_NAME'); // variables from the GLOBALS array // that are implicitly assigned - // to all templates + // to all templates + var $undefined = 'null' // undefined variables in $global_assign will be + // created with this value var $compile_check = true; // whether to check for compiling step or not: // This is generally set to false once the // application is entered into production and @@ -122,9 +124,21 @@ \*======================================================================*/ function Smarty() { - foreach ($this->global_assign as $var_name) { - if(isset($GLOBALS[$var_name])) { - $this->assign($var_name, $GLOBALS[$var_name]); + foreach ($this->global_assign as $key => $var_name) { + if (is_array($var_name) { + foreach ($var_name as $var) { + if (isset($GLOBALS[$key][$var])) { + $this->assign($key, $GLOBALS[$key][$var]); + } else { + $this->assign($key, $this->undefined); + } + } + } else { + if (isset($GLOBALS[$var_name])) { + $this->assign($var_name, $GLOBALS[$var_name]); + } else { + $this->assign($var_name, $this->undefined); + } } } }
« previous php.smarty.general (#550) next »