Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

some fixes to avoid notices

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development
View previous topic :: View next topic  
Author Message
shuther
Smarty Rookie


Joined: 04 Jan 2004
Posts: 13

PostPosted: Thu Feb 05, 2004 12:00 pm    Post subject: some fixes to avoid notices Reply with quote

Quote:

RCS file: /repository/smarty/libs/Smarty.class.php,v
retrieving revision 1.475
diff -w -b -r1.475 Smarty.class.php
1227c1227
< if (@count($this->_cache_info['insert_tags']) == 0
---
> if ( (!isset($this->_cache_info['insert_tags']) || count($this->_cache_info['insert_tags']) == 0)


Quote:

RCS file: /repository/smarty/libs/Config_File.class.php,v
retrieving revision 1.64
diff -w -b -r1.64 Config_File.class.php
135a136
> if (isset($this->_config_data[$file_name]["vars"]))
136a138,139
> else
> return array();
292c295
< if ( @($line{0} == '[') && preg_match('!^\[(.*?)\]!', $line, $match) ) {
---
> if ( !empty($line) && ($line{0} == '[') && preg_match('!^\[(.*?)\]!', $line, $match) ) {



Quote:

RCS file: /repository/smarty/libs/Smarty_Compiler.class.php,v
retrieving revision 1.312
diff -w -b -r1.312 Smarty_Compiler.class.php
1436c1436
< if (@$tokens[$expr_end] == 'by') {
---
> if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') {
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Feb 07, 2004 8:13 pm    Post subject: Re: some fixes to avoid notices Reply with quote

shuther wrote:
Quote:

RCS file: /repository/smarty/libs/Smarty.class.php,v
retrieving revision 1.475
diff -w -b -r1.475 Smarty.class.php
1227c1227
< if (@count($this->_cache_info['insert_tags']) == 0
---
> if ( (!isset($this->_cache_info['insert_tags']) || count($this->_cache_info['insert_tags']) == 0)


what do you think of this one?

Code:
RCS file: /repository/smarty/libs/Smarty.class.php,v
retrieving revision 1.475
diff -u -r1.475 Smarty.class.php
--- libs/Smarty.class.php       25 Jan 2004 15:36:05 -0000      1.475
+++ libs/Smarty.class.php       7 Feb 2004 19:54:56 -0000
@@ -1185,7 +1185,7 @@
         if ($this->caching) {
             // save old cache_info, initialize cache_info
             array_push($_cache_info, $this->_cache_info);
-            $this->_cache_info = array();
+            $this->_cache_info = array('insert_tags'=>array(), 'cache_serials'=>array());
             $_params = array(
                 'tpl_file' => $resource_name,
                 'cache_id' => $cache_id,
@@ -1195,7 +1195,7 @@
             require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php');
             if (smarty_core_read_cache_file($_params, $this)) {
                 $_smarty_results = $_params['results'];
-                if (@count($this->_cache_info['insert_tags'])) {
+                if (count($this->_cache_info['insert_tags'])) {
                     $_params = array('plugins' => $this->_cache_info['insert_tags']);
                     require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
                     smarty_core_load_plugins($_params, $this);
@@ -1203,7 +1203,7 @@
                     require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php');
                     $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
                 }
-                if (@count($this->_cache_info['cache_serials'])) {
+                if (count($this->_cache_info['cache_serials'])) {
                     $_params = array('results' => $_smarty_results);
                     require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_compiled_include.php');
                     $_smarty_results = smarty_core_process_compiled_include($_params, $this);
@@ -1224,7 +1224,7 @@
                         $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
                         $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
                         $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
-                        if (@count($this->_cache_info['insert_tags']) == 0
+                        if (count($this->_cache_info['insert_tags']) == 0
                             && !$this->_cache_serials
                             && $_gmt_mtime == $_last_modified_date) {
                             if (php_sapi_name()=='cgi')


disadvantage: everybody has to serialize and unserialze two empty arrays. so it's a little correctness over performance. i could live with that.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Feb 07, 2004 8:55 pm    Post subject: Re: some fixes to avoid notices Reply with quote

shuther wrote:
Quote:

RCS file: /repository/smarty/libs/Smarty_Compiler.class.php,v
retrieving revision 1.312
diff -w -b -r1.312 Smarty_Compiler.class.php
1436c1436
< if (@$tokens[$expr_end] == 'by') {
---
> if (isset($tokens[$expr_end]) && $tokens[$expr_end] == 'by') {


fixed. thanks Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sat Feb 07, 2004 9:18 pm    Post subject: Re: some fixes to avoid notices Reply with quote

shuther wrote:
Quote:

RCS file: /repository/smarty/libs/Config_File.class.php,v
retrieving revision 1.64
diff -w -b -r1.64 Config_File.class.php
135a136
> if (isset($this->_config_data[$file_name]["vars"]))
136a138,139
> else
> return array();
292c295
< if ( @($line{0} == '[') && preg_match('!^\[(.*?)\]!', $line, $match) ) {
---
> if ( !empty($line) && ($line{0} == '[') && preg_match('!^\[(.*?)\]!', $line, $match) ) {



I think emitting a notice for the former is correct. The notice is silenced when debugging is turned off, but may be of interest when debugging is turned on, not?

The latter is fixed in CVS. Thanks for your input again Smile.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty Development All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP