Author: sevein
Date: Thu Dec  8 21:32:39 2011
New Revision: 10387

Log:
Keep thumbnail adapter in memory because its calculation is slow

Modified:
   trunk/lib/model/QubitDigitalObject.php

Modified: trunk/lib/model/QubitDigitalObject.php
==============================================================================
--- trunk/lib/model/QubitDigitalObject.php      Thu Dec  8 16:56:26 2011        
(r10386)
+++ trunk/lib/model/QubitDigitalObject.php      Thu Dec  8 21:32:39 2011        
(r10387)
@@ -1409,12 +1409,20 @@
 
   /**
    * Get a valid adapter for the sfThumbnail library (either GD or ImageMagick)
+   * Cache the adapter value because is very expensive to calculate it
    *
    * @return mixed  name of adapter on success, false on failure
    */
   public static function getThumbnailAdapter()
   {
     $adapter = false;
+
+    $context = sfContext::getInstance();
+    if ($context->has('thumbnailAdapter'))
+    {
+      return $context->get('thumbnailAdapter');
+    }
+
     if (QubitDigitalObject::hasImageMagick())
     {
       $adapter = 'sfImageMagickAdapter';
@@ -1424,6 +1432,8 @@
       $adapter = 'sfGDAdapter';
     }
 
+    $context->set('thumbnailAdapter', $adapter);
+
     return $adapter;
   }
 

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to