Author: Raymond Bosman
Date: 2007-01-23 15:52:04 +0100 (Tue, 23 Jan 2007)
New Revision: 4548

Log:
- Try to fix caching but got lots of PDO segfaults. Trying it on another 
installation.

Modified:
   trunk/Template/src/cache_filesystem.php
   trunk/Template/src/configuration.php
   trunk/Template/src/parsers/source_to_tst/implementations/cache.php
   
trunk/Template/src/parsers/tst_to_ast/implementations/tst_to_ast_cached_transformer.php
   
trunk/Template/src/parsers/tst_to_ast/implementations/tst_to_ast_transformer.php
   trunk/Template/src/template.php

Modified: trunk/Template/src/cache_filesystem.php
===================================================================
--- trunk/Template/src/cache_filesystem.php     2007-01-23 12:41:13 UTC (rev 
4547)
+++ trunk/Template/src/cache_filesystem.php     2007-01-23 14:52:04 UTC (rev 
4548)
@@ -78,7 +78,19 @@
      */
     protected function notFileExistsCache()
     {
-        return new ezcTemplateLogicalNegationOperatorAstNode( new 
ezcTemplateFunctionCallAstNode( "file_exists", array( new 
ezcTemplateVariableAstNode( "_ezcTemplateCache" ) ) ) );
+        if( $this->config->cacheManager !== false )
+        {
+            // !$this->config->cacheManager->isValid( $cacheName ) || 
!file_exist()
+            $a = new ezcTemplateLogicalNegationOperatorAstNode( new 
ezcTemplateFunctionCallAstNode( 
"\$this->template->configuration->cacheManager->isValid", array( new 
ezcTemplateVariableAstNode( "_ezcTemplateCache" ) ) ) );
+            $b = new ezcTemplateLogicalNegationOperatorAstNode( new 
ezcTemplateFunctionCallAstNode( "file_exists", array( new 
ezcTemplateVariableAstNode( "_ezcTemplateCache" ) ) ) );
+            
+           return new ezcTemplateLogicalOrOperatorAstNode( $a, $b );
+        }
+        else
+        {
+
+            return new ezcTemplateLogicalNegationOperatorAstNode( new 
ezcTemplateFunctionCallAstNode( "file_exists", array( new 
ezcTemplateVariableAstNode( "_ezcTemplateCache" ) ) ) );
+        }
     }
 
 

Modified: trunk/Template/src/configuration.php
===================================================================
--- trunk/Template/src/configuration.php        2007-01-23 12:41:13 UTC (rev 
4547)
+++ trunk/Template/src/configuration.php        2007-01-23 14:52:04 UTC (rev 
4548)
@@ -72,6 +72,7 @@
      * @var array(string=>mixed)
      */
      private $properties = array( 'context' => false,
+                                  'cacheManager' => false,
                                   'templatePath' => ".",
                                   'compilePath' => ".",
                                   'cachedTemplatesPath' => null,
@@ -96,6 +97,7 @@
         switch ( $name )
         {
             case 'context': 
+            case 'cacheManager':
             case 'templatePath': 
             case 'compilePath': 
             case 'cachedTemplatesPath':       // Relative path to the 
compilePath
@@ -143,6 +145,15 @@
                 $this->properties[$name] = $value;
                 break;
 
+            case 'cacheManager': 
+/*                if ( !$value instanceof ezcTemplateOutputContext )
+                {
+                    throw new ezcBaseValueException( $name, $value, 
'ezcTemplateContext' );
+                }
+ */
+                $this->properties[$name] = $value;
+                break;
+
             case 'templatePath': 
             case 'compilePath': 
             case 'cachedTemplatesPath':
@@ -173,6 +184,9 @@
             case 'context': 
                 return true;
 
+            case 'cacheManager': 
+                return true;
+
             case 'templatePath': 
             case 'compilePath':
             case 'cachedTemplatesPath':

Modified: trunk/Template/src/parsers/source_to_tst/implementations/cache.php
===================================================================
--- trunk/Template/src/parsers/source_to_tst/implementations/cache.php  
2007-01-23 12:41:13 UTC (rev 4547)
+++ trunk/Template/src/parsers/source_to_tst/implementations/cache.php  
2007-01-23 14:52:04 UTC (rev 4548)
@@ -39,7 +39,7 @@
     protected function parseCurrent( ezcTemplateCursor $cursor )
     {
         // Disable caching.
-        return false;
+        //return false;
 
         if ( $cursor->match( "dynamic" ) )
         {

Modified: 
trunk/Template/src/parsers/tst_to_ast/implementations/tst_to_ast_cached_transformer.php
===================================================================
--- 
trunk/Template/src/parsers/tst_to_ast/implementations/tst_to_ast_cached_transformer.php
     2007-01-23 12:41:13 UTC (rev 4547)
+++ 
trunk/Template/src/parsers/tst_to_ast/implementations/tst_to_ast_cached_transformer.php
     2007-01-23 14:52:04 UTC (rev 4548)
@@ -212,15 +212,23 @@
             // $cb->body->statements = $type->statements;
 
 
-                  // Inside.
-        $cb->body->appendStatement( $this->_fopenCacheFileWriteMode() ); // 
$fp = fopen( $this->cache, "w" ); 
+            // Inside.
 
-        $cb->body->appendStatement( $this->_fwritePhpOpen() );                 
// fwrite( $fp, "<" . "?php\n" );
-        $cb->body->appendStatement( $this->_assignEmptyString("total") );      
// $total = ""
-        $cb->body->appendStatement( $this->_fwriteLiteral( "\$" . 
self::INTERNAL_PREFIX . "output = '';\n") );      // fwrite( $fp, 
"\\\$_ezcTemplate_output = '';\\n" );
+            /// startCaching(); 
+            
+            if ($this->template->configuration->cacheManager !== false )
+            {
+                $cb->body->appendStatement( new 
ezcTemplateGenericStatementAstNode( new ezcTemplateFunctionCallAstNode( 
"\$this->template->configuration->cacheManager->startCaching", array( new 
ezcTemplateVariableAstNode("_ezcTemplateCache" ) ) ) ) );// new 
ezcTemplatePhpCodeAstNode( "startCaching();\n" ) );
+            }
+          
+            $cb->body->appendStatement( $this->_fopenCacheFileWriteMode() ); 
// $fp = fopen( $this->cache, "w" ); 
 
+            $cb->body->appendStatement( $this->_fwritePhpOpen() );             
    // fwrite( $fp, "<" . "?php\n" );
+            $cb->body->appendStatement( $this->_assignEmptyString("total") );  
    // $total = ""
+            $cb->body->appendStatement( $this->_fwriteLiteral( "\$" . 
self::INTERNAL_PREFIX . "output = '';\n") );      // fwrite( $fp, 
"\\\$_ezcTemplate_output = '';\\n" );
 
 
+
             // XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
             foreach ( $type->elements as $element )
@@ -272,15 +280,15 @@
 
             // Outside.
         
-        // Add the 'use' statement, that is removed by the prepareCache walker.
-        // XXX can probably be an array, test it.
-        foreach ( $this->preparedCache->useVariableTst as $useVariable)
-        {
-            $use = $useVariable->accept($this);
-            $this->programNode->appendStatement( $use );
-        }
+            // Add the 'use' statement, that is removed by the prepareCache 
walker.
+            // XXX can probably be an array, test it.
+            foreach ( $this->preparedCache->useVariableTst as $useVariable)
+            {
+                $use = $useVariable->accept($this);
+                $this->programNode->appendStatement( $use );
+            }
 
-        
+            
             $ttlStatements = $this->cacheSystem->checkTTL();
             foreach ( $ttlStatements as $s )
             {
@@ -365,7 +373,7 @@
         {
             if (array_key_exists( $s, $this->declaredVariables ) )
             {
-                $newStatement[] = $this->_fwriteVarExportVariable( "_ezc_".$s, 
false, false );
+                $newStatement[] = $this->_fwriteVarExportVariable( "t_".$s, 
false, false );
             }
         }
         

Modified: 
trunk/Template/src/parsers/tst_to_ast/implementations/tst_to_ast_transformer.php
===================================================================
--- 
trunk/Template/src/parsers/tst_to_ast/implementations/tst_to_ast_transformer.php
    2007-01-23 12:41:13 UTC (rev 4547)
+++ 
trunk/Template/src/parsers/tst_to_ast/implementations/tst_to_ast_transformer.php
    2007-01-23 14:52:04 UTC (rev 4548)
@@ -166,7 +166,7 @@
      * @param string $name
      * @return ezcTemplateVariableAstNode
      */
-    private function createVariableNode( $name )
+    protected function createVariableNode( $name )
     {
         $node = new ezcTemplateVariableAstNode( $name );
         $symbolTable = ezcTemplateSymbolTable::getInstance();

Modified: trunk/Template/src/template.php
===================================================================
--- trunk/Template/src/template.php     2007-01-23 12:41:13 UTC (rev 4547)
+++ trunk/Template/src/template.php     2007-01-23 14:52:04 UTC (rev 4548)
@@ -116,6 +116,7 @@
      * @throws ezcBasePropertyNotFoundException if the property does not exist.
      * @param string $name
      * @return mixed
+     * @ignore
      */
     public function __get( $name )
     {
@@ -150,6 +151,7 @@
      *
      * @param string $name
      * @return bool
+     * @ignore
      */
     public function __isset( $name )
     {
@@ -176,6 +178,7 @@
      * @param string $name
      * @param mixed $value
      * @return void
+     * @ignore
      */
     public function __set( $name, $value )
     {

-- 
svn-components mailing list
svn-components@lists.ez.no
http://lists.ez.no/mailman/listinfo/svn-components

Reply via email to