diff options
author | Dries Buytaert <dries@buytaert.net> | 2011-05-22 18:04:42 -0400 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2011-05-22 18:04:42 -0400 |
commit | c27eec17124cf327747649496c8c55c434b61c65 (patch) | |
tree | ff64c5e51687f2e3f70fb3e80367c734c33a4f30 /modules/comment | |
parent | 5dbe8aa92b9e746962b43f9a24b10d7f9616d232 (diff) | |
download | brdo-c27eec17124cf327747649496c8c55c434b61c65.tar.gz brdo-c27eec17124cf327747649496c8c55c434b61c65.tar.bz2 |
- Patch #1120412 by skwashd: comment_save() doesn't support additional columns added by hook_schema_alter().
Diffstat (limited to 'modules/comment')
-rw-r--r-- | modules/comment/comment.module | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 499adc847..4a737557d 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -1465,21 +1465,8 @@ function comment_save($comment) { module_invoke_all('entity_presave', $comment, 'comment'); if ($comment->cid) { - // Update the comment in the database. - db_update('comment') - ->fields(array( - 'status' => $comment->status, - 'created' => $comment->created, - 'changed' => $comment->changed, - 'subject' => $comment->subject, - 'uid' => $comment->uid, - 'name' => $comment->name, - 'mail' => $comment->mail, - 'homepage' => $comment->homepage, - 'language' => $comment->language, - )) - ->condition('cid', $comment->cid) - ->execute(); + + drupal_write_record('comment', $comment, 'cid'); // Ignore slave server temporarily to give time for the // saved comment to be propagated to the slave. @@ -1551,23 +1538,16 @@ function comment_save($comment) { $comment->name = $user->name; } - $comment->cid = db_insert('comment') - ->fields(array( - 'nid' => $comment->nid, - 'pid' => empty($comment->pid) ? 0 : $comment->pid, - 'uid' => $comment->uid, - 'subject' => $comment->subject, - 'hostname' => ip_address(), - 'created' => $comment->created, - 'changed' => $comment->changed, - 'status' => $comment->status, - 'thread' => $thread, - 'name' => $comment->name, - 'mail' => $comment->mail, - 'homepage' => $comment->homepage, - 'language' => $comment->language, - )) - ->execute(); + // Ensure the parent id (pid) has a value set. + if (empty($comment->pid)) { + $comment->pid = 0; + } + + // Add the values which aren't passed into the function. + $comment->thread = $thread; + $comment->hostname = ip_address(); + + drupal_write_record('comment', $comment); // Ignore slave server temporarily to give time for the // created comment to be propagated to the slave. |