? boost-385924.1.patch
? boost-385924.patch
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.43
diff -u -p -r1.3.2.2.2.5.2.43 boost.module
--- boost.module	2 Jun 2009 20:08:47 -0000	1.3.2.2.2.5.2.43
+++ boost.module	4 Jun 2009 06:43:14 -0000
@@ -56,6 +56,8 @@ function boost_help($path, $arg) {
     case 'admin/settings/performance/boost':
       return '<p>' . t('') . '</p>'; // TODO: add help text.
   }
+  //hack to get drupal_get_messages before they are destroyed.
+  $GLOBALS['_boost_message_count'] = count(drupal_get_messages(NULL, FALSE));
 }
 
 /**
@@ -315,6 +317,22 @@ function boost_block($op = 'list', $delt
                 'The cached copy will expire in %interval.',
                 array('%interval' => format_interval(abs($ttl))));
             }
+            $error = FALSE;
+            if (function_exists('error_get_last')) {
+              $error = error_get_last();
+            }
+            $drupal_msg = max(count(drupal_get_messages(NULL, FALSE)),$GLOBALS['_boost_message_count']);
+
+            if ($error || $drupal_msg != 0) {
+              $ttl = boost_file_get_ttl(boost_file_path($GLOBALS['_boost_path']));
+              $output = t('There are <strong>php errors</strong> or <strong>drupal messages</strong> on this page, preventing boost from caching.');
+              if ($error){
+                $output .= t(' ERROR: <pre>%error</pre>. %link', array('%error' => print_r($error, TRUE), '%link' => l(t('Lookup Error'), 'http://php.net/errorfunc.constants')));
+              }
+              if ($drupal_msg != 0) {
+                $output .= t(' MESSAGES: %msg', array('%msg' => $drupal_msg));
+              }
+            }
 
             $block['subject'] = '';
             $block['content'] = theme('boost_cache_status', isset($ttl) ? $ttl : -1, $output);
@@ -352,25 +370,27 @@ function _boost_ob_handler($buffer) {
   // Ensure we're in the correct working directory, since some web servers (e.g. Apache) mess this up here.
   chdir(dirname($_SERVER['SCRIPT_FILENAME']));
 
-  if ($error = error_get_last()){
-  switch($error['type']){
-    //case E_NOTICE: //Ignore run-time notices
-    //case E_USER_NOTICE: //Ignore user-generated notice message
-    //case E_DEPRECATED: //Ignore run-time notices
-    //case E_USER_DEPRECATED: //Ignore user-generated notice message
-    //  break;
-    default: //Do not cache page on all other errors
-      return $buffer;
+  if (function_exists('error_get_last')) {
+    if ($error = error_get_last()){
+    switch($error['type']){
+      //case E_NOTICE: //Ignore run-time notices
+      //case E_USER_NOTICE: //Ignore user-generated notice message
+      //case E_DEPRECATED: //Ignore run-time notices
+      //case E_USER_DEPRECATED: //Ignore user-generated notice message
+      //  break;
+      default: //Do not cache page on all other errors
+        return $buffer;
+      }
     }
   }
-  
+
   // Check the currently set content type (at present we can't deal with
   // anything else than HTML) and the HTTP response code. We're going to be
   // exceedingly conservative here and only cache 'text/html' pages that
   // were output with a 200 OK status. Anything more is simply asking for
   // loads of trouble.
   if (   _boost_get_http_status() == 200 
-      && count(drupal_get_messages(NULL, FALSE)) == 0 
+      && $GLOBALS['_boost_message_count'] == 0
       && strlen($buffer) > 0
       ) {
     if (_boost_get_content_type() == 'text/html') {
