diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-04-24 08:23:02 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-04-24 08:23:02 +0000 |
commit | 6e334892f2df1f744bdc305570b82f79b2a6cfd2 (patch) | |
tree | bd28ef6048e5b046775cd09275dd8af230d649ac /modules | |
parent | e99838fbf488d9bca18f56e7ea6aee32d563ab68 (diff) | |
download | brdo-6e334892f2df1f744bdc305570b82f79b2a6cfd2.tar.gz brdo-6e334892f2df1f744bdc305570b82f79b2a6cfd2.tar.bz2 |
- Patch #440768 by Dave Reid: move {node_counter} table from node module to statistics module.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/node/node.install | 53 | ||||
-rw-r--r-- | modules/node/node.module | 2 | ||||
-rw-r--r-- | modules/statistics/statistics.install | 66 | ||||
-rw-r--r-- | modules/statistics/statistics.module | 7 |
4 files changed, 69 insertions, 59 deletions
diff --git a/modules/node/node.install b/modules/node/node.install index b1ab08d64..11ced749a 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -174,42 +174,6 @@ function node_schema() { 'primary key' => array('nid', 'gid', 'realm'), ); - $schema['node_counter'] = array( - 'description' => 'Access statistics for {node}s.', - 'fields' => array( - 'nid' => array( - 'description' => 'The {node}.nid for these statistics.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'totalcount' => array( - 'description' => 'The total number of times the {node} has been viewed.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'size' => 'big', - ), - 'daycount' => array( - 'description' => 'The total number of times the {node} has been viewed today.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'size' => 'medium', - ), - 'timestamp' => array( - 'description' => 'The most recent time the {node} has been viewed.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - ), - 'primary key' => array('nid'), - ); - $schema['node_revision'] = array( 'description' => 'Stores information about each saved version of a {node}.', 'fields' => array( @@ -382,7 +346,8 @@ function node_schema() { } /** - * Drupal 6.x to 7.x updates + * @defgroup updates-6.x-to-7.x System updates from 6.x to 7.x + * @{ */ /** @@ -417,5 +382,17 @@ function node_update_7002() { } /** - * End of 6.x to 7.x updates + * Remove the node_counter if the statistics module is uninstalled. + */ +function node_update_7003() { + $ret = array(); + if (!drupal_get_installed_schema_version('statistics')) { + db_drop_table($ret, 'node_counter'); + } + return $ret; +} + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. */ diff --git a/modules/node/node.module b/modules/node/node.module index df85fbeaf..a207f44d3 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -2086,8 +2086,6 @@ function node_page_view($node) { function node_update_index() { $limit = (int)variable_get('search_cron_limit', 100); - variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}')))); - $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit); while ($node = db_fetch_object($result)) { diff --git a/modules/statistics/statistics.install b/modules/statistics/statistics.install index e835cf317..4b3141d80 100644 --- a/modules/statistics/statistics.install +++ b/modules/statistics/statistics.install @@ -10,31 +10,13 @@ function statistics_install() { } /** - * Changes session ID field to VARCHAR(64) to add support for SHA-1 hashes. - */ -function statistics_update_1000() { - $ret = array(); - - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - $ret[] = update_sql("ALTER TABLE {accesslog} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''"); - break; - case 'pgsql': - db_change_column($ret, 'accesslog', 'sid', 'sid', 'varchar(64)', array('not null' => TRUE, 'default' => "''")); - break; - } - - return $ret; -} - -/** * Implementation of hook_uninstall(). */ function statistics_uninstall() { // Remove tables. drupal_uninstall_schema('statistics'); + // Remove variables. variable_del('statistics_count_content_views'); variable_del('statistics_enable_access_log'); variable_del('statistics_flush_accesslog_timer'); @@ -115,10 +97,51 @@ function statistics_schema() { 'primary key' => array('aid'), ); + $schema['node_counter'] = array( + 'description' => 'Access statistics for {node}s.', + 'fields' => array( + 'nid' => array( + 'description' => 'The {node}.nid for these statistics.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'totalcount' => array( + 'description' => 'The total number of times the {node} has been viewed.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'size' => 'big', + ), + 'daycount' => array( + 'description' => 'The total number of times the {node} has been viewed today.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'size' => 'medium', + ), + 'timestamp' => array( + 'description' => 'The most recent time the {node} has been viewed.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('nid'), + ); + return $schema; } /** + * @defgroup updates-6.x-to-7.x System updates from 6.x to 7.x + * @{ + */ + +/** * Allow longer referrers. */ function statistics_update_7000() { @@ -126,3 +149,8 @@ function statistics_update_7000() { db_change_field($ret, 'accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE)); return $ret; } + +/** + * @} End of "defgroup updates-6.x-to-7.x" + * The next series of updates should start at 8000. + */ diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 57407872f..eea3a078c 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -388,3 +388,10 @@ function statistics_ranking() { ); } } + +/** + * Implementation of hook_update_index(). + */ +function statistics_update_index() { + variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}')))); +} |