? boost-385924.2.patch ? boost-385924.3.patch Index: boost.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.admin.inc,v retrieving revision 1.1.2.1.2.3.2.20 diff -u -p -r1.1.2.1.2.3.2.20 boost.admin.inc --- boost.admin.inc 2 Jun 2009 20:08:47 -0000 1.1.2.1.2.3.2.20 +++ boost.admin.inc 4 Jun 2009 08:31:54 -0000 @@ -133,6 +133,12 @@ function boost_admin_settings($form = ar '#default_value' => BOOST_CLEAR_CACHE_OFFLINE, '#description' => t('Under site maintenance when the status is set to offline, boost clears its cache. If you do not want this to happen, clear this checkbox. Pages that are not cached will still send out a Site off-line message, so be smart if turning this off.'), ); + $form['advanced']['boost_halt_on_errors'] = array( + '#type' => 'checkbox', + '#title' => t('Do not cache if error on page'), + '#default_value' => BOOST_HALT_ON_ERRORS, + '#description' => t('Boost will not cache the page if there are PHP errors or drupal messages. Disable this if you want to cache pages even if it might contain errors.'), + ); $form['advanced']['boost_multisite_single_db'] = array( '#type' => 'checkbox', '#title' => t('Do not store the cache file path in the database'), 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 08:31:54 -0000 @@ -26,6 +26,7 @@ define('BOOST_ONLY_ASCII_PATH', var define('BOOST_GZIP', variable_get('boost_gzip', TRUE)); define('BOOST_GZIP_FILE_PATH', str_replace(BOOST_ROOT_CACHE_PATH . '/', BOOST_ROOT_CACHE_PATH . '/gz/', BOOST_FILE_PATH)); define('BOOST_CLEAR_CACHE_OFFLINE', variable_get('boost_clear_cache_offline', TRUE)); +define('BOOST_HALT_ON_ERRORS', variable_get('boost_halt_on_errors', TRUE)); // This cookie is set for all authenticated users, so that they can be @@ -56,6 +57,8 @@ function boost_help($path, $arg) { case 'admin/settings/performance/boost': return '
' . t('') . '
'; // 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 +318,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 (BOOST_HALT_ON_ERRORS && ($error || $drupal_msg != 0)) { + $ttl = boost_file_get_ttl(boost_file_path($GLOBALS['_boost_path'])); + $output = t('There are php errors or drupal messages on this page, preventing boost from caching.'); + if ($error){ + $output .= t(' ERROR:%error. %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,27 +371,30 @@ 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 (BOOST_HALT_ON_ERRORS && $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 (BOOST_HALT_ON_ERRORS && $GLOBALS['_boost_message_count'] != 0) { + 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 - && strlen($buffer) > 0 - ) { + if (_boost_get_http_status() == 200 && strlen($buffer) > 0) { if (_boost_get_content_type() == 'text/html') { boost_cache_set($GLOBALS['_boost_path'], $buffer); }