From 3c2dc18c82fd6fc19d5e2e26bc1f28b0048f89a8 Mon Sep 17 00:00:00 2001
From: Dries Buytaert
Date: Sun, 20 Apr 2003 20:33:28 +0000
Subject: - Fixed bug #1545: incorrect sequence tables on PostgreSQL. Patch by
Neil.
In addition, I have updated update.php so it makes the corresponding
changes for MySQL users.
---
modules/aggregator.module | 52 ++++++++++++++---------------
modules/aggregator/aggregator.module | 52 ++++++++++++++---------------
modules/comment.module | 62 +++++++++++++++++-----------------
modules/comment/comment.module | 62 +++++++++++++++++-----------------
modules/import.module | 52 ++++++++++++++---------------
modules/node.module | 14 ++++----
modules/node/node.module | 14 ++++----
modules/taxonomy.module | 64 ++++++++++++++++++------------------
modules/taxonomy/taxonomy.module | 64 ++++++++++++++++++------------------
9 files changed, 218 insertions(+), 218 deletions(-)
(limited to 'modules')
diff --git a/modules/aggregator.module b/modules/aggregator.module
index 22cb55939..a36ef3215 100644
--- a/modules/aggregator.module
+++ b/modules/aggregator.module
@@ -92,7 +92,7 @@ function import_bundle_block($attributes) {
}
function import_feed_block($feed) {
- $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15));
+ $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15));
while ($item = db_fetch_object($result)) {
$output .= import_format_item($item);
@@ -119,13 +119,13 @@ function import_block($op, $delta) {
list($type, $id) = split(":", $delta);
switch ($type) {
case "feed":
- $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $id));
+ $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $id));
$block["subject"] = $feed->title;
$block["content"] .= import_feed_block($feed) ."". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
";
break;
case "bundle":
- $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $id));
+ $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $id));
$block["subject"] = $bundle->title;
$block["content"] .= import_bundle_block($bundle->attributes) ."". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
";
break;
@@ -168,7 +168,7 @@ function import_get_feeds($attributes = 0) {
}
function import_remove($feed) {
- db_query("DELETE FROM item WHERE fid = '%d'", $feed["fid"]);
+ db_query("DELETE FROM item WHERE fid = %d", $feed["fid"]);
return t("removed news items from '%site'.", array("%site" => $feed["title"]));
}
@@ -270,7 +270,7 @@ function import_refresh($feed) {
$channel[$key] = filter(strtr(trim($value), $tt));
}
- db_query("UPDATE feed SET timestamp = '%d', link = '%s', description = '%s' WHERE fid = '%d'", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]);
+ db_query("UPDATE feed SET timestamp = %d, link = '%s', description = '%s' WHERE fid = %d", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]);
/*
** We reverse the array such that we store the first item last,
@@ -316,10 +316,10 @@ function import_refresh($feed) {
*/
if ($link && $link != $feed["link"] && $link != $feed["url"]) {
- $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND link = '%s'", $feed["fid"], $link));
+ $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND link = '%s'", $feed["fid"], $link));
}
else {
- $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND title = '%s'", $feed["fid"], $title));
+ $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND title = '%s'", $feed["fid"], $title));
}
import_save_item(array(iid => $entry->iid, fid => $feed["fid"], title => $title, link => $link, author => $item["AUTHOR"], description => $item["DESCRIPTION"], attributes => $feed["attributes"]));
@@ -331,7 +331,7 @@ function import_refresh($feed) {
unset($items);
- $result = db_query("SELECT iid FROM item WHERE fid = '%d' ORDER BY timestamp", $feed["fid"]);
+ $result = db_query("SELECT iid FROM item WHERE fid = %d ORDER BY timestamp", $feed["fid"]);
while ($item = db_fetch_object($result)) {
$items[] = "iid = '$item->iid'";
@@ -351,10 +351,10 @@ function import_refresh($feed) {
function import_save_item($edit) {
if ($edit["iid"] && $edit["title"]) {
- db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = '%d'", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]);
+ db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = %d", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]);
}
else if ($edit["iid"]) {
- db_query("DELETE FROM item WHERE iid = '%d'", $edit["iid"]);
+ db_query("DELETE FROM item WHERE iid = %d", $edit["iid"]);
}
else if ($edit["title"] && $edit["link"]) {
db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time());
@@ -378,15 +378,15 @@ function import_form_bundle($edit = array()) {
function import_save_bundle($edit) {
if ($edit["bid"] && $edit["title"]) {
- db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = '%d'", $edit["title"], $edit["attributes"], $edit["bid"]);
+ db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = %d", $edit["title"], $edit["attributes"], $edit["bid"]);
}
else if ($edit["bid"]) {
- db_query("DELETE FROM bundle WHERE bid = '%d'", $edit["bid"]);
+ db_query("DELETE FROM bundle WHERE bid = %d", $edit["bid"]);
}
else if ($edit["title"]) {
// a single unique id for bundles and feeds, to use in blocks
- $next_id = db_next_id("import");
- db_query("INSERT INTO bundle (bid, title, attributes) VALUES ('%d', '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]);
+ $next_id = db_next_id("bundle_bid");
+ db_query("INSERT INTO bundle (bid, title, attributes) VALUES (%d, '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]);
}
}
@@ -415,33 +415,33 @@ function import_form_feed($edit = array()) {
function import_save_feed($edit) {
if ($edit["fid"] && $edit["title"]) {
- db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = '%d'", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
- db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]);
+ db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
+ db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]);
}
else if ($edit["fid"]) {
- db_query("DELETE FROM feed WHERE fid = '%d'", $edit["fid"]);
- db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]);
+ db_query("DELETE FROM feed WHERE fid = %d", $edit["fid"]);
+ db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]);
}
else if ($edit["title"]) {
// a single unique id for bundles and feeds, to use in blocks
- $next_id = db_next_id("import");
- db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES ('%d', '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
+ $next_id = db_next_id("feed_fid");
+ db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
}
}
function import_save_attributes($edit) {
foreach ($edit as $iid => $value) {
- db_query("UPDATE item SET attributes = '%s' WHERE iid = '%d'", $value, $iid);
+ db_query("UPDATE item SET attributes = '%s' WHERE iid = %d", $value, $iid);
}
return "attributes has been saved";
}
function import_get_feed($fid) {
- return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid));
+ return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = %d", $fid));
}
function import_get_bundle($bid) {
- return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid));
+ return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = %d", $bid));
}
function import_view() {
@@ -594,13 +594,13 @@ function import_page_last() {
function import_page_feed($fid) {
- $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid));
+ $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $fid));
$header .= "". t("Website") .":
";
$header .= "". t("Description") .":
$feed->description
";
$header .= "". t("Last update") .":
". format_interval(time() - $feed->timestamp) ." ". t("ago") ."
url\">
\n";
- $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75));
+ $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75));
$output .= "";
while ($item = db_fetch_object($result)) {
@@ -630,7 +630,7 @@ function import_page_feed($fid) {
function import_page_bundle($bid) {
- $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid));
+ $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $bid));
$header .= "". t("Website") .":
". l($bundle->title, "import/bundle/$bundle->bid") ."
";
$header .= "". t("Description") .":
". t("A composite news feed about") ." $bundle->attributes.
";
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 22cb55939..a36ef3215 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -92,7 +92,7 @@ function import_bundle_block($attributes) {
}
function import_feed_block($feed) {
- $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15));
+ $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15));
while ($item = db_fetch_object($result)) {
$output .= import_format_item($item);
@@ -119,13 +119,13 @@ function import_block($op, $delta) {
list($type, $id) = split(":", $delta);
switch ($type) {
case "feed":
- $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $id));
+ $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $id));
$block["subject"] = $feed->title;
$block["content"] .= import_feed_block($feed) ."". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."
";
break;
case "bundle":
- $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $id));
+ $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $id));
$block["subject"] = $bundle->title;
$block["content"] .= import_bundle_block($bundle->attributes) ."". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."
";
break;
@@ -168,7 +168,7 @@ function import_get_feeds($attributes = 0) {
}
function import_remove($feed) {
- db_query("DELETE FROM item WHERE fid = '%d'", $feed["fid"]);
+ db_query("DELETE FROM item WHERE fid = %d", $feed["fid"]);
return t("removed news items from '%site'.", array("%site" => $feed["title"]));
}
@@ -270,7 +270,7 @@ function import_refresh($feed) {
$channel[$key] = filter(strtr(trim($value), $tt));
}
- db_query("UPDATE feed SET timestamp = '%d', link = '%s', description = '%s' WHERE fid = '%d'", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]);
+ db_query("UPDATE feed SET timestamp = %d, link = '%s', description = '%s' WHERE fid = %d", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]);
/*
** We reverse the array such that we store the first item last,
@@ -316,10 +316,10 @@ function import_refresh($feed) {
*/
if ($link && $link != $feed["link"] && $link != $feed["url"]) {
- $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND link = '%s'", $feed["fid"], $link));
+ $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND link = '%s'", $feed["fid"], $link));
}
else {
- $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = '%d' AND title = '%s'", $feed["fid"], $title));
+ $entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND title = '%s'", $feed["fid"], $title));
}
import_save_item(array(iid => $entry->iid, fid => $feed["fid"], title => $title, link => $link, author => $item["AUTHOR"], description => $item["DESCRIPTION"], attributes => $feed["attributes"]));
@@ -331,7 +331,7 @@ function import_refresh($feed) {
unset($items);
- $result = db_query("SELECT iid FROM item WHERE fid = '%d' ORDER BY timestamp", $feed["fid"]);
+ $result = db_query("SELECT iid FROM item WHERE fid = %d ORDER BY timestamp", $feed["fid"]);
while ($item = db_fetch_object($result)) {
$items[] = "iid = '$item->iid'";
@@ -351,10 +351,10 @@ function import_refresh($feed) {
function import_save_item($edit) {
if ($edit["iid"] && $edit["title"]) {
- db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = '%d'", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]);
+ db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = %d", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]);
}
else if ($edit["iid"]) {
- db_query("DELETE FROM item WHERE iid = '%d'", $edit["iid"]);
+ db_query("DELETE FROM item WHERE iid = %d", $edit["iid"]);
}
else if ($edit["title"] && $edit["link"]) {
db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time());
@@ -378,15 +378,15 @@ function import_form_bundle($edit = array()) {
function import_save_bundle($edit) {
if ($edit["bid"] && $edit["title"]) {
- db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = '%d'", $edit["title"], $edit["attributes"], $edit["bid"]);
+ db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = %d", $edit["title"], $edit["attributes"], $edit["bid"]);
}
else if ($edit["bid"]) {
- db_query("DELETE FROM bundle WHERE bid = '%d'", $edit["bid"]);
+ db_query("DELETE FROM bundle WHERE bid = %d", $edit["bid"]);
}
else if ($edit["title"]) {
// a single unique id for bundles and feeds, to use in blocks
- $next_id = db_next_id("import");
- db_query("INSERT INTO bundle (bid, title, attributes) VALUES ('%d', '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]);
+ $next_id = db_next_id("bundle_bid");
+ db_query("INSERT INTO bundle (bid, title, attributes) VALUES (%d, '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]);
}
}
@@ -415,33 +415,33 @@ function import_form_feed($edit = array()) {
function import_save_feed($edit) {
if ($edit["fid"] && $edit["title"]) {
- db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = '%d'", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
- db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]);
+ db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
+ db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]);
}
else if ($edit["fid"]) {
- db_query("DELETE FROM feed WHERE fid = '%d'", $edit["fid"]);
- db_query("DELETE FROM item WHERE fid = '%d'", $edit["fid"]);
+ db_query("DELETE FROM feed WHERE fid = %d", $edit["fid"]);
+ db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]);
}
else if ($edit["title"]) {
// a single unique id for bundles and feeds, to use in blocks
- $next_id = db_next_id("import");
- db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES ('%d', '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
+ $next_id = db_next_id("feed_fid");
+ db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
}
}
function import_save_attributes($edit) {
foreach ($edit as $iid => $value) {
- db_query("UPDATE item SET attributes = '%s' WHERE iid = '%d'", $value, $iid);
+ db_query("UPDATE item SET attributes = '%s' WHERE iid = %d", $value, $iid);
}
return "attributes has been saved";
}
function import_get_feed($fid) {
- return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid));
+ return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = %d", $fid));
}
function import_get_bundle($bid) {
- return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid));
+ return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = %d", $bid));
}
function import_view() {
@@ -594,13 +594,13 @@ function import_page_last() {
function import_page_feed($fid) {
- $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = '%d'", $fid));
+ $feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $fid));
$header .= "". t("Website") .":
";
$header .= "". t("Description") .":
$feed->description
";
$header .= "". t("Last update") .":
". format_interval(time() - $feed->timestamp) ." ". t("ago") ."
url\">
\n";
- $result = db_query_range("SELECT * FROM item WHERE fid = '%d' ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75));
+ $result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75));
$output .= "";
while ($item = db_fetch_object($result)) {
@@ -630,7 +630,7 @@ function import_page_feed($fid) {
function import_page_bundle($bid) {
- $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '%d'", $bid));
+ $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $bid));
$header .= "". t("Website") .":
". l($bundle->title, "import/bundle/$bundle->bid") ."
";
$header .= "". t("Description") .":
". t("A composite news feed about") ." $bundle->attributes.
";
diff --git a/modules/comment.module b/modules/comment.module
index 8ada37458..9af8c2a7f 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -113,7 +113,7 @@ function comment_form($edit) {
function comment_edit($cid) {
global $user;
- $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status != 2", $cid));
+ $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2", $cid));
if (comment_access("edit", $comment)) {
comment_preview(object2array($comment));
@@ -130,7 +130,7 @@ function comment_reply($pid, $nid) {
*/
if ($pid) {
- $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0", $pid));
+ $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid));
comment_view($comment);
}
else {
@@ -181,7 +181,7 @@ function comment_preview($edit) {
theme("box", t("Reply"), comment_form($edit));
if ($edit["pid"]) {
- $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0", $edit["pid"]));
+ $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"]));
comment_view($comment);
}
else {
@@ -221,7 +221,7 @@ function comment_post($edit) {
** validated/filtered data to perform such check.
*/
- $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '%d' AND nid = '%d' AND subject = '%s' AND comment = '%s'", $edit["pid"], $edit["nid"], $edit["subject"], $edit["comment"]), 0);
+ $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = %d AND nid = %d AND subject = '%s' AND comment = '%s'", $edit["pid"], $edit["nid"], $edit["subject"], $edit["comment"]), 0);
if ($duplicate != 0) {
watchdog("warning", "comment: duplicate '". $edit["subject"] ."'");
@@ -237,7 +237,7 @@ function comment_post($edit) {
** user.
*/
- db_query("UPDATE comments SET subject = '%s', comment = '%s' WHERE cid = '%d' AND uid = '$user->uid'", $edit["subject"], $edit["comment"], $edit["cid"]);
+ db_query("UPDATE comments SET subject = '%s', comment = '%s' WHERE cid = %d AND uid = '$user->uid'", $edit["subject"], $edit["comment"], $edit["cid"]);
/*
** Fire a hook
@@ -268,9 +268,9 @@ function comment_post($edit) {
$score = $roles[$user->rid] ? $roles[$user->rid] : 0;
$users = serialize(array(0 => $score));
- $edit["cid"] = db_next_id("comments");
+ $edit["cid"] = db_next_id("comments_cid");
- db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users);
+ db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users);
/*
** Tell the other modules a new comment has been submitted:
@@ -397,7 +397,7 @@ function comment_render($node, $cid = 0) {
if (empty($threshold)) {
$threshold = $user->uid ? $user->threshold : variable_get("comment_default_threshold", 0);
}
- $threshold_min = db_result(db_query("SELECT minimum FROM moderation_filters WHERE fid = '%d'", $threshold));
+ $threshold_min = db_result(db_query("SELECT minimum FROM moderation_filters WHERE fid = %d", $threshold));
if (empty($comment_page)) {
$comment_page = 1;
@@ -417,7 +417,7 @@ function comment_render($node, $cid = 0) {
print "
";
if ($mid) {
- $vote = db_fetch_object(db_query("SELECT vote, weight FROM moderation_votes WHERE mid = '%d'", $mid));
+ $vote = db_fetch_object(db_query("SELECT vote, weight FROM moderation_votes WHERE mid = %d", $mid));
}
$output .= "Add new moderation option
";
@@ -938,15 +938,15 @@ function comment_mod_filters($edit) {
$fid = arg(3);
if ($op == t("Save threshold")) {
- db_query("UPDATE moderation_filters SET filter = '%s', minimum = '%d' WHERE fid = '%d'", $edit["filter"], $edit["minimum"], $fid);
+ db_query("UPDATE moderation_filters SET filter = '%s', minimum = %d WHERE fid = %d", $edit["filter"], $edit["minimum"], $fid);
$fid = 0;
}
else if ($op == t("Delete threshold")) {
- db_query("DELETE FROM moderation_filters WHERE fid = '%d'", $fid);
+ db_query("DELETE FROM moderation_filters WHERE fid = %d", $fid);
$fid = 0;
}
else if ($op == t("Add new threshold")) {
- db_query("INSERT INTO moderation_filters (fid, filter, minimum) VALUES (NULL, '%s', '%d')", $edit["filter"], $edit["minimum"]);
+ db_query("INSERT INTO moderation_filters (fid, filter, minimum) VALUES (NULL, '%s', %d)", $edit["filter"], $edit["minimum"]);
$fid = 0;
}
@@ -962,7 +962,7 @@ function comment_mod_filters($edit) {
$output .= "
";
if ($fid) {
- $filter = db_fetch_object(db_query("SELECT filter, fid, minimum FROM moderation_filters WHERE fid = '%d'", $fid));
+ $filter = db_fetch_object(db_query("SELECT filter, fid, minimum FROM moderation_filters WHERE fid = %d", $fid));
}
$output .= "Add new threshold
";
@@ -1138,7 +1138,7 @@ function comment_moderation_form($comment) {
// comment hasn't been moderated yet:
if (!isset($votes)) {
- $result = db_query("SELECT v.mid, v.vote, r.value FROM moderation_votes v, moderation_roles r WHERE v.mid = r.mid AND r.rid = '%d' ORDER BY weight", $user->rid);
+ $result = db_query("SELECT v.mid, v.vote, r.value FROM moderation_votes v, moderation_roles r WHERE v.mid = r.mid AND r.rid = %d ORDER BY weight", $user->rid);
$votes = array();
while ($vote = db_fetch_object($result)) {
if ($vote->value != 0) {
@@ -1257,18 +1257,18 @@ function comment_moderate() {
global $moderation, $user;
if ($moderation) {
- $result = db_query("SELECT mid, value FROM moderation_roles WHERE rid = '%d'", $user->rid);
+ $result = db_query("SELECT mid, value FROM moderation_roles WHERE rid = %d", $user->rid);
while ($mod = db_fetch_object($result)) {
$votes[$mod->mid] = $mod->value;
}
- $node = node_load(array("nid" => db_result(db_query("SELECT nid FROM comments WHERE cid = '%d'", key($moderation)))));
+ $node = node_load(array("nid" => db_result(db_query("SELECT nid FROM comments WHERE cid = %d", key($moderation)))));
if (user_access("administer comments") || comment_user_can_moderate($node)) {
foreach ($moderation as $cid => $vote) {
if ($vote) {
if (($vote == 'offline') && (user_access("administer comments"))) {
- db_query("UPDATE comments SET status = 1 WHERE cid = '%d'", $cid);
+ db_query("UPDATE comments SET status = 1 WHERE cid = %d", $cid);
watchdog("special", "comment: unpublished comment #". $cid);
/*
@@ -1278,7 +1278,7 @@ function comment_moderate() {
module_invoke_all("comment", "unpublish", $cid);
}
else {
- $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = '%d'", $cid));
+ $comment = db_fetch_object(db_query("SELECT * FROM comments WHERE cid = %d", $cid));
$users = unserialize($comment->users);
if ($user->uid != $comment->uid && !(comment_already_moderated($user->uid, $comment->users))) {
$users[$user->uid] = $vote;
@@ -1293,7 +1293,7 @@ function comment_moderate() {
}
}
$new_score = round($tot_score / count($users));
- db_query("UPDATE comments SET score = '$new_score', users = '%s' WHERE cid = '%d'", serialize($users), $cid);
+ db_query("UPDATE comments SET score = '$new_score', users = '%s' WHERE cid = %d", serialize($users), $cid);
/*
** Fire a hook
@@ -1320,7 +1320,7 @@ function comment_num_all($nid) {
static $cache;
if (!isset($cache[$nid])) {
- $comment = db_fetch_object(db_query("SELECT COUNT(c.nid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = '%d' AND c.status = 0 GROUP BY n.nid", $nid));
+ $comment = db_fetch_object(db_query("SELECT COUNT(c.nid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = %d AND c.status = 0 GROUP BY n.nid", $nid));
$cache[$nid] = $comment->number ? $comment->number : 0;
}
return $cache[$nid];
@@ -1330,7 +1330,7 @@ function comment_num_replies($id) {
static $cache;
if (!isset($cache[$nid])) {
- $result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = '%d' AND status = 0", $id);
+ $result = db_query("SELECT COUNT(cid) FROM comments WHERE pid = %d AND status = 0", $id);
$cache[$nid] = $result ? db_result($result, 0) : 0;
}
@@ -1360,7 +1360,7 @@ function comment_num_new($nid, $timestamp = 0) {
** Use the timestamp to retrieve the number of new comments
*/
- $result = db_result(db_query("SELECT COUNT(c.cid) FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = '%d' AND timestamp > '%d' AND c.status = 0", $nid, $timestamp));
+ $result = db_result(db_query("SELECT COUNT(c.cid) FROM node n LEFT JOIN comments c ON n.nid = c.nid WHERE n.nid = %d AND timestamp > %d AND c.status = 0", $nid, $timestamp));
return $result;
}
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 8ada37458..9af8c2a7f 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -113,7 +113,7 @@ function comment_form($edit) {
function comment_edit($cid) {
global $user;
- $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status != 2", $cid));
+ $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2", $cid));
if (comment_access("edit", $comment)) {
comment_preview(object2array($comment));
@@ -130,7 +130,7 @@ function comment_reply($pid, $nid) {
*/
if ($pid) {
- $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0", $pid));
+ $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid));
comment_view($comment);
}
else {
@@ -181,7 +181,7 @@ function comment_preview($edit) {
theme("box", t("Reply"), comment_form($edit));
if ($edit["pid"]) {
- $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = '%d' AND c.status = 0", $edit["pid"]));
+ $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM comments c LEFT JOIN users u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"]));
comment_view($comment);
}
else {
@@ -221,7 +221,7 @@ function comment_post($edit) {
** validated/filtered data to perform such check.
*/
- $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = '%d' AND nid = '%d' AND subject = '%s' AND comment = '%s'", $edit["pid"], $edit["nid"], $edit["subject"], $edit["comment"]), 0);
+ $duplicate = db_result(db_query("SELECT COUNT(cid) FROM comments WHERE pid = %d AND nid = %d AND subject = '%s' AND comment = '%s'", $edit["pid"], $edit["nid"], $edit["subject"], $edit["comment"]), 0);
if ($duplicate != 0) {
watchdog("warning", "comment: duplicate '". $edit["subject"] ."'");
@@ -237,7 +237,7 @@ function comment_post($edit) {
** user.
*/
- db_query("UPDATE comments SET subject = '%s', comment = '%s' WHERE cid = '%d' AND uid = '$user->uid'", $edit["subject"], $edit["comment"], $edit["cid"]);
+ db_query("UPDATE comments SET subject = '%s', comment = '%s' WHERE cid = %d AND uid = '$user->uid'", $edit["subject"], $edit["comment"], $edit["cid"]);
/*
** Fire a hook
@@ -268,9 +268,9 @@ function comment_post($edit) {
$score = $roles[$user->rid] ? $roles[$user->rid] : 0;
$users = serialize(array(0 => $score));
- $edit["cid"] = db_next_id("comments");
+ $edit["cid"] = db_next_id("comments_cid");
- db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES ('%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users);
+ db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users);
/*
** Tell the other modules a new comment has been submitted:
@@ -397,7 +397,7 @@ function comment_render($node, $cid = 0) {
if (empty($threshold)) {
$threshold = $user->uid ? $user->threshold : variable_get("comment_default_threshold", 0);
}
- $threshold_min = db_result(db_query("SELECT minimum FROM moderation_filters WHERE fid = '%d'", $threshold));
+ $threshold_min = db_result(db_query("SELECT minimum FROM moderation_filters WHERE fid = %d", $threshold));
if (empty($comment_page)) {
$comment_page = 1;
@@ -417,7 +417,7 @@ function comment_render($node, $cid = 0) {
print "