configuration settings.', array('@config' => url('admin/settings/performance'), '@settings' => url('admin/settings/performance/boost')))); // Forcibly disable Drupal's built-in SQL caching to prevent any conflicts of interest: if (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED) { variable_set('cache', CACHE_DISABLED); drupal_set_message(t('Drupal\'s standard page caching disabled by Boost.')); } } /** * Implementation of hook_disable(). */ function boost_disable() { // Make sure that the static page cache is wiped when the module is disabled: boost_cache_clear_all(); drupal_set_message(t('Static page cache cleared.')); } /** * Implementation of hook_install(). */ function boost_install() { // Ensure that the module is loaded early in the bootstrap: db_query("UPDATE {system} SET weight = -90 WHERE name = '%s'", 'boost'); // Create tables. drupal_install_schema('boost'); } /** * Implementation of hook_uninstall(). */ function boost_uninstall() { db_query("DELETE FROM {variable} WHERE name LIKE '%s_%%'", 'boost'); cache_clear_all('variables', 'cache'); // Delete tables. drupal_uninstall_schema('boost'); } /** * Implementation of hook_requirements(). */ function boost_requirements($phase) { $requirements = array(); $t = get_t(); switch ($phase) { case 'runtime': $cache_directories = array(); $cache_directories[] = BOOST_FILE_PATH; if (BOOST_GZIP) { $cache_directories[] = BOOST_GZIP_FILE_PATH; } $htaccess = file_get_contents('.htaccess'); $char = BOOST_CHAR; foreach($cache_directories as $cache_directory) { _boost_mkdir_p($cache_directory); $root_file = file_put_contents($cache_directory . '/' . variable_get('boost_root_file', '.boost'), $cache_directory); if (!is_dir($cache_directory)) { $requirements['boost'] = array( 'title' => $t('Boost'), 'description' => $t('!cache_dir: does not exist.', array('!cache_dir' => $cache_directory)), 'severity' => REQUIREMENT_ERROR, 'value' => $t('Cache path'), ); } elseif (!$root_file || !is_writable($cache_directory)) { $requirements['boost'] = array( 'title' => $t('Boost'), 'description' => $t('Directory %dir credentials - Permissions: %fp. Owner %fo. Group %fg.
Your credentials - Group ID: %gid. User ID: %uid. Current script owner: %user.', array('%dir' => getcwd() . '/' . $cache_directory, '%gid' => getmygid(), '%uid' => getmyuid(), '%user' => get_current_user(), '%fp' => substr(sprintf('%o', fileperms($cache_directory)), -4), '%fo' => fileowner($cache_directory), '%fg' => filegroup($cache_directory) )), 'severity' => REQUIREMENT_ERROR, 'value' => $t('Can not write to file-system'), ); } } if (isset($requirements['boost'])) {} elseif (BOOST_FILE_PATH != boost_cache_directory(NULL, FALSE)) { $requirements['boost'] = array( 'title' => $t('Boost'), 'description' => $t('Cache file path: is not set to the default(!default). ', array('@url' => url('admin/settings/performance/boost#edit-boost-file-path'), '!default' => boost_cache_directory(NULL, FALSE))), 'severity' => REQUIREMENT_WARNING, 'value' => $t('Cache path'), ); } elseif ($htaccess && count(explode("%{REQUEST_URI}$char%{QUERY_STRING}\.html", $htaccess)) < 3) { $requirements['boost'] = array( 'title' => $t('Boost'), 'description' => $t('.htaccess file does not contain the boost specific rewrite rules, or the rewrite rules have changed and they need to be updated. Get rules: Boost Apache .htaccess settings generation.', array('@url' => url('admin/settings/performance/boost#edit-boost-verbose'))), 'severity' => REQUIREMENT_ERROR, 'value' => $t('.htaccess file'), ); } else { $requirements['boost'] = array( 'title' => $t('Boost'), 'severity' => REQUIREMENT_OK, 'value' => t(''), ); } break; } return $requirements; } /** * Implementation of hook_schema(). */ function boost_schema() { $schema['boost_cache'] = array( 'description' => t('List of the cached page'), 'fields' => array( 'filename' => array( 'description' => 'Path of the cached file relative to Drupal webroot.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), 'base_dir' => array( 'description' => 'Path of the cache root dir relative to Drupal webroot.', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'expire' => array( 'description' => t('UNIX timestamp for the expiration date of cached page.'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'lifetime' => array( 'description' => t('Number of seconds this page should be considered fresh. Used to set the expiration column.'), 'type' => 'int', 'not null' => TRUE, 'default' => -1, ), 'push' => array( 'description' => 'A flag to indicate whether page should be crawled so it is fresh in the cache.', 'type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => -1, ), 'page_callback' => array( 'description' => 'The name of the function that renders the page.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), 'page_arguments' => array( 'description' => 'The name of the content type.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), 'page_id' => array( 'description' => 'The ID of the page.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'extension' => array( 'description' => 'File Extension/Mime content type of this page.', 'type' => 'varchar', 'length' => 8, 'not null' => TRUE, 'default' => '', ), 'timer' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Time in milliseconds that the page took to be generated.', ), 'timer_average' => array( 'type' => 'float', 'not null' => TRUE, 'default' => 0, 'description' => 'Average time in milliseconds that the page took to be generated.', ), 'url' => array( 'description' => 'URL of cached page', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), ), 'indexes' => array( 'expire' => array('expire'), 'push' => array('push'), 'base_dir' => array('base_dir'), 'page_id' => array('page_id'), 'timer' => array('timer'), 'timer_average' => array('timer_average'), 'page_callback' => array('page_callback'), 'page_arguments' => array('page_arguments'), 'extension' => array('extension'), ), 'primary key' => array('filename'), ); $schema['boost_cache_settings'] = array( 'description' => t('Boost cache settings'), 'fields' => array( 'csid' => array( 'description' => 'Primary Key: Unique cache settings ID.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE ), 'base_dir' => array( 'description' => 'Path of the cache root dir relative to Drupal webroot.', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', ), 'page_callback' => array( 'description' => 'The name of the function that renders the page.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), 'page_arguments' => array( 'description' => 'The name of the content type.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '0' ), 'page_id' => array( 'description' => 'The ID of the page.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'extension' => array( 'description' => 'File Extension/Mime content type of this page.', 'type' => 'varchar', 'length' => 8, 'not null' => TRUE, 'default' => '', ), 'lifetime' => array( 'description' => t('Number of seconds this page should be considered fresh. Used to set the expiration column.'), 'type' => 'int', 'not null' => TRUE, 'default' => -1, ), 'push' => array( 'description' => 'A flag to indicate whether page should be crawled so it is fresh in the cache.', 'type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => -1, ), ), 'indexes' => array( 'page_callback' => array('page_callback'), 'page_arguments' => array('page_arguments'), 'base_dir' => array('base_dir'), 'page_id' => array('page_id'), 'extension' => array('extension'), ), 'primary key' => array('csid'), ); $schema['boost_crawler'] = array( 'description' => t('Boost crawler - temp table'), 'fields' => array( 'id' => array( 'description' => 'Primary Key: Unique ID.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE ), 'url' => array( 'description' => 'URL of page', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), ), 'primary key' => array('id'), 'unique keys' => array( 'url' => array('url'), ), ); return $schema; } /** * Update 6100 - Install Boost Database. */ function boost_update_6100() { // Create tables. $schema['boost_cache'] = array( 'description' => t('List of the cached page'), 'fields' => array( 'filename' => array( 'description' => 'Path of the cached file relative to Drupal webroot.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), 'url' => array( 'description' => 'URL of cached page', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), 'expire' => array( 'description' => t('UNIX timestamp for the expiration date of cached page.'), 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'lifetime' => array( 'description' => t('Number of seconds this page should be considered fresh. Used to set the expiration column.'), 'type' => 'int', 'not null' => TRUE, 'default' => -1, ), 'push' => array( 'description' => 'A flag to indicate whether page should be crawled so it is fresh in the cache.', 'type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => -1, ), 'page_callback' => array( 'description' => 'The name of the function that renders the page.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), 'page_arguments' => array( 'description' => 'The name of the content type.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), ), 'indexes' => array( 'expire' => array('expire'), 'push' => array('push'), ), 'primary key' => array('filename'), ); $schema['boost_cache_settings'] = array( 'description' => t('Boost cache settings'), 'fields' => array( 'csid' => array( 'description' => 'Primary Key: Unique cache settings ID.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE ), 'page_callback' => array( 'description' => 'The name of the function that renders the page.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), 'page_arguments' => array( 'description' => 'The name of the content type.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '' ), 'lifetime' => array( 'description' => t('Number of seconds this page should be considered fresh. Used to set the expiration column.'), 'type' => 'int', 'not null' => TRUE, 'default' => -1, ), 'push' => array( 'description' => 'A flag to indicate whether page should be crawled so it is fresh in the cache.', 'type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => -1, ), ), 'indexes' => array( 'page_callback' => array('page_callback'), 'page_arguments' => array('page_arguments'), ), 'primary key' => array('csid'), ); $ret = array(); db_create_table($ret, 'boost_cache', $schema['boost_cache']); db_create_table($ret, 'boost_cache_settings', $schema['boost_cache_settings']); return $ret; } /** * Update 6101 - Copy old variable to new one. */ function boost_update_6101() { // copy variable return array(update_sql("UPDATE {variable} SET name = 'boost_enabled' WHERE name = 'boost'")); } /** * Update 6102 - Delete old boost permissions variable. */ function boost_update_6102() { // del variable variable_del('boost_permissions'); return array(array('success' => TRUE, 'query' => 'Old permissions variable deleted.')); } /** * Update 6103 - Add new columns to tables */ function boost_update_6103() { $ret = array(); // Add in base_dir column db_add_field($ret, 'boost_cache', 'base_dir', array( 'description' => 'Path of the cache root dir relative to Drupal webroot.', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', )); db_add_field($ret, 'boost_cache_settings', 'base_dir', array( 'description' => 'Path of the cache root dir relative to Drupal webroot.', 'type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '', )); db_add_index($ret, 'boost_cache', 'base_dir', array('base_dir')); db_add_index($ret, 'boost_cache_settings', 'base_dir', array('base_dir')); // Add in page_id column db_add_field($ret, 'boost_cache', 'page_id', array( 'description' => 'The ID of the page.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, )); db_add_field($ret, 'boost_cache_settings', 'page_id', array( 'description' => 'The ID of the page.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, )); db_add_index($ret, 'boost_cache', 'page_id', array('page_id')); db_add_index($ret, 'boost_cache_settings', 'page_id', array('page_id')); // Add in timer column db_add_field($ret, 'boost_cache', 'timer', array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'Time in milliseconds that the page took to be generated.', )); db_add_index($ret, 'boost_cache', 'timer', array('timer')); // Add in timer_average column db_add_field($ret, 'boost_cache', 'timer_average', array( 'type' => 'float', 'not null' => TRUE, 'default' => 0, 'description' => 'Average time in milliseconds that the page took to be generated.', )); db_add_index($ret, 'boost_cache', 'timer_average', array('timer_average')); // Add indexes db_add_index($ret, 'boost_cache', 'page_callback', array('page_callback')); db_add_index($ret, 'boost_cache', 'page_arguments', array('page_arguments')); // Set Defaults db_field_set_default($ret, 'boost_cache_settings', 'page_arguments', '0'); return $ret; } /** * Update 6104 - Add new column to tables * Add in mime_type column */ function boost_update_6104() { $ret = array(); // Add in extension column db_add_field($ret, 'boost_cache', 'extension', array( 'description' => 'File Extension/Mime content type of this page.', 'type' => 'varchar', 'length' => 8, 'not null' => TRUE, 'default' => '', )); db_add_field($ret, 'boost_cache_settings', 'extension', array( 'description' => 'File Extension/Mime content type of this page.', 'type' => 'varchar', 'length' => 8, 'not null' => TRUE, 'default' => '', )); db_add_index($ret, 'boost_cache', 'extension', array('extension')); db_add_index($ret, 'boost_cache_settings', 'extension', array('extension')); return $ret; } /** * Update 6105 - Add new column to boost_cache table * Add in url column */ function boost_update_6105() { $ret = array(); db_add_field($ret, 'boost_cache', 'url', array( 'description' => 'URL of cached page', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', )); return $ret; } /** * Update 6106 - Add boost_crawler table to DB */ function boost_update_6106() { $schema['boost_crawler'] = array( 'description' => t('Boost crawler - temp table'), 'fields' => array( 'id' => array( 'description' => 'Primary Key: Unique ID.', 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE ), 'url' => array( 'description' => 'URL of page', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), ), 'primary key' => array('id'), 'unique keys' => array( 'url' => array('url'), ), ); $ret = array(); db_create_table($ret, 'boost_crawler', $schema['boost_crawler']); return $ret; }