diff --git a/INSTALL.txt b/INSTALL.txt index c2927714d7a9101b98f56c6a21b45219e0b91859..0abc2fadcd07ed9e56d07490e7f4a9f7cd1ddc78 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -2,7 +2,7 @@ REQUIREMENTS ------------ -This version of Boost is designed for Drupal 4.7 running on a Unix platform. +This version of Boost is designed for Drupal 6.x running on a Unix platform. Drupal's clean URLs MUST be enabled and working properly. The `path' and `pathauto' modules are recommended. diff --git a/README.txt b/README.txt index d3ee85affc0b3d94683d0f6be7cada4eb22a5ff2..8c2cbc42ffbe4d87ea6b62a6188173fabd006e88 100644 --- a/README.txt +++ b/README.txt @@ -2,7 +2,7 @@ DESCRIPTION ----------- -This module provides static page caching for Drupal 5.x, enabling a +This module provides static page caching for Drupal 6.x, enabling a potentially very significant performance and scalability boost for heavily-trafficked Drupal sites. diff --git a/boost.admin.inc b/boost.admin.inc index e3c9d527a58c568400be6a7d18c5f568283409d8..2dd56f69e3bb9eea3ab7afab6582b97b576b95c9 100644 --- a/boost.admin.inc +++ b/boost.admin.inc @@ -14,7 +14,7 @@ * * Called from hook_form_alter(). */ -function boost_system_settings_form($form = array()) { +function boost_system_settings_form($form = array()) { $form['cache'] = array('#type' => 'hidden','#value' => CACHE_DISABLED); $form['boost'] = array( '#type' => 'radios', @@ -46,11 +46,12 @@ function boost_system_settings_form($form = array()) { /** * Declares administrative settings for the Boost module. * - * Called from hook_settings(). + * @see system_settings_form + * @ingroup forms */ -function boost_settings_form($form = array()) { +function boost_admin_settings($form = array()) { //_boost_check_htaccess(); // TODO - + $options = array(t('Cache every page except the listed pages.'), t('Cache only the listed pages.')); $description = t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '%blog' for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => theme('placeholder', 'blog'), '%blog-wildcard' => theme('placeholder', 'blog/*'), '%front' => theme('placeholder', ''))); if (user_access('use PHP for block visibility')) { @@ -75,20 +76,6 @@ function boost_settings_form($form = array()) { '#description' => $description, ); - // TODO - /*$form['throttle'] = array( - '#type' => 'fieldset', - '#title' => t('Throttle settings'), - '#collapsible' => FALSE, - ); - $form['throttle']['boost_cron_limit'] = array( - '#type' => 'select', - '#title' => t('Pages to update per cron run'), - '#default_value' => BOOST_CRON_LIMIT, - '#options' => drupal_map_assoc(array(10, 20, 50, 100, 200, 500, 1000)), - '#description' => t('The maximum number of static pages that will be built or rebuilt in one cron run. Set this number lower if your cron is timing out or if PHP is running out of memory.'), - );*/ - $form['advanced'] = array( '#type' => 'fieldset', '#title' => t('Advanced settings'), @@ -127,7 +114,7 @@ function boost_settings_form($form = array()) { '#description' => t('If you are synchronizing the generated static cache files to an external server through some means such as SFTP or rsync, you can enter a shell command to be executed following a successful cron-triggered cache update. Note that this is an advanced setting that should normally be left blank.'), );*/ - return $form; + return system_settings_form($form); } ////////////////////////////////////////////////////////////////////////////// diff --git a/boost.api.inc b/boost.api.inc index 09afb94f75eb07e615046f7fa52be7abd98fd2e9..ac3038e1966b466e8818410c40b9168e7061f60a 100644 --- a/boost.api.inc +++ b/boost.api.inc @@ -135,7 +135,7 @@ function boost_cache_set($path, $data = '') { _boost_mkdir_p(dirname($filename)); if (!file_exists($filename) || boost_file_is_expired($filename)) { if (file_put_contents($filename, $data) === FALSE) { - watchdog('boost', t('Unable to write file: %file', array('%file' => $filename)), WATCHDOG_WARNING); + watchdog('boost', 'Unable to write file: %file', array('%file' => $filename), array(), WATCHDOG_WARNING); } } @@ -147,7 +147,7 @@ function boost_cache_set($path, $data = '') { @unlink($symlink); } if (!_boost_symlink($filename, $symlink)) { - watchdog('boost', t('Unable to create symlink: %link to %target', array('%link' => $symlink, '%target' => $filename)), WATCHDOG_WARNING); + watchdog('boost', 'Unable to create symlink: %link to %target', array('%link' => $symlink, '%target' => $filename), array(), WATCHDOG_WARNING); } } } diff --git a/boost.info b/boost.info index b51760a37dbbc3ff73a2f738fd419042a4a4baf2..54550b05734f81452a6414bf04443384179808e6 100644 --- a/boost.info +++ b/boost.info @@ -2,3 +2,4 @@ name = Boost description = Provides a performance and scalability boost through caching Drupal pages as static HTML files. package = Caching +core = 6.x diff --git a/boost.module b/boost.module index 96057b5fb13864ec2817199411587e20640b908d..f1990123b0611516b059aa9e66ed09a1edb4d0ec 100644 --- a/boost.module +++ b/boost.module @@ -10,8 +10,8 @@ // BOOST SETTINGS define('BOOST_PATH', dirname(__FILE__)); -define('BOOST_FRONTPAGE', drupal_get_normal_path(variable_get('site_frontpage', 'node'))); +// BOOST_FRONTPAGE now hidden in boost_init due to bootstrap changes in D6 define('BOOST_ENABLED', variable_get('boost', CACHE_DISABLED)); define('BOOST_FILE_PATH', variable_get('boost_file_path', 'cache')); define('BOOST_FILE_EXTENSION', variable_get('boost_file_extension', '.html')); @@ -47,8 +47,8 @@ require_once BOOST_PATH . '/boost.api.inc'; /** * Implementation of hook_help(). Provides online user help. */ -function boost_help($section) { - switch ($section) { +function boost_help($path, $arg) { + switch ($path) { case 'admin/modules#name': return t('boost'); case 'admin/modules#description': @@ -63,41 +63,33 @@ function boost_help($section) { } } -/** - * Implementation of hook_perm(). Defines user permissions. - */ -function boost_perm() { - return array('administer cache'); -} - /** * Implementation of hook_menu(). Defines menu items and page callbacks. */ -function boost_menu($may_cache) { - $access = user_access('administer cache'); +function boost_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/performance/boost', + $items['admin/settings/performance/boost'] = array( 'title' => t('Boost'), - 'description' => t('Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('boost_settings'), - 'access' => user_access('administer site configuration'), + 'description' => t('Configure static page cache settings.'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('boost_admin_settings'), + 'access arguments' => array('administer site configuration'), + 'file' => 'boost.admin.inc' ); // TODO: define menu actions for cache administration. - } return $items; } /** - * Implementation of hook_init(). Performs page setup tasks. + * Implementation of hook_init(). Performs page setup tasks if page not cached. */ function boost_init() { // Stop right here unless we're being called for an ordinary page request if (strpos($_SERVER['PHP_SELF'], 'index.php') === FALSE) return; - + + // hidden here as d6 loads path.inc after parsing this file looking for hook_boot + define('BOOST_FRONTPAGE', drupal_get_normal_path(variable_get('site_frontpage', 'node'))); // TODO: check interaction with other modules that use ob_start(); this // may have to be moved to an earlier stage of the page request. if (!variable_get('cache', CACHE_DISABLED) && BOOST_ENABLED) { @@ -181,7 +173,7 @@ function boost_exit($destination = NULL) { * Implementation of hook_form_alter(). Performs alterations before a form * is rendered. */ -function boost_form_alter($form_id, &$form) { +function boost_form_alter(&$form, &$form_state, $form_id ) { // Alter Drupal's settings form by hiding the default cache enabled/disabled control (which will now always default to CACHE_DISABLED), and add our own control instead. if ($form_id == 'system_performance_settings') { require_once BOOST_PATH . '/boost.admin.inc'; @@ -196,7 +188,7 @@ function boost_cron() { if (!BOOST_ENABLED) return; if (boost_cache_expire_all()) { - watchdog('boost', t('Expired stale files from static page cache.'), WATCHDOG_NOTICE); + watchdog('boost', 'Expired stale files from static page cache.', array(), WATCHDOG_NOTICE); } } @@ -277,16 +269,6 @@ function boost_user($op, &$edit, &$account, $category = NULL) { } } -/** - * Implementation of hook_settings(). Declares administrative settings for a module. - * - * @deprecated in Drupal 5.0. - */ -function boost_settings() { - require_once BOOST_PATH . '/boost.admin.inc'; - return system_settings_form(boost_settings_form()); -} - ////////////////////////////////////////////////////////////////////////////// // OUTPUT BUFFERING CALLBACK