diff options
-rw-r--r-- | database/database.mssql | 18 | ||||
-rw-r--r-- | database/database.mysql | 10 | ||||
-rw-r--r-- | database/database.pgsql | 42 | ||||
-rw-r--r-- | includes/common.inc | 2 | ||||
-rw-r--r-- | modules/node.module | 8 | ||||
-rw-r--r-- | modules/node/node.module | 8 | ||||
-rw-r--r-- | modules/path.module | 26 | ||||
-rw-r--r-- | modules/path/path.module | 26 | ||||
-rw-r--r-- | modules/statistics.module | 16 | ||||
-rw-r--r-- | modules/statistics/statistics.module | 16 | ||||
-rw-r--r-- | update.php | 54 |
11 files changed, 126 insertions, 100 deletions
diff --git a/database/database.mssql b/database/database.mssql index f323cd207..21a8d7274 100644 --- a/database/database.mssql +++ b/database/database.mssql @@ -214,21 +214,21 @@ CREATE TABLE [dbo].[page] ( ) ON [PRIMARY] GO -CREATE TABLE [dbo].[path] ( +CREATE TABLE [dbo].[url_alias] ( [pid] numeric (10, 0) NOT NULL, [dst] [varchar] (128) NOT NULL, [src] [varchar] (128) NOT NULL ) ON [PRIMARY] GO -ALTER TABLE [dbo].[path] WITH NOCHECK ADD - CONSTRAINT [DF_[path_pid] DEFAULT (0) FOR [pid], - CONSTRAINT [DF_path_dst] DEFAULT ('') FOR [dst], - CONSTRAINT [DF_path_src] DEFAULT ('') FOR [src] +ALTER TABLE [dbo].[url_alias] WITH NOCHECK ADD + CONSTRAINT [DF_[url_alias_pid] DEFAULT (0) FOR [pid], + CONSTRAINT [DF_url_alias_dst] DEFAULT ('') FOR [dst], + CONSTRAINT [DF_url_alias_src] DEFAULT ('') FOR [src] GO -CREATE INDEX [path_src_idx] ON [dbo].[path]([src]) ON [PRIMARY] -CREATE INDEX path_dst_idx ON path(dst); +CREATE INDEX [url_alias_src_idx] ON [dbo].[url_alias]([src]) ON [PRIMARY] +CREATE INDEX url_alias_dst_idx ON url_alias(dst); GO CREATE TABLE [dbo].[permission] ( @@ -298,7 +298,7 @@ CREATE TABLE [dbo].[site] ( ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO -CREATE TABLE [dbo].[statistics] ( +CREATE TABLE [dbo].[node_counter] ( [nid] [int] NOT NULL , [totalcount] [numeric](20, 0) NOT NULL , [daycount] [numeric](4, 0) NOT NULL , @@ -500,7 +500,7 @@ INSERT INTO system VALUES ('modules/story.module','story','module','',1); INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1); INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1); -INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2002-05-15";'); +INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-10-22";'); INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";'); INSERT INTO users(uid,name,mail,rid) VALUES(0,'Anonymous','root@localhost','1'); diff --git a/database/database.mysql b/database/database.mysql index ef5076355..115a73674 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -302,10 +302,10 @@ CREATE TABLE page ( ) TYPE=MyISAM; -- --- Table structure for table 'path' +-- Table structure for table 'url_alias' -- -CREATE TABLE path ( +CREATE TABLE url_alias ( pid int(10) unsigned NOT NULL auto_increment, src varchar(128) NOT NULL default '', dst varchar(128) NOT NULL default '', @@ -421,10 +421,10 @@ CREATE TABLE site ( ) TYPE=MyISAM; -- --- Table structure for table 'statistics' +-- Table structure for table 'node_counter' -- -CREATE TABLE statistics ( +CREATE TABLE node_counter ( nid int(11) NOT NULL default '0', totalcount bigint(20) unsigned NOT NULL default '0', daycount mediumint(8) unsigned NOT NULL default '0', @@ -590,7 +590,7 @@ INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1); INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1); INSERT INTO users (uid, name, mail, rid) VALUES ('0', 'Anonymous', 'root@localhost', '1'); -REPLACE variable SET name='update_start', value='s:10:"2003-09-29;"'; +REPLACE variable SET name='update_start', value='s:10:"2003-10-22;"'; REPLACE variable SET name='theme_default', value='s:6:"marvin";'; REPLACE blocks SET module = 'user', delta = '0', status = '1'; diff --git a/database/database.pgsql b/database/database.pgsql index cba2ca5db..4bf21d875 100644 --- a/database/database.pgsql +++ b/database/database.pgsql @@ -288,6 +288,21 @@ CREATE INDEX node_moderate_idx ON node (moderate); CREATE INDEX node_promote_status_idx ON node (promote, status); -- +-- Table structure for table 'node_counter' +-- + +CREATE TABLE node_counter ( + nid integer NOT NULL default '0', + totalcount integer NOT NULL default '0', + daycount integer NOT NULL default '0', + timestamp integer NOT NULL default '0', + PRIMARY KEY (nid) +); +CREATE INDEX node_counter_totalcount_idx ON node_counter(totalcount); +CREATE INDEX node_counter_daycount_idx ON node_counter(daycount); +CREATE INDEX node_counter_timestamp_idx ON node_counter(timestamp); + +-- -- Table structure for page -- @@ -301,18 +316,17 @@ CREATE TABLE page ( CREATE INDEX page_nid_idx ON page(nid); -- --- Table structure for table 'path' +-- Table structure for table 'url_alias' -- -CREATE TABLE path ( - pid integer NOT NULL default '0', +CREATE TABLE url_alias ( + pid serial, dst varchar(128) NOT NULL default '', src varchar(128) NOT NULL default '', PRIMARY KEY (pid) ); -CREATE INDEX path_src_idx ON path(src); -CREATE INDEX path_dst_idx ON path(dst); - +CREATE INDEX url_alias_src_idx ON url_alias(src); +CREATE INDEX url_alias_dst_idx ON url_alias(dst); -- -- Table structure for permission -- @@ -417,20 +431,6 @@ CREATE TABLE site ( UNIQUE (link) ); --- --- Table structure for table 'statistics' --- - -CREATE TABLE statistics ( - nid integer NOT NULL default '0', - totalcount integer NOT NULL default '0', - daycount integer NOT NULL default '0', - timestamp integer NOT NULL default '0', - PRIMARY KEY (nid) -); -CREATE INDEX statistics_totalcount_idx ON statistics(totalcount); -CREATE INDEX statistics_daycount_idx ON statistics(daycount); -CREATE INDEX statistics_timestamp_idx ON statistics(timestamp); -- -- Table structure for system @@ -590,7 +590,7 @@ INSERT INTO system VALUES ('modules/story.module','story','module','',1); INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1); INSERT INTO system VALUES ('themes/marvin/marvin.theme','marvin','theme','Internet explorer, Netscape, Opera',1); -INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-09-29";'); +INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2003-10-22";'); INSERT INTO variable(name,value) VALUES('theme_default','s:6:"marvin";'); INSERT INTO users(uid,name,mail,rid) VALUES(0,'Anonymous','root@localhost', '1'); diff --git a/includes/common.inc b/includes/common.inc index 48984ac52..8ebbc1c26 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -39,7 +39,7 @@ function drupal_get_path_map($action = "") { } if (!$cache) { - $result = db_query("SELECT * FROM {path}"); + $result = db_query("SELECT * FROM {url_alias}"); while ($data = db_fetch_object($result)) { $map[$data->dst] = $data->src; } diff --git a/modules/node.module b/modules/node.module index a2d6677e4..f14775446 100644 --- a/modules/node.module +++ b/modules/node.module @@ -627,12 +627,12 @@ function node_admin_nodes() { ** Handle operations: */ - if (empty($_SESSION["node-overview-filter"])) { - $_SESSION["node-overview-filter"] = 0; + if (empty($_SESSION["node_overview_filter"])) { + $_SESSION["node_overview_filter"] = 0; } if (isset($_POST["edit"]["filter"])) { - $_SESSION["node-overview-filter"] = $_POST["edit"]["filter"]; + $_SESSION["node_overview_filter"] = $_POST["edit"]["filter"]; } if (isset($_POST["edit"]["operation"])) { @@ -646,7 +646,7 @@ function node_admin_nodes() { $output = status(t("the update has been performed.")); } - $filter = $_SESSION["node-overview-filter"]; + $filter = $_SESSION["node_overview_filter"]; /* ** Render filter form: diff --git a/modules/node/node.module b/modules/node/node.module index a2d6677e4..f14775446 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -627,12 +627,12 @@ function node_admin_nodes() { ** Handle operations: */ - if (empty($_SESSION["node-overview-filter"])) { - $_SESSION["node-overview-filter"] = 0; + if (empty($_SESSION["node_overview_filter"])) { + $_SESSION["node_overview_filter"] = 0; } if (isset($_POST["edit"]["filter"])) { - $_SESSION["node-overview-filter"] = $_POST["edit"]["filter"]; + $_SESSION["node_overview_filter"] = $_POST["edit"]["filter"]; } if (isset($_POST["edit"]["operation"])) { @@ -646,7 +646,7 @@ function node_admin_nodes() { $output = status(t("the update has been performed.")); } - $filter = $_SESSION["node-overview-filter"]; + $filter = $_SESSION["node_overview_filter"]; /* ** Render filter form: diff --git a/modules/path.module b/modules/path.module index 0211ad910..29cc81ddc 100644 --- a/modules/path.module +++ b/modules/path.module @@ -47,28 +47,28 @@ function path_admin() { function path_set_alias($path = NULL, $alias = NULL) { if ($path && !$alias) { - db_query("DELETE FROM {path} WHERE src = '%s'", $path); + db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path); drupal_rebuild_path_map(); } else if (!$path && $alias) { - db_query("DELETE FROM {path} WHERE dst = '%s'", $alias); + db_query("DELETE FROM {url_alias} WHERE dst = '%s'", $alias); drupal_rebuild_path_map(); } else if ($path && $alias) { - $path_count = db_result(db_query("SELECT COUNT(src) FROM {path} WHERE src = '%s'", $path)); - $alias_count = db_result(db_query("SELECT COUNT(dst) FROM {path} WHERE dst = '%s'", $alias)); + $path_count = db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE src = '%s'", $path)); + $alias_count = db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s'", $alias)); // We have an insert: if ($path_count == 0 && $alias_count == 0) { - db_query("INSERT INTO {path} SET src = '%s', dst = '%s'", $path, $alias); + db_query("INSERT INTO {url_alias} SET src = '%s', dst = '%s'", $path, $alias); drupal_rebuild_path_map(); } else if ($path_count == 1 && $alias_count == 0) { - db_query("UPDATE {path} SET dst = '%s' WHERE src = '%s'", $alias, $path); + db_query("UPDATE {url_alias} SET dst = '%s' WHERE src = '%s'", $alias, $path); drupal_rebuild_path_map(); } else if ($path_count == 0 && $alias_count == 1) { - db_query("UPDATE {path} SET src = '%s' WHERE dst = '%s'", $path, $alias); + db_query("UPDATE {url_alias} SET src = '%s' WHERE dst = '%s'", $path, $alias); drupal_rebuild_path_map(); } else if ($path_count == 1 && $alias_count == 1) { @@ -154,7 +154,7 @@ function path_nodeapi(&$node, $op, $arg) { $error["path"] = t("The path is invalid."); return $error; } - else if (db_result(db_query("SELECT COUNT(dst) FROM {path} WHERE dst = '%s' AND src != '%s'", $node->path, "node/view/$node->nid"))) { + else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/view/$node->nid"))) { $error["path"] = t("The path is already in use."); return $error; } @@ -191,7 +191,7 @@ function path_perm() { } function path_overview() { - $sql = "SELECT * FROM {path}"; + $sql = "SELECT * FROM {url_alias}"; $header = array( array ("data" => t("alias"), "field" => "dst", "sort" => "asc"), array ("data" => t("normal"), "field" => "src"), @@ -216,7 +216,7 @@ function path_overview() { } function path_load($pid) { - return db_fetch_array(db_query("SELECT * FROM {path} WHERE pid = '%d'", $pid)); + return db_fetch_array(db_query("SELECT * FROM {url_alias} WHERE pid = '%d'", $pid)); } function path_delete($pid) { @@ -233,7 +233,7 @@ function path_save($edit) { $error[] = t("the normal path '%src' is invalid.", array("%src" => $src)); } - if (db_result(db_query("SELECT COUNT(src) FROM {path} WHERE pid != '%d' AND src = '%s'", $pid, $src))) { + if (db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE pid != '%d' AND src = '%s'", $pid, $src))) { $error[] = t("the normal path '%src' is already aliased.", array("%src" => $src)); } @@ -241,7 +241,7 @@ function path_save($edit) { $error[] = t("the alias '%dst' is invalid.", array("%dst" => $dst)); } - if (db_result(db_query("SELECT COUNT(dst) FROM {path} WHERE pid != '%d' AND dst = '%s'", $pid, $dst))) { + if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != '%d' AND dst = '%s'", $pid, $dst))) { $error[] = t("the alias '%dst' is already in use.", array("%dst" => $dst)); } @@ -256,7 +256,7 @@ function path_save($edit) { */ if ($pid) { - db_query("UPDATE {path} SET src = '%s', dst = '%s' WHERE pid = '%d'", $src, $dst, $pid); + db_query("UPDATE {url_alias} SET src = '%s', dst = '%s' WHERE pid = '%d'", $src, $dst, $pid); } else { path_set_alias($src, $dst); diff --git a/modules/path/path.module b/modules/path/path.module index 0211ad910..29cc81ddc 100644 --- a/modules/path/path.module +++ b/modules/path/path.module @@ -47,28 +47,28 @@ function path_admin() { function path_set_alias($path = NULL, $alias = NULL) { if ($path && !$alias) { - db_query("DELETE FROM {path} WHERE src = '%s'", $path); + db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path); drupal_rebuild_path_map(); } else if (!$path && $alias) { - db_query("DELETE FROM {path} WHERE dst = '%s'", $alias); + db_query("DELETE FROM {url_alias} WHERE dst = '%s'", $alias); drupal_rebuild_path_map(); } else if ($path && $alias) { - $path_count = db_result(db_query("SELECT COUNT(src) FROM {path} WHERE src = '%s'", $path)); - $alias_count = db_result(db_query("SELECT COUNT(dst) FROM {path} WHERE dst = '%s'", $alias)); + $path_count = db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE src = '%s'", $path)); + $alias_count = db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s'", $alias)); // We have an insert: if ($path_count == 0 && $alias_count == 0) { - db_query("INSERT INTO {path} SET src = '%s', dst = '%s'", $path, $alias); + db_query("INSERT INTO {url_alias} SET src = '%s', dst = '%s'", $path, $alias); drupal_rebuild_path_map(); } else if ($path_count == 1 && $alias_count == 0) { - db_query("UPDATE {path} SET dst = '%s' WHERE src = '%s'", $alias, $path); + db_query("UPDATE {url_alias} SET dst = '%s' WHERE src = '%s'", $alias, $path); drupal_rebuild_path_map(); } else if ($path_count == 0 && $alias_count == 1) { - db_query("UPDATE {path} SET src = '%s' WHERE dst = '%s'", $path, $alias); + db_query("UPDATE {url_alias} SET src = '%s' WHERE dst = '%s'", $path, $alias); drupal_rebuild_path_map(); } else if ($path_count == 1 && $alias_count == 1) { @@ -154,7 +154,7 @@ function path_nodeapi(&$node, $op, $arg) { $error["path"] = t("The path is invalid."); return $error; } - else if (db_result(db_query("SELECT COUNT(dst) FROM {path} WHERE dst = '%s' AND src != '%s'", $node->path, "node/view/$node->nid"))) { + else if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s'", $node->path, "node/view/$node->nid"))) { $error["path"] = t("The path is already in use."); return $error; } @@ -191,7 +191,7 @@ function path_perm() { } function path_overview() { - $sql = "SELECT * FROM {path}"; + $sql = "SELECT * FROM {url_alias}"; $header = array( array ("data" => t("alias"), "field" => "dst", "sort" => "asc"), array ("data" => t("normal"), "field" => "src"), @@ -216,7 +216,7 @@ function path_overview() { } function path_load($pid) { - return db_fetch_array(db_query("SELECT * FROM {path} WHERE pid = '%d'", $pid)); + return db_fetch_array(db_query("SELECT * FROM {url_alias} WHERE pid = '%d'", $pid)); } function path_delete($pid) { @@ -233,7 +233,7 @@ function path_save($edit) { $error[] = t("the normal path '%src' is invalid.", array("%src" => $src)); } - if (db_result(db_query("SELECT COUNT(src) FROM {path} WHERE pid != '%d' AND src = '%s'", $pid, $src))) { + if (db_result(db_query("SELECT COUNT(src) FROM {url_alias} WHERE pid != '%d' AND src = '%s'", $pid, $src))) { $error[] = t("the normal path '%src' is already aliased.", array("%src" => $src)); } @@ -241,7 +241,7 @@ function path_save($edit) { $error[] = t("the alias '%dst' is invalid.", array("%dst" => $dst)); } - if (db_result(db_query("SELECT COUNT(dst) FROM {path} WHERE pid != '%d' AND dst = '%s'", $pid, $dst))) { + if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != '%d' AND dst = '%s'", $pid, $dst))) { $error[] = t("the alias '%dst' is already in use.", array("%dst" => $dst)); } @@ -256,7 +256,7 @@ function path_save($edit) { */ if ($pid) { - db_query("UPDATE {path} SET src = '%s', dst = '%s' WHERE pid = '%d'", $src, $dst, $pid); + db_query("UPDATE {url_alias} SET src = '%s', dst = '%s' WHERE pid = '%d'", $src, $dst, $pid); } else { path_set_alias($src, $dst); diff --git a/modules/statistics.module b/modules/statistics.module index 06cb508ae..84ee28a3f 100644 --- a/modules/statistics.module +++ b/modules/statistics.module @@ -42,11 +42,11 @@ function statistics_exit() { // node view counters are enabled if ((arg(0) == "node") && (arg(1) == "view") && arg(2)) { // a node has been viewed, so updated the node's counters - db_query("UPDATE {statistics} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d", time(), arg(2)); + db_query("UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d", time(), arg(2)); // if we affected 0 rows, this is the first time viewing the node if (!db_affected_rows()) { // must create a new row to store counter's for new node - db_query("INSERT INTO {statistics} (nid, daycount, totalcount) VALUES(%d, 1, 1)", arg(2)); + db_query("INSERT INTO {node_counter} (nid, daycount, totalcount) VALUES(%d, 1, 1)", arg(2)); } } } @@ -326,7 +326,7 @@ function statistics_admin_topnodes_table() { array("data" => t("last hit"), "field" => "s.timestamp"), array("data" => t("operations")) ); - $sql = "SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM {statistics} s INNER JOIN {node} n ON s.nid = n.nid"; + $sql = "SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid"; $sql .= tablesort_sql($header); $result = pager_query($sql, 20); // WHERE s.%s <> '0' @@ -611,7 +611,7 @@ function statistics_cron() { if ((time() - $statistics_timestamp) >= 86400) { /* reset day counts */ - db_query("UPDATE {statistics} SET daycount='0'"); + db_query("UPDATE {node_counter} SET daycount = '0'"); variable_set("statistics_day_timestamp", time()); } @@ -732,7 +732,7 @@ function statistics_display_online_block() { /* Display linked title based on field name */ function statistics_title_list($dbfield, $dbrows) { /* valid dbfields: totalcount, daycount, timestamp */ - return db_query_range("SELECT s.nid, n.title, u.uid, u.name FROM {statistics} s INNER JOIN {node} n ON s.nid = n.nid INNER JOIN {users} u ON n.uid = u.uid WHERE %s <> '0' AND n.status = 1 ORDER BY %s DESC", "s.". $dbfield, "s.". $dbfield, 0, $dbrows); + return db_query_range("SELECT s.nid, n.title, u.uid, u.name FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid INNER JOIN {users} u ON n.uid = u.uid WHERE %s <> '0' AND n.status = 1 ORDER BY %s DESC", "s.". $dbfield, "s.". $dbfield, 0, $dbrows); } @@ -741,7 +741,7 @@ function statistics_get($nid) { if ($nid > 0) { /* retrieves an array with both totalcount and daycount */ - $statistics = db_fetch_array(db_query("SELECT totalcount, daycount, timestamp FROM {statistics} WHERE nid = %d", $nid)); + $statistics = db_fetch_array(db_query("SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = %d", $nid)); } return $statistics; @@ -832,7 +832,7 @@ function statistics_summary($dbfield, $dbrows) { /* valid dbfields: totalcount, daycount, timestamp */ $output = ""; - $result = db_query_range("SELECT n.nid, n.title FROM {statistics} s INNER JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC", $dbfield, 0, $dbrows); + $result = db_query_range("SELECT n.nid, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC", $dbfield, 0, $dbrows); while ($nid = db_fetch_array($result)) { $content = node_load(array("nid" => $nid["nid"])); $links = link_node($content, 1); @@ -849,7 +849,7 @@ function statistics_nodeapi(&$node, $op, $arg = 0) { switch ($op) { case "delete": // clean up statistics table when node is deleted - db_query("DELETE FROM {statistics} WHERE nid = %d", $node->nid); + db_query("DELETE FROM {node_counter} WHERE nid = %d", $node->nid); } } diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 06cb508ae..84ee28a3f 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -42,11 +42,11 @@ function statistics_exit() { // node view counters are enabled if ((arg(0) == "node") && (arg(1) == "view") && arg(2)) { // a node has been viewed, so updated the node's counters - db_query("UPDATE {statistics} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d", time(), arg(2)); + db_query("UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d", time(), arg(2)); // if we affected 0 rows, this is the first time viewing the node if (!db_affected_rows()) { // must create a new row to store counter's for new node - db_query("INSERT INTO {statistics} (nid, daycount, totalcount) VALUES(%d, 1, 1)", arg(2)); + db_query("INSERT INTO {node_counter} (nid, daycount, totalcount) VALUES(%d, 1, 1)", arg(2)); } } } @@ -326,7 +326,7 @@ function statistics_admin_topnodes_table() { array("data" => t("last hit"), "field" => "s.timestamp"), array("data" => t("operations")) ); - $sql = "SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM {statistics} s INNER JOIN {node} n ON s.nid = n.nid"; + $sql = "SELECT s.nid, s.daycount, s.totalcount, s.timestamp, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid"; $sql .= tablesort_sql($header); $result = pager_query($sql, 20); // WHERE s.%s <> '0' @@ -611,7 +611,7 @@ function statistics_cron() { if ((time() - $statistics_timestamp) >= 86400) { /* reset day counts */ - db_query("UPDATE {statistics} SET daycount='0'"); + db_query("UPDATE {node_counter} SET daycount = '0'"); variable_set("statistics_day_timestamp", time()); } @@ -732,7 +732,7 @@ function statistics_display_online_block() { /* Display linked title based on field name */ function statistics_title_list($dbfield, $dbrows) { /* valid dbfields: totalcount, daycount, timestamp */ - return db_query_range("SELECT s.nid, n.title, u.uid, u.name FROM {statistics} s INNER JOIN {node} n ON s.nid = n.nid INNER JOIN {users} u ON n.uid = u.uid WHERE %s <> '0' AND n.status = 1 ORDER BY %s DESC", "s.". $dbfield, "s.". $dbfield, 0, $dbrows); + return db_query_range("SELECT s.nid, n.title, u.uid, u.name FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid INNER JOIN {users} u ON n.uid = u.uid WHERE %s <> '0' AND n.status = 1 ORDER BY %s DESC", "s.". $dbfield, "s.". $dbfield, 0, $dbrows); } @@ -741,7 +741,7 @@ function statistics_get($nid) { if ($nid > 0) { /* retrieves an array with both totalcount and daycount */ - $statistics = db_fetch_array(db_query("SELECT totalcount, daycount, timestamp FROM {statistics} WHERE nid = %d", $nid)); + $statistics = db_fetch_array(db_query("SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = %d", $nid)); } return $statistics; @@ -832,7 +832,7 @@ function statistics_summary($dbfield, $dbrows) { /* valid dbfields: totalcount, daycount, timestamp */ $output = ""; - $result = db_query_range("SELECT n.nid, n.title FROM {statistics} s INNER JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC", $dbfield, 0, $dbrows); + $result = db_query_range("SELECT n.nid, n.title FROM {node_counter} s INNER JOIN {node} n ON s.nid = n.nid ORDER BY %s DESC", $dbfield, 0, $dbrows); while ($nid = db_fetch_array($result)) { $content = node_load(array("nid" => $nid["nid"])); $links = link_node($content, 1); @@ -849,7 +849,7 @@ function statistics_nodeapi(&$node, $op, $arg = 0) { switch ($op) { case "delete": // clean up statistics table when node is deleted - db_query("DELETE FROM {statistics} WHERE nid = %d", $node->nid); + db_query("DELETE FROM {node_counter} WHERE nid = %d", $node->nid); } } diff --git a/update.php b/update.php index 842d8bb80..ef362324b 100644 --- a/update.php +++ b/update.php @@ -57,7 +57,8 @@ $mysql_updates = array( "2003-09-29" => "update_65", "2003-09-30" => "update_66", "2003-10-11" => "update_67", - "2003-10-20" => "update_68" + "2003-10-20" => "update_68", + "2003-10-22" => "update_69" ); function update_32() { @@ -360,10 +361,6 @@ function update_60() { function update_61() { if ($GLOBALS["db_type"] == "pgsql") { - /** - * Overkill.. the user cant get here without having this table - */ - update_sql("CREATE TABLE {sessions} ( uid integer NOT NULL, sid varchar(32) NOT NULL default '', @@ -458,7 +455,7 @@ function update_64() { } function update_65() { - /* PG SQL ONLY UPDATE */ + // PostgreSQL-only update. if ($GLOBALS["db_type"] == "pgsql") { update_sql("CREATE FUNCTION \"rand\"() RETURNS float AS ' BEGIN @@ -470,7 +467,7 @@ function update_65() { function update_66() { if ($GLOBALS["db_type"] == "pgsql") { update_sql("CREATE TABLE {path} ( - pid integer NOT NULL default '0', + pid serial, src varchar(128) NOT NULL default '', dst varchar(128) NOT NULL default '', PRIMARY KEY (pid) @@ -481,9 +478,6 @@ function update_66() { while ($node = db_fetch_object($result)) { update_sql("INSERT INTO {path} (src, dst) VALUES ('node/view/$node->nid', '". check_query($node->path) ."')"); } - - /* most versions of pgsql are incapable of dropping columns */ - } else { update_sql("CREATE TABLE {path} ( @@ -505,13 +499,45 @@ function update_66() { } function update_67() { - update_sql("ALTER TABLE users DROP homepage"); + if ($GLOBALS["db_type"] == "pgsql") { + // Taking no action. PostgreSQL is not always capable of dropping columns. + } + else { + update_sql("ALTER TABLE users DROP homepage"); + } } function update_68() { - $max = db_result(db_query("SELECT MAX(aid) FROM {access};")); - update_sql("INSERT INTO {sequences} (name, id) VALUES ('access_aid', '$max')"); - update_sql("ALTER TABLE access CHANGE aid aid tinyint(10) NOT NULL "); + if ($GLOBALS["db_type"] == "pgsql") { + // Unneccesary. The PostgreSQL port was already using a sequence. + } + else { + $max = db_result(db_query("SELECT MAX(aid) FROM {access};")); + update_sql("INSERT INTO {sequences} (name, id) VALUES ('access_aid', '$max')"); + update_sql("ALTER TABLE access CHANGE aid aid tinyint(10) NOT NULL "); + } +} + +function update_69() { + if ($GLOBALS["db_type"] == "pgsql") { + /* Rename the statistics table to node_counter */ + update_sql("ALTER TABLE {statistics} RENAME TO {node_counter}"); + update_sql("DROP INDEX {statistics}_totalcount_idx"); + update_sql("DROP INDEX {statistics}_daycount_idx"); + update_sql("DROP INDEX {statistics}_timestamp_idx"); + update_sql("CREATE INDEX {node_counter}_totalcount_idx ON {node_counter}(totalcount)"); + update_sql("CREATE INDEX {node_counter}_daycount_idx ON {node_counter}(daycount)"); + update_sql("CREATE INDEX {node_counter}_timestamp_idx ON {node_counter}(timestamp)"); + + /* Rename the path table to url_alias */ + update_sql("ALTER TABLE {path} RENAME TO {url_alias}"); + update_sql("ALTER TABLE {path}_pid_seq RENAME TO {url_alias}_pid_seq"); + } + else { + update_sql("ALTER TABLE {statistics} RENAME TO {node_counter}"); + update_sql("ALTER TABLE {path} RENAME TO {url_alias}"); + update_sql("UPDATE {sequences} set name = '{url_alias}_pid' where name = '{path}_pid'"); + } } /* |