Commit 51c004ab authored by catch's avatar catch

Issue #1361234 by duellj, loganfsmyth, aspilicious, cosmicdreams, fago,...

Issue #1361234 by duellj, loganfsmyth, aspilicious, cosmicdreams, fago, amateescu, sun: Added Make the node entity a classed object.
parent 4daf1c63
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
* Admin page callbacks for the book module. * Admin page callbacks for the book module.
*/ */
use Drupal\node\Node;
/** /**
* Page callback: Returns an administrative overview of all books. * Page callback: Returns an administrative overview of all books.
* *
...@@ -66,7 +68,7 @@ function book_admin_settings_validate($form, &$form_state) { ...@@ -66,7 +68,7 @@ function book_admin_settings_validate($form, &$form_state) {
/** /**
* Form constructor for administering a single book's hierarchy. * Form constructor for administering a single book's hierarchy.
* *
* @param $node * @param Drupal\node\Node $node
* The node of the top-level page in the book. * The node of the top-level page in the book.
* *
* @see book_menu() * @see book_menu()
...@@ -74,7 +76,7 @@ function book_admin_settings_validate($form, &$form_state) { ...@@ -74,7 +76,7 @@ function book_admin_settings_validate($form, &$form_state) {
* @see book_admin_edit_submit() * @see book_admin_edit_submit()
* @ingroup forms * @ingroup forms
*/ */
function book_admin_edit($form, $form_state, $node) { function book_admin_edit($form, $form_state, Node $node) {
drupal_set_title($node->title); drupal_set_title($node->title);
$form['#node'] = $node; $form['#node'] = $node;
_book_admin_table($node, $form); _book_admin_table($node, $form);
...@@ -135,7 +137,7 @@ function book_admin_edit_submit($form, &$form_state) { ...@@ -135,7 +137,7 @@ function book_admin_edit_submit($form, &$form_state) {
$node->revision = 1; $node->revision = 1;
$node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title'])); $node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title']));
node_save($node); $node->save();
watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid)); watchdog('content', 'book: updated %title.', array('%title' => $node->title), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
} }
} }
...@@ -147,14 +149,14 @@ function book_admin_edit_submit($form, &$form_state) { ...@@ -147,14 +149,14 @@ function book_admin_edit_submit($form, &$form_state) {
/** /**
* Builds the table portion of the form for the book administration page. * Builds the table portion of the form for the book administration page.
* *
* @param $node * @param Drupal\node\Node $node
* The node of the top-level page in the book. * The node of the top-level page in the book.
* @param $form * @param $form
* The form that is being modified. * The form that is being modified.
* *
* @see book_admin_edit() * @see book_admin_edit()
*/ */
function _book_admin_table($node, &$form) { function _book_admin_table(Node $node, &$form) {
$form['table'] = array( $form['table'] = array(
'#theme' => 'book_admin_table', '#theme' => 'book_admin_table',
'#tree' => TRUE, '#tree' => TRUE,
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
* Allows users to create and organize related content in an outline. * Allows users to create and organize related content in an outline.
*/ */
use Drupal\node\Node;
/** /**
* Implements hook_help(). * Implements hook_help().
*/ */
...@@ -86,12 +88,12 @@ function book_permission() { ...@@ -86,12 +88,12 @@ function book_permission() {
/** /**
* Adds relevant book links to the node's links. * Adds relevant book links to the node's links.
* *
* @param $node * @param Drupal\node\Node $node
* The book page node to add links to. * The book page node to add links to.
* @param $view_mode * @param $view_mode
* The view mode of the node. * The view mode of the node.
*/ */
function book_node_view_link($node, $view_mode) { function book_node_view_link(Node $node, $view_mode) {
$links = array(); $links = array();
if (isset($node->book['depth'])) { if (isset($node->book['depth'])) {
...@@ -201,24 +203,24 @@ function book_menu() { ...@@ -201,24 +203,24 @@ function book_menu() {
* - admin/content/book/%node * - admin/content/book/%node
* - node/%node/outline * - node/%node/outline
* *
* @param $node * @param Drupal\node\Node $node
* The node whose outline tab is to be viewed. * The node whose outline tab is to be viewed.
* *
* @see book_menu() * @see book_menu()
*/ */
function _book_outline_access($node) { function _book_outline_access(Node $node) {
return user_access('administer book outlines') && node_access('view', $node); return user_access('administer book outlines') && node_access('view', $node);
} }
/** /**
* Access callback: Determines if the user can remove nodes from the outline. * Access callback: Determines if the user can remove nodes from the outline.
* *
* @param $node * @param Drupal\node\Node $node
* The node to remove from the outline. * The node to remove from the outline.
* *
* @see book_menu() * @see book_menu()
*/ */
function _book_outline_remove_access($node) { function _book_outline_remove_access(Node $node) {
return _book_node_is_removable($node) && _book_outline_access($node); return _book_node_is_removable($node) && _book_outline_access($node);
} }
...@@ -520,10 +522,10 @@ function _book_parent_select($book_link) { ...@@ -520,10 +522,10 @@ function _book_parent_select($book_link) {
/** /**
* Builds the common elements of the book form for the node and outline forms. * Builds the common elements of the book form for the node and outline forms.
* *
* @param $node * @param Drupal\node\Node $node
* The node whose form is being viewed. * The node whose form is being viewed.
*/ */
function _book_add_form_elements(&$form, &$form_state, $node) { function _book_add_form_elements(&$form, &$form_state, Node $node) {
// If the form is being processed during the Ajax callback of our book bid // If the form is being processed during the Ajax callback of our book bid
// dropdown, then $form_state will hold the value that was selected. // dropdown, then $form_state will hold the value that was selected.
if (isset($form_state['values']['book'])) { if (isset($form_state['values']['book'])) {
...@@ -625,13 +627,13 @@ function book_form_update($form, $form_state) { ...@@ -625,13 +627,13 @@ function book_form_update($form, $form_state) {
* outline through node addition, node editing, node deletion, or the outline * outline through node addition, node editing, node deletion, or the outline
* tab. * tab.
* *
* @param $node * @param Drupal\node\Node $node
* The node that is being saved, added, deleted, or moved. * The node that is being saved, added, deleted, or moved.
* *
* @return * @return
* TRUE if the menu link was saved; FALSE otherwise. * TRUE if the menu link was saved; FALSE otherwise.
*/ */
function _book_update_outline($node) { function _book_update_outline(Node $node) {
if (empty($node->book['bid'])) { if (empty($node->book['bid'])) {
return FALSE; return FALSE;
} }
...@@ -889,7 +891,7 @@ function book_node_load($nodes, $types) { ...@@ -889,7 +891,7 @@ function book_node_load($nodes, $types) {
/** /**
* Implements hook_node_view(). * Implements hook_node_view().
*/ */
function book_node_view($node, $view_mode) { function book_node_view(Node $node, $view_mode) {
if ($view_mode == 'full') { if ($view_mode == 'full') {
if (!empty($node->book['bid']) && empty($node->in_preview)) { if (!empty($node->book['bid']) && empty($node->in_preview)) {
$node->content['book_navigation'] = array( $node->content['book_navigation'] = array(
...@@ -921,14 +923,10 @@ function book_page_alter(&$page) { ...@@ -921,14 +923,10 @@ function book_page_alter(&$page) {
/** /**
* Implements hook_node_presave(). * Implements hook_node_presave().
*/ */
function book_node_presave($node) { function book_node_presave(Node $node) {
// Always save a revision for non-administrators. // Always save a revision for non-administrators.
if (!empty($node->book['bid']) && !user_access('administer nodes')) { if (!empty($node->book['bid']) && !user_access('administer nodes')) {
$node->revision = 1; $node->revision = 1;
// The database schema requires a log message for every revision.
if (!isset($node->log)) {
$node->log = '';
}
} }
// Make sure a new node gets a new menu link. // Make sure a new node gets a new menu link.
if (empty($node->nid)) { if (empty($node->nid)) {
...@@ -939,7 +937,7 @@ function book_node_presave($node) { ...@@ -939,7 +937,7 @@ function book_node_presave($node) {
/** /**
* Implements hook_node_insert(). * Implements hook_node_insert().
*/ */
function book_node_insert($node) { function book_node_insert(Node $node) {
if (!empty($node->book['bid'])) { if (!empty($node->book['bid'])) {
if ($node->book['bid'] == 'new') { if ($node->book['bid'] == 'new') {
// New nodes that are their own book. // New nodes that are their own book.
...@@ -954,7 +952,7 @@ function book_node_insert($node) { ...@@ -954,7 +952,7 @@ function book_node_insert($node) {
/** /**
* Implements hook_node_update(). * Implements hook_node_update().
*/ */
function book_node_update($node) { function book_node_update(Node $node) {
if (!empty($node->book['bid'])) { if (!empty($node->book['bid'])) {
if ($node->book['bid'] == 'new') { if ($node->book['bid'] == 'new') {
// New nodes that are their own book. // New nodes that are their own book.
...@@ -969,7 +967,7 @@ function book_node_update($node) { ...@@ -969,7 +967,7 @@ function book_node_update($node) {
/** /**
* Implements hook_node_predelete(). * Implements hook_node_predelete().
*/ */
function book_node_predelete($node) { function book_node_predelete(Node $node) {
if (!empty($node->book['bid'])) { if (!empty($node->book['bid'])) {
if ($node->nid == $node->book['bid']) { if ($node->nid == $node->book['bid']) {
// Handle deletion of a top-level post. // Handle deletion of a top-level post.
...@@ -993,7 +991,7 @@ function book_node_predelete($node) { ...@@ -993,7 +991,7 @@ function book_node_predelete($node) {
/** /**
* Implements hook_node_prepare(). * Implements hook_node_prepare().
*/ */
function book_node_prepare($node) { function book_node_prepare(Node $node) {
// Prepare defaults for the add/edit form. // Prepare defaults for the add/edit form.
if (empty($node->book) && (user_access('add content to books') || user_access('administer book outlines'))) { if (empty($node->book) && (user_access('add content to books') || user_access('administer book outlines'))) {
$node->book = array(); $node->book = array();
...@@ -1291,7 +1289,7 @@ function book_export_traverse($tree, $visit_func) { ...@@ -1291,7 +1289,7 @@ function book_export_traverse($tree, $visit_func) {
/** /**
* Generates printer-friendly HTML for a node. * Generates printer-friendly HTML for a node.
* *
* @param $node * @param Drupal\node\Node $node
* The node that will be output. * The node that will be output.
* @param $children * @param $children
* All the rendered child nodes within the current node. * All the rendered child nodes within the current node.
...@@ -1301,7 +1299,7 @@ function book_export_traverse($tree, $visit_func) { ...@@ -1301,7 +1299,7 @@ function book_export_traverse($tree, $visit_func) {
* *
* @see book_export_traverse() * @see book_export_traverse()
*/ */
function book_node_export($node, $children = '') { function book_node_export(Node $node, $children = '') {
$build = node_view($node, 'print'); $build = node_view($node, 'print');
unset($build['#theme']); unset($build['#theme']);
// @todo Rendering should happen in the template using render(). // @todo Rendering should happen in the template using render().
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
* User page callbacks for the book module. * User page callbacks for the book module.
*/ */
use Drupal\node\Node;
/** /**
* Page callback: Prints a listing of all books. * Page callback: Prints a listing of all books.
* *
...@@ -93,12 +95,12 @@ function book_export_html($nid) { ...@@ -93,12 +95,12 @@ function book_export_html($nid) {
/** /**
* Page callback: Shows the outline form for a single node. * Page callback: Shows the outline form for a single node.
* *
* @param $node * @param Drupal\node\Node $node
* The book node for which to show the outline. * The book node for which to show the outline.
* *
* @see book_menu() * @see book_menu()
*/ */
function book_outline($node) { function book_outline(Node $node) {
drupal_set_title($node->title); drupal_set_title($node->title);
return drupal_get_form('book_outline_form', $node); return drupal_get_form('book_outline_form', $node);
} }
...@@ -108,14 +110,14 @@ function book_outline($node) { ...@@ -108,14 +110,14 @@ function book_outline($node) {
* *
* Allows handling of all book outline operations via the outline tab. * Allows handling of all book outline operations via the outline tab.
* *
* @param $node * @param Drupal\node\Node $node
* The book node for which to show the outline. * The book node for which to show the outline.
* *
* @see book_outline_form_submit() * @see book_outline_form_submit()
* @see book_remove_button_submit() * @see book_remove_button_submit()
* @ingroup forms * @ingroup forms
*/ */
function book_outline_form($form, &$form_state, $node) { function book_outline_form($form, &$form_state, Node $node) {
if (!isset($node->book)) { if (!isset($node->book)) {
// The node is not part of any book yet - set default options. // The node is not part of any book yet - set default options.
$node->book = _book_link_defaults($node->nid); $node->book = _book_link_defaults($node->nid);
...@@ -197,14 +199,14 @@ function book_outline_form_submit($form, &$form_state) { ...@@ -197,14 +199,14 @@ function book_outline_form_submit($form, &$form_state) {
/** /**
* Form constructor to confirm removal of a node from a book. * Form constructor to confirm removal of a node from a book.
* *
* @param $node * @param Drupal\node\Node $node
* The node to delete. * The node to delete.
* *
* @see book_remove_form_submit() * @see book_remove_form_submit()
* @see book_menu() * @see book_menu()
* @ingroup forms * @ingroup forms
*/ */
function book_remove_form($form, &$form_state, $node) { function book_remove_form($form, &$form_state, Node $node) {
$form['#node'] = $node; $form['#node'] = $node;
$title = array('%title' => $node->title); $title = array('%title' => $node->title);
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
* Tests for book.module. * Tests for book.module.
*/ */
use Drupal\node\Node;
class BookTestCase extends DrupalWebTestCase { class BookTestCase extends DrupalWebTestCase {
protected $book; protected $book;
// $book_author is a user with permission to create and edit books. // $book_author is a user with permission to create and edit books.
...@@ -108,7 +110,7 @@ class BookTestCase extends DrupalWebTestCase { ...@@ -108,7 +110,7 @@ class BookTestCase extends DrupalWebTestCase {
/** /**
* Check the outline of sub-pages; previous, up, and next; and printer friendly version. * Check the outline of sub-pages; previous, up, and next; and printer friendly version.
* *
* @param $node * @param Node $node
* Node to check. * Node to check.
* @param $nodes * @param $nodes
* Nodes that should be in outline. * Nodes that should be in outline.
...@@ -121,7 +123,7 @@ class BookTestCase extends DrupalWebTestCase { ...@@ -121,7 +123,7 @@ class BookTestCase extends DrupalWebTestCase {
* @param $breadcrumb * @param $breadcrumb
* The nodes that should be displayed in the breadcrumb. * The nodes that should be displayed in the breadcrumb.
*/ */
function checkBookNode($node, $nodes, $previous = FALSE, $up = FALSE, $next = FALSE, array $breadcrumb) { function checkBookNode(Node $node, $nodes, $previous = FALSE, $up = FALSE, $next = FALSE, array $breadcrumb) {
// $number does not use drupal_static as it should not be reset // $number does not use drupal_static as it should not be reset
// since it uniquely identifies each call to checkBookNode(). // since it uniquely identifies each call to checkBookNode().
static $number = 0; static $number = 0;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* the template. * the template.
* *
* The following variables are provided for contextual information. * The following variables are provided for contextual information.
* - $node: Node object the comments are attached to. * - $node: Node entity the comments are attached to.
* The constants below the variables show the possible values and should be * The constants below the variables show the possible values and should be
* used for comparison. * used for comparison.
* - $display_mode * - $display_mode
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* book page, etc. * book page, etc.
*/ */
use Drupal\node\Node;
/** /**
* Comment is awaiting approval. * Comment is awaiting approval.
*/ */
...@@ -545,13 +547,13 @@ function comment_get_recent($number = 10) { ...@@ -545,13 +547,13 @@ function comment_get_recent($number = 10) {
* Number of comments. * Number of comments.
* @param $new_replies * @param $new_replies
* Number of new replies. * Number of new replies.
* @param $node * @param Drupal\node\Node $node
* The first new comment node. * The first new comment node.
* *
* @return * @return
* "page=X" if the page number is greater than zero; empty string otherwise. * "page=X" if the page number is greater than zero; empty string otherwise.
*/ */
function comment_new_page_count($num_comments, $new_replies, $node) { function comment_new_page_count($num_comments, $new_replies, Node $node) {
$mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED);
$comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50);
$pagenum = NULL; $pagenum = NULL;
...@@ -629,7 +631,7 @@ function theme_comment_block() { ...@@ -629,7 +631,7 @@ function theme_comment_block() {
/** /**
* Implements hook_node_view(). * Implements hook_node_view().
*/ */
function comment_node_view($node, $view_mode) { function comment_node_view(Node $node, $view_mode) {
$links = array(); $links = array();
if ($node->comment != COMMENT_NODE_HIDDEN) { if ($node->comment != COMMENT_NODE_HIDDEN) {
...@@ -737,14 +739,14 @@ function comment_node_view($node, $view_mode) { ...@@ -737,14 +739,14 @@ function comment_node_view($node, $view_mode) {
/** /**
* Builds the comment-related elements for node detail pages. * Builds the comment-related elements for node detail pages.
* *
* @param $node * @param Drupal\node\Node $node
* The node object for which to build the comment-related elements. * The node entity for which to build the comment-related elements.
* *
* @return * @return
* A renderable array representing the comment-related page elements for the * A renderable array representing the comment-related page elements for the
* node. * node.
*/ */
function comment_node_page_additions($node) { function comment_node_page_additions(Node $node) {
$additions = array(); $additions = array();
// Only attempt to render comments if the node has visible comments. // Only attempt to render comments if the node has visible comments.
...@@ -783,7 +785,7 @@ function comment_node_page_additions($node) { ...@@ -783,7 +785,7 @@ function comment_node_page_additions($node) {
/** /**
* Retrieves comments for a thread. * Retrieves comments for a thread.
* *
* @param $node * @param Drupal\node\Node $node
* The node whose comment(s) needs rendering. * The node whose comment(s) needs rendering.
* @param $mode * @param $mode
* The comment display mode; COMMENT_MODE_FLAT or COMMENT_MODE_THREADED. * The comment display mode; COMMENT_MODE_FLAT or COMMENT_MODE_THREADED.
...@@ -847,7 +849,7 @@ function comment_node_page_additions($node) { ...@@ -847,7 +849,7 @@ function comment_node_page_additions($node) {
* spoil the reverse ordering, "ORDER BY thread ASC" -- here, we do not need * spoil the reverse ordering, "ORDER BY thread ASC" -- here, we do not need
* to consider the trailing "/" so we use a substring only. * to consider the trailing "/" so we use a substring only.
*/ */
function comment_get_thread($node, $mode, $comments_per_page) { function comment_get_thread(Node $node, $mode, $comments_per_page) {
$query = db_select('comment', 'c')->extend('PagerDefault'); $query = db_select('comment', 'c')->extend('PagerDefault');
$query->addField('c', 'cid'); $query->addField('c', 'cid');
$query $query
...@@ -936,7 +938,7 @@ function comment_prepare_thread(&$comments) { ...@@ -936,7 +938,7 @@ function comment_prepare_thread(&$comments) {
* *
* @param Comment $comment * @param Comment $comment
* The comment object. * The comment object.
* @param $node * @param Drupal\node\Node $node
* The node the comment is attached to. * The node the comment is attached to.
* @param $view_mode * @param $view_mode
* View mode, e.g. 'full', 'teaser'... * View mode, e.g. 'full', 'teaser'...
...@@ -947,7 +949,7 @@ function comment_prepare_thread(&$comments) { ...@@ -947,7 +949,7 @@ function comment_prepare_thread(&$comments) {
* @return * @return
* An array as expected by drupal_render(). * An array as expected by drupal_render().
*/ */
function comment_view(Comment $comment, $node, $view_mode = 'full', $langcode = NULL) { function comment_view(Comment $comment, Node $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) { if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->langcode; $langcode = $GLOBALS['language_content']->langcode;
} }
...@@ -1006,7 +1008,7 @@ function comment_view(Comment $comment, $node, $view_mode = 'full', $langcode = ...@@ -1006,7 +1008,7 @@ function comment_view(Comment $comment, $node, $view_mode = 'full', $langcode =
* *
* @param Comment $comment * @param Comment $comment
* A comment object. * A comment object.
* @param $node * @param Drupal\node\Node $node
* The node the comment is attached to. * The node the comment is attached to.
* @param $view_mode * @param $view_mode
* View mode, e.g. 'full', 'teaser'... * View mode, e.g. 'full', 'teaser'...
...@@ -1014,7 +1016,7 @@ function comment_view(Comment $comment, $node, $view_mode = 'full', $langcode = ...@@ -1014,7 +1016,7 @@ function comment_view(Comment $comment, $node, $view_mode = 'full', $langcode =
* (optional) A language code to use for rendering. Defaults to the global * (optional) A language code to use for rendering. Defaults to the global
* content language of the current request. * content language of the current request.
*/ */
function comment_build_content(Comment $comment, $node, $view_mode = 'full', $langcode = NULL) { function comment_build_content(Comment $comment, Node $node, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) { if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->langcode; $langcode = $GLOBALS['language_content']->langcode;
} }
...@@ -1050,13 +1052,13 @@ function comment_build_content(Comment $comment, $node, $view_mode = 'full', $la ...@@ -1050,13 +1052,13 @@ function comment_build_content(Comment $comment, $node, $view_mode = 'full', $la
* *
* @param Comment $comment * @param Comment $comment
* The comment object. * The comment object.
* @param $node * @param Drupal\node\Node $node
* The node the comment is attached to. * The node the comment is attached to.
* *
* @return * @return
* A structured array of links. * A structured array of links.
*/ */
function comment_links(Comment $comment, $node) { function comment_links(Comment $comment, Node $node) {
$links = array(); $links = array();
if ($node->comment == COMMENT_NODE_OPEN) { if ($node->comment == COMMENT_NODE_OPEN) {
if (user_access('administer comments') && user_access('post comments')) { if (user_access('administer comments') && user_access('post comments')) {
...@@ -1111,7 +1113,7 @@ function comment_links(Comment $comment, $node) { ...@@ -1111,7 +1113,7 @@ function comment_links(Comment $comment, $node) {
* *
* @param $comments * @param $comments
* An array of comments as returned by comment_load_multiple(). * An array of comments as returned by comment_load_multiple().
* @param $node * @param Drupal\node\Node $node
* The node the comments are attached to. * The node the comments are attached to.
* @param $view_mode * @param $view_mode
* View mode, e.g. 'full', 'teaser'... * View mode, e.g. 'full', 'teaser'...
...@@ -1126,7 +1128,7 @@ function comment_links(Comment $comment, $node) { ...@@ -1126,7 +1128,7 @@ function comment_links(Comment $comment, $node) {
* *
* @see drupal_render() * @see drupal_render()
*/ */
function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0, $langcode = NULL) { function comment_view_multiple($comments, Node $node, $view_mode = 'full', $weight = 0, $langcode = NULL) {
field_attach_prepare_view('comment', $comments, $view_mode, $langcode); field_attach_prepare_view('comment', $comments, $view_mode, $langcode);
entity_prepare_view('comment', $comments, $langcode); entity_prepare_view('comment', $comments, $langcode);
...@@ -1308,7 +1310,7 @@ function comment_node_load($nodes, $types) { ...@@ -1308,7 +1310,7 @@ function comment_node_load($nodes, $types) {
/** /**
* Implements hook_node_prepare(). * Implements hook_node_prepare().
*/ */
function comment_node_prepare($node) { function comment_node_prepare(Node $node) {
if (!isset($node->comment)) { if (!isset($node->comment)) {
$node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN); $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN);
} }
...@@ -1317,7 +1319,7 @@ function comment_node_prepare($node) { ...@@ -1317,7 +1319,7 @@ function comment_node_prepare($node) {
/** /**
* Implements hook_node_insert(). * Implements hook_node_insert().
*/ */
function comment_node_insert($node) { function comment_node_insert(Node $node) {
// Allow bulk updates and inserts to temporarily disable the // Allow bulk updates and inserts to temporarily disable the
// maintenance of the {node_comment_statistics} table. // maintenance of the {node_comment_statistics} table.
if (variable_get('comment_maintain_node_statistics', TRUE)) { if (variable_get('comment_maintain_node_statistics', TRUE)) {
...@@ -1337,7 +1339,7 @@ function comment_node_insert($node) { ...@@ -1337,7 +1339,7 @@ function comment_node_insert($node) {
/** /**
* Implements hook_node_predelete(). * Implements hook_node_predelete().
*/ */
function comment_node_predelete($node) { function comment_node_predelete(Node $node) {
$cids = db_query('SELECT cid FROM {comment} WHERE nid = :nid', array(':nid' => $node->nid))->fetchCol(); $cids = db_query('SELECT cid FROM {comment} WHERE nid = :nid', array(':nid' => $node->nid))->fetchCol();
comment_delete_multiple($cids); comment_delete_multiple($cids);
db_delete('node_comment_statistics') db_delete('node_comment_statistics')
...@@ -1348,7 +1350,7 @@ function comment_node_predelete($node) { ...@@ -1348,7 +1350,7 @@ function comment_node_predelete($node) {
/** /**
* Implements hook_node_update_index(). * Implements hook_node_update_index().
*/ */
function comment_node_update_index($node) { function comment_node_update_index(Node $node) {
$index_comments = &drupal_static(__FUNCTION__); $index_comments = &drupal_static(__FUNCTION__);
if ($index_comments === NULL) { if ($index_comments === NULL) {
...@@ -1397,7 +1399,7 @@ function comment_update_index() { ...@@ -1397,7 +1399,7 @@ function comment_update_index() {
* Formats a comment count string and returns it, for display with search * Formats a comment count string and returns it, for display with search
* results. * results.
*/ */
function comment_node_search_result($node) { function comment_node_search_result(Node $node) {
// Do not make a string if comments are hidden. // Do not make a string if comments are hidden.
if (user_access('access comments') && $node->comment != COMMENT_NODE_HIDDEN) { if (user_access('access comments') && $node->comment != COMMENT_NODE_HIDDEN) {
$comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField();