summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2004-08-06 21:00:43 +0000
committerDries Buytaert <dries@buytaert.net>2004-08-06 21:00:43 +0000
commit821c6d2d17892ba4b4cfb7771e94953a1e3d5dac (patch)
tree63c8c8ccb98eb3e11d4df0a58373ad7b4f7eb44e /modules
parent9e54dc27ff91c7bf2d8edb1bf07f9c893a3b1ae8 (diff)
downloadbrdo-821c6d2d17892ba4b4cfb7771e94953a1e3d5dac.tar.gz
brdo-821c6d2d17892ba4b4cfb7771e94953a1e3d5dac.tar.bz2
- Patch #9812 by Adrian: fixed some PostgreSQL/ANSI SQL compabitibility
problems created by the new comment and node access permissions code.
Diffstat (limited to 'modules')
-rw-r--r--modules/comment.module4
-rw-r--r--modules/comment/comment.module4
-rw-r--r--modules/node.module9
-rw-r--r--modules/node/node.module9
4 files changed, 18 insertions, 8 deletions
diff --git a/modules/comment.module b/modules/comment.module
index 8c528d313..349635bc1 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -765,7 +765,7 @@ function comment_render($node, $cid = 0) {
$output .= '<form method="post" action="'. url('comment') ."\"><div>\n";
$output .= form_hidden('nid', $nid);
- $result = db_query('SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users', $cid);
+ $result = db_query('SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users', $cid);
if ($comment = db_fetch_object($result)) {
$comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
@@ -782,7 +782,7 @@ function comment_render($node, $cid = 0) {
$query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name , c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = '". check_query($nid) ."' AND c.status = 0";
- $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread';
+ $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread';
/*
** We want to use the standard pager, but threads would need every
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 8c528d313..349635bc1 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -765,7 +765,7 @@ function comment_render($node, $cid = 0) {
$output .= '<form method="post" action="'. url('comment') ."\"><div>\n";
$output .= form_hidden('nid', $nid);
- $result = db_query('SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users', $cid);
+ $result = db_query('SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users', $cid);
if ($comment = db_fetch_object($result)) {
$comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
@@ -782,7 +782,7 @@ function comment_render($node, $cid = 0) {
$query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name , c.mail, c.homepage, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = '". check_query($nid) ."' AND c.status = 0";
- $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread';
+ $query .= ' GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, u.picture, c.homepage, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread';
/*
** We want to use the standard pager, but threads would need every
diff --git a/modules/node.module b/modules/node.module
index 27d050d89..1a35d6c74 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -1397,7 +1397,7 @@ function node_delete($edit) {
* Generate a listing of promoted nodes.
*/
function node_page_default() {
- $result = pager_query('SELECT DISTINCT(n.nid), n.type FROM {node} n '. node_access_join_sql() .' WHERE n.promote = 1 AND n.status = 1 AND '. node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC', variable_get('default_nodes_main', 10));
+ $result = pager_query('SELECT DISTINCT(n.nid), n.type, n.sticky, n.created FROM {node} n '. node_access_join_sql() .' WHERE n.promote = 1 AND n.status = 1 AND '. node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC', variable_get('default_nodes_main', 10));
if (db_num_rows($result)) {
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('node/feed', NULL, NULL, TRUE) .'" />');
@@ -1634,7 +1634,12 @@ function node_access_join_sql($node_alias = 'n', $node_access_alias = 'na') {
*/
function node_access_where_sql($op = 'view', $node_access_alias = 'na') {
if (user_access('administer nodes')) {
- return '1';
+ /**
+ * This number is being used in a SQL query in a boolean nature.
+ * It is "'1'" instead of "1" for database compatibility, as both
+ * Postgres and Mysql treat it as boolean in this case.
+ */
+ return "'1'";
}
$sql = $node_access_alias .'.grant_'. $op .' = 1 AND CONCAT('. $node_access_alias .'.realm, '. $node_access_alias .'.gid) IN (';
diff --git a/modules/node/node.module b/modules/node/node.module
index 27d050d89..1a35d6c74 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1397,7 +1397,7 @@ function node_delete($edit) {
* Generate a listing of promoted nodes.
*/
function node_page_default() {
- $result = pager_query('SELECT DISTINCT(n.nid), n.type FROM {node} n '. node_access_join_sql() .' WHERE n.promote = 1 AND n.status = 1 AND '. node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC', variable_get('default_nodes_main', 10));
+ $result = pager_query('SELECT DISTINCT(n.nid), n.type, n.sticky, n.created FROM {node} n '. node_access_join_sql() .' WHERE n.promote = 1 AND n.status = 1 AND '. node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC', variable_get('default_nodes_main', 10));
if (db_num_rows($result)) {
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('node/feed', NULL, NULL, TRUE) .'" />');
@@ -1634,7 +1634,12 @@ function node_access_join_sql($node_alias = 'n', $node_access_alias = 'na') {
*/
function node_access_where_sql($op = 'view', $node_access_alias = 'na') {
if (user_access('administer nodes')) {
- return '1';
+ /**
+ * This number is being used in a SQL query in a boolean nature.
+ * It is "'1'" instead of "1" for database compatibility, as both
+ * Postgres and Mysql treat it as boolean in this case.
+ */
+ return "'1'";
}
$sql = $node_access_alias .'.grant_'. $op .' = 1 AND CONCAT('. $node_access_alias .'.realm, '. $node_access_alias .'.gid) IN (';