diff --git a/advagg_bundler/advagg_bundler.install b/advagg_bundler/advagg_bundler.install index 97893dd..cb6aaf2 100644 --- a/advagg_bundler/advagg_bundler.install +++ b/advagg_bundler/advagg_bundler.install @@ -6,7 +6,14 @@ */ /** - * Implementation of hook_enable(). + * Implements hook_install(). + */ +function advagg_bundler_install() { + drupal_install_schema('advagg_bundler'); +} + +/** + * Implements hook_enable(). */ function advagg_bundler_enable() { // Flush advagg caches. @@ -17,7 +24,7 @@ function advagg_bundler_enable() { } /** - * Implementation of hook_disable(). + * Implements hook_disable(). */ function advagg_bundler_disable() { // Flush advagg caches. @@ -36,7 +43,7 @@ function advagg_bundler_uninstall() { variable_del('advagg_bundler_max_css'); variable_del('advagg_bundler_max_js'); variable_del('advagg_bundler_active'); - + drupal_uninstall_schema('advagg_bundler'); } @@ -54,11 +61,11 @@ function advagg_bundler_requirements($phase) { } /** - * Implementation of hook_schema(). + * Implements hook_schema(). */ function advagg_bundler_schema() { $schema['advagg_bundler_selector_count'] = array( - 'description' => 'Keep track of when ware the files modified.', + 'description' => 'Keep track of when the files were modified.', 'fields' => array( 'filename' => array( 'description' => 'Path of the file relative to Drupal webroot.', @@ -86,44 +93,7 @@ function advagg_bundler_schema() { ), 'primary key' => array('filename_md5'), ); - + return $schema; } -/** - * Add advagg_bundler_selector_count table. - */ -function advagg_bundler_update_6000() { - $schema['advagg_bundler_selector_count'] = array( - 'description' => 'Keep track of when ware the files modified.', - 'fields' => array( - 'filename' => array( - 'description' => 'Path of the file relative to Drupal webroot.', - 'type' => 'text', - 'size' => 'normal', - 'not null' => TRUE, - ), - 'filename_md5' => array( - 'description' => 'MD5 hash of filename', - 'type' => 'varchar', - 'length' => 32, - 'not null' => TRUE, - 'default' => '', - ), - 'selector_count' => array( - 'description' => 'CSS selector count of the file.', - 'type' => 'int', - 'not null' => TRUE, - ), - 'timestamp' => array( - 'description' => 'Last modified timestamp of the file.', - 'type' => 'int', - 'not null' => TRUE, - ), - ), - 'primary key' => array('filename_md5'), - ); - $ret = array(); - db_create_table($ret, 'advagg_bundler_selector_count', $schema['advagg_bundler_selector_count']); - return $ret; -} diff --git a/advagg_bundler/advagg_bundler.module b/advagg_bundler/advagg_bundler.module index 0946fe4..2c66b50 100644 --- a/advagg_bundler/advagg_bundler.module +++ b/advagg_bundler/advagg_bundler.module @@ -63,7 +63,6 @@ function advagg_bundler_advagg_filenames_alter(&$filenames) { // Get max number of sub aggregates to create. $max_css = variable_get('advagg_bundler_max_css', ADVAGG_BUNDLER_MAX_CSS); $max_js = variable_get('advagg_bundler_max_js', ADVAGG_BUNDLER_MAX_JS); - $schema = advagg_get_server_schema(); $output = array(); foreach ($filenames as $values) { @@ -71,7 +70,7 @@ function advagg_bundler_advagg_filenames_alter(&$filenames) { $filetype = $values['filetype']; $files = $values['files']; $bundle_md5 = $values['bundle_md5']; - $cached_data_key = 'bundler_' . $schema . '_' . $bundle_md5; + $cached_data_key = 'bundler_' . $bundle_md5; // Try cache first; cache table is cache_advagg_bundle_reuse. $cached_data = advagg_cached_bundle_get($cached_data_key, 'advagg_bundler_filenames_alter'); @@ -151,7 +150,7 @@ function advagg_bundler_advagg_filenames_alter(&$filenames) { $data = array(); foreach ($groupings as $bundle) { $values['files'] = $bundle; - $values['bundle_md5'] = md5($schema . implode('', $bundle)); + $values['bundle_md5'] = md5(implode('', $bundle)); $data[] = $values; $output[] = $values; } @@ -201,7 +200,7 @@ function advagg_bundler_analysis($filename = '', $force = FALSE) { filename FROM ( SELECT - LPAD(CAST(COUNT(*) AS char(8)), 8, '0') AS count, + LPAD(COUNT(*), 8, '00000000') AS count, bundle_md5, filename_md5 FROM @@ -256,8 +255,6 @@ function advagg_bundler_analysis($filename = '', $force = FALSE) { * array of requested groups * @param $max * max number of grouping - * @param $filetype - * String with the file type: css or js */ function advagg_bundler_merge(&$groupings, $max, $filetype) { $group_count = count($groupings); @@ -311,9 +308,7 @@ function advagg_bundler_merge(&$groupings, $max, $filetype) { } } -// watchdog('debug', $first . "
\n" . $last . "
\n" . str_replace(' ', '    ', nl2br(htmlentities(print_r(array($groupings, $map, $counts), TRUE))))); - - // Create the new merged set + // Create the new merged set. $a = $groupings[$first]; $b = $groupings[$last]; $new_set = array_merge($a, $b); @@ -429,17 +424,14 @@ function advagg_bundler_merge(&$groupings, $max, $filetype) { } } while ($groupings_edited); } - - // Output Debugging info to watchdog. - // watchdog('debug', str_replace(' ', '    ', nl2br(htmlentities(print_r($groupings, TRUE))))); } /** * Gets the selector count of the provided files. - * + * * @param array $files * Array of files to use. - * + * * @return array * The selector counts of each file. */