[PHPTAL] Patch for Php/State.php

smoking_birds_on_moon at earthling.net smoking_birds_on_moon at earthling.net
Mon Nov 13 11:18:11 CET 2006


Hello again,

this is a patch for PHPTAL_Php_State regarding the memory-leak problem. 
I'm not a php programmer and I only tested this patch with a very simple 
Template.

May someone test this within a larger project and lots uses of 
"${VarName}" in Tales expressions ?

Thanks and regards,
mg


patch for PHPTAL-1.1.7 (PHPTAL/Php/State.php):

*** State.php   2006-11-13 11:05:34.000000000  0100
--- State.php.patched   2006-11-13 11:05:07.000000000  0100
***************
*** 104,116 ****
           return '\''.$string.'\'';
       }

       public function interpolateTalesVarsInHtml($src)
       {
           if ($this->_talesMode == 'tales'){
!             $func = create_function('$matches','return "<?php echo 
".phptal_tales($matches[1])." ?>";');
!             $result = preg_replace_callback('/(?<!\$)\$\{structure 
(.*?)\}/ism', $func, $src);
!             $func = create_function('$matches','return "<?php echo 
phptal_escape(".phptal_tales($matches[1]).", ENT_QUOTES, 
\''.$this->_encoding.'\'); ?>";');
!             $result = preg_replace_callback('/(?<!\$)\$\{(.*?)\}/ism', 
$func, $result);
               /*
               $result = preg_replace(
                   '/(?<!\$)\$\{([a-z0-9\/_] )\}/ism',
--- 104,132 ----
           return '\''.$string.'\'';
       }

      private function _interpolateTalesVarsStructure($matches) {
          return "<?php echo ".phptal_tales($matches[1])." ?>";
      }
 
      private function _interpolateTalesVarsEscaped($matches) {
          return "<?php echo 
phptal_escape(".phptal_tales($matches[1]).", ENT_QUOTES, 
'".$this->_encoding."');?>";
      }
 
       public function interpolateTalesVarsInHtml($src)
       {
           if ($this->_talesMode == 'tales'){
!             $result = preg_replace_callback(
!                 '/(?<!\$)\$\{structure (.*?)\}/ism',
!                 Array($this,"_interpolateTalesVarsStructure"),
!                 $src
!             );
!
!             $result = preg_replace_callback(
!                 '/(?<!\$)\$\{(.*?)\}/ism',
!                 Array($this,"_interpolateTalesVarsEscaped"),
!                 $result
!             );
!
               /*
               $result = preg_replace(
                   '/(?<!\$)\$\{([a-z0-9\/_] )\}/ism',

-- 

Search for products and services at: 
http://search.mail.com




More information about the PHPTAL mailing list