Commit 9d631d22 authored by Dries's avatar Dries
Browse files

- Patch #314532 by jsaints, Crell, Arancaytar, CorniI, Rob Loach, et al:...

- Patch #314532 by jsaints, Crell, Arancaytar, CorniI, Rob Loach, et al: convert comment module to new DB layer.  Doesn't break any additional tests so if we discover a regression, please submit a test with it.
parent a56f520f
...@@ -128,7 +128,9 @@ function comment_admin_overview_submit($form, &$form_state) { ...@@ -128,7 +128,9 @@ function comment_admin_overview_submit($form, &$form_state) {
foreach ($form_state['values']['comments'] as $cid => $value) { foreach ($form_state['values']['comments'] as $cid => $value) {
if ($value) { if ($value) {
// Perform the update action, then refresh node statistics. // Perform the update action, then refresh node statistics.
db_query($query, $cid); $query
->condition('cid', $cid )
->execute();
$comment = comment_load($cid); $comment = comment_load($cid);
_comment_update_node_statistics($comment->nid); _comment_update_node_statistics($comment->nid);
// Allow modules to respond to the updating of a comment. // Allow modules to respond to the updating of a comment.
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
function comment_edit($cid) { function comment_edit($cid) {
global $user; global $user;
$comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid)); $comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid', array(':cid'=>$cid) )->fetchObject();
$comment = drupal_unpack($comment); $comment = drupal_unpack($comment);
$comment->name = $comment->uid ? $comment->registered_name : $comment->name; $comment->name = $comment->uid ? $comment->registered_name : $comment->name;
...@@ -69,7 +69,10 @@ function comment_reply($node, $pid = NULL) { ...@@ -69,7 +69,10 @@ function comment_reply($node, $pid = NULL) {
// $pid indicates that this is a reply to a comment. // $pid indicates that this is a reply to a comment.
if ($pid) { if ($pid) {
// Load the comment whose cid = $pid // Load the comment whose cid = $pid
if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $pid, COMMENT_PUBLISHED))) { $comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array(
':cid'=>$pid,
':status'=>COMMENT_PUBLISHED))->fetchObject();
if ( $comment ) {
// If that comment exists, make sure that the current comment and the // If that comment exists, make sure that the current comment and the
// parent comment both belong to the same parent node. // parent comment both belong to the same parent node.
if ($comment->nid != $node->nid) { if ($comment->nid != $node->nid) {
...@@ -123,7 +126,10 @@ function comment_approve($cid) { ...@@ -123,7 +126,10 @@ function comment_approve($cid) {
// Load the comment whose cid = $cid // Load the comment whose cid = $cid
if ($comment = comment_load($cid)) { if ($comment = comment_load($cid)) {
$operations = comment_operations('publish'); $operations = comment_operations('publish');
db_query($operations['publish'][1], $cid); $query = $operations['publish'][1];
$query
->condition('cid', $cid )
->execute();
drupal_set_message(t('Comment approved.')); drupal_set_message(t('Comment approved.'));
drupal_goto("node/$comment->nid"); drupal_goto("node/$comment->nid");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment