[TYPO3-core] RFC: feature #2743

Wolfgang Klinger wolfgang at stufenlos.net
Sat Mar 11 15:49:16 CET 2006


 *hiya!*

 On Thu, 09 Mar 2006, Wolfgang Klinger wrote the following:
> >  Speed up substituteConstants with preg_replace_callback
> >  BT reference: http://bugs.typo3.org/view.php?id=2743
> > 
> >  preg_replace_callback is available with PHP >= 4.0.5
> 
>  Committed to CVS.

 Committed a patch to fix a problem with recursive constant
 substitution, see http://bugs.typo3.org/view.php?id=2743 for details.


 bye
 Wolfgang

-------------- next part --------------
--- TYPO3core/t3lib/class.t3lib_tstemplate.php  2006-03-09 10:48:53.000000000 +0100
+++ TYPO3core_testing/t3lib/class.t3lib_tstemplate.php  2006-03-11 15:31:04.000000000 +0100
@@ -966,7 +966,17 @@
        function substituteConstants($all)      {
                if ($this->tt_track)    $GLOBALS['TT']->setTSlogMessage('Constants to substitute: '.count($this->flatSetup));

-               return preg_replace_callback('/\{\$(.[^}]+)\}/', array($this, 'substituteConstantsCallBack'), $all);
+               $noChange = false;
+               // recursive substitution of constants (up to 10 nested levels)
+               for ($i = 0; $i < 10 && !$noChange; $i++) {
+                       $old_all = $all;
+                       $all = preg_replace_callback('/\{\$(.[^}]*)\}/', array($this, 'substituteConstantsCallBack'), $all);
+                       if ($old_all == $all) {
+                               $noChange = true;
+                       }
+               }
+
+               return $all;
        }

        /**


More information about the TYPO3-team-core mailing list