diff --git a/modules/comment/comment.admin.inc b/modules/comment/comment.admin.inc index 4f3d350..21fba35 100644 --- a/modules/comment/comment.admin.inc +++ b/modules/comment/comment.admin.inc @@ -253,7 +253,7 @@ function comment_confirm_delete_page($cid) { * @ingroup forms * @see comment_confirm_delete_submit() */ -function comment_confirm_delete($form, &$form_state, $comment) { +function comment_confirm_delete($form, &$form_state, EntityInterface $comment) { $form['#comment'] = $comment; // Always provide entity id in the same form key as in the entity edit form. $form['cid'] = array('#type' => 'value', '#value' => $comment->cid); diff --git a/modules/comment/comment.module b/modules/comment/comment.module index a4148b8..38a4020 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -154,7 +154,7 @@ function comment_node_type_load($name) { /** * Entity uri callback. */ -function comment_uri($comment) { +function comment_uri(EntityInterface $comment) { return array( 'path' => 'comment/' . $comment->cid, 'options' => array('fragment' => 'comment-' . $comment->cid), @@ -904,7 +904,7 @@ function comment_prepare_thread(&$comments) { /** * Generate an array for rendering the given comment. * - * @param $comment + * @param EntityInterface $comment * A comment object. * @param $node * The node the comment is attached to. @@ -917,7 +917,7 @@ function comment_prepare_thread(&$comments) { * @return * An array as expected by drupal_render(). */ -function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) { +function comment_view(EntityInterface $comment, $node, $view_mode = 'full', $langcode = NULL) { if (!isset($langcode)) { $langcode = $GLOBALS['language_content']->language; } @@ -974,7 +974,7 @@ function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) { * The content built for the comment (field values, comments, file attachments or * other comment components) will vary depending on the $view_mode parameter. * - * @param $comment + * @param EntityInterface $comment * A comment object. * @param $node * The node the comment is attached to. @@ -984,7 +984,7 @@ function comment_view($comment, $node, $view_mode = 'full', $langcode = NULL) { * (optional) A language code to use for rendering. Defaults to the global * content language of the current request. */ -function comment_build_content($comment, $node, $view_mode = 'full', $langcode = NULL) { +function comment_build_content(EntityInterface $comment, $node, $view_mode = 'full', $langcode = NULL) { if (!isset($langcode)) { $langcode = $GLOBALS['language_content']->language; } @@ -1020,14 +1020,14 @@ function comment_build_content($comment, $node, $view_mode = 'full', $langcode = * * Adds reply, edit, delete etc. depending on the current user permissions. * - * @param $comment + * @param EntityInterface $comment * The comment object. * @param $node * The node the comment is attached to. * @return * A structured array of links. */ -function comment_links($comment, $node) { +function comment_links(EntityInterface $comment, $node) { $links = array(); if ($node->comment == COMMENT_NODE_OPEN) { if (user_access('administer comments') && user_access('post comments')) { @@ -1419,12 +1419,12 @@ function comment_user_delete($account) { * @param $op * The operation that is to be performed on the comment. Only 'edit' is * recognized now. - * @param $comment + * @param EntityInterface $comment * The comment object. * @return * TRUE if the current user has acces to the comment, FALSE otherwise. */ -function comment_access($op, $comment) { +function comment_access($op, EntityInterface $comment) { global $user; if ($op == 'edit') { @@ -1435,12 +1435,10 @@ function comment_access($op, $comment) { /** * Accepts a submission of new or changed comment content. * - * @param $comment + * @param EntityInterface $comment * A comment object. - * - * @see comment_int_to_alphadecimal() */ -function comment_save($comment) { +function comment_save(EntityInterface $comment) { $comment->save(); } @@ -1605,7 +1603,7 @@ function comment_get_display_page($cid, $node_type) { /** * Page callback for comment editing. */ -function comment_edit_page($comment) { +function comment_edit_page(EntityInterface $comment) { drupal_set_title(t('Edit comment %comment', array('%comment' => $comment->subject)), PASS_THROUGH); $node = node_load($comment->nid); return drupal_get_form("comment_node_{$node->type}_form", $comment); @@ -1630,7 +1628,7 @@ function comment_forms() { * * @ingroup forms */ -function comment_form($form, &$form_state, $comment) { +function comment_form($form, &$form_state, EntityInterface $comment) { global $user; // During initial form build, add the comment entity to the form state for @@ -1834,7 +1832,7 @@ function comment_form_build_preview($form, &$form_state) { /** * Generate a comment preview. */ -function comment_preview($comment) { +function comment_preview(EntityInterface $comment) { global $user; drupal_set_title(t('Preview comment'), PASS_THROUGH); @@ -1933,7 +1931,7 @@ function comment_form_validate($form, &$form_state) { /** * Prepare a comment for submission. */ -function comment_submit($comment) { +function comment_submit(EntityInterface $comment) { if (empty($comment->date)) { $comment->date = 'now'; } @@ -2259,7 +2257,7 @@ function comment_action_info() { /** * Publishes a comment. * - * @param $comment + * @param EntityInterface $comment * An optional comment object. * @param array $context * Array with components: @@ -2267,7 +2265,7 @@ function comment_action_info() { * * @ingroup actions */ -function comment_publish_action($comment, $context = array()) { +function comment_publish_action(EntityInterface $comment = NULL, $context = array()) { if (isset($comment->subject)) { $subject = $comment->subject; $comment->status = COMMENT_PUBLISHED; @@ -2286,7 +2284,7 @@ function comment_publish_action($comment, $context = array()) { /** * Unpublishes a comment. * - * @param $comment + * @param EntityInterface $comment * An optional comment object. * @param array $context * Array with components: @@ -2294,7 +2292,7 @@ function comment_publish_action($comment, $context = array()) { * * @ingroup actions */ -function comment_unpublish_action($comment, $context = array()) { +function comment_unpublish_action(EntityInterface $comment = NULL, $context = array()) { if (isset($comment->subject)) { $subject = $comment->subject; $comment->status = COMMENT_NOT_PUBLISHED; @@ -2313,7 +2311,7 @@ function comment_unpublish_action($comment, $context = array()) { /** * Unpublishes a comment if it contains certain keywords. * - * @param $comment + * @param EntityInterface $comment * Comment object to modify. * @param array $context * Array with components: @@ -2324,7 +2322,7 @@ function comment_unpublish_action($comment, $context = array()) { * @see comment_unpublish_by_keyword_action_form() * @see comment_unpublish_by_keyword_action_submit() */ -function comment_unpublish_by_keyword_action($comment, $context) { +function comment_unpublish_by_keyword_action(EntityInterface $comment, $context) { foreach ($context['keywords'] as $keyword) { $text = drupal_render($comment); if (strpos($text, $keyword) !== FALSE) { @@ -2367,7 +2365,7 @@ function comment_unpublish_by_keyword_action_submit($form, $form_state) { * * @ingroup actions */ -function comment_save_action($comment) { +function comment_save_action(EntityInterface $comment) { comment_save($comment); cache_clear_all(); watchdog('action', 'Saved comment %title', array('%title' => $comment->subject)); diff --git a/modules/comment/comment.pages.inc b/modules/comment/comment.pages.inc index 7193fb1..568eedc 100644 --- a/modules/comment/comment.pages.inc +++ b/modules/comment/comment.pages.inc @@ -47,11 +47,12 @@ function comment_reply($node, $pid = NULL) { if ($pid) { if (user_access('access comments')) { // Load the comment whose cid = $pid - $comment = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data FROM {comment} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = :cid AND c.status = :status', array( + $values = db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.signature_format, u.picture, u.data FROM {comment} 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) { + ))->fetchAssoc(); + if (!empty($values)) { + $comment = entity_construct('comment', $values); // If that comment exists, make sure that the current comment and the // parent comment both belong to the same parent node. if ($comment->nid != $node->nid) {