Commit ad137531 authored by alexpott's avatar alexpott

Issue #2041287 by Berdir: Convert ->nid to ->id() and ->isNew().

parent d455adeb
......@@ -4929,7 +4929,7 @@ function _drupal_form_send_response(Response $response) {
*
* $nodes = entity_load_multiple_by_properties('node', array('uid' => $uid, 'type' => $type));
* $node = reset($nodes);
* $context['results'][] = $node->nid . ' : ' . check_plain($node->label());
* $context['results'][] = $node->id() . ' : ' . check_plain($node->label());
* $context['message'] = check_plain($node->label());
* }
*
......
......@@ -86,7 +86,7 @@ function book_admin_edit_submit($form, &$form_state) {
$node->log = t('Title changed from %original to %current.', array('%original' => $node->title, '%current' => $values['title']));
$node->save();
watchdog('content', 'book: updated %title.', array('%title' => $node->label()), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->nid));
watchdog('content', 'book: updated %title.', array('%title' => $node->label()), WATCHDOG_NOTICE, l(t('view'), 'node/' . $node->id()));
}
}
}
......
......@@ -137,7 +137,7 @@ function book_node_view_link(EntityInterface $node, $view_mode) {
if (user_access('access printer-friendly version')) {
$links['book_printer'] = array(
'title' => t('Printer-friendly version'),
'href' => 'book/export/html/' . $node->nid,
'href' => 'book/export/html/' . $node->id(),
'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.'))
);
}
......@@ -265,7 +265,7 @@ function _book_outline_remove_access(EntityInterface $node) {
* The node to remove from the outline.
*/
function _book_node_is_removable(EntityInterface $node) {
return (!empty($node->book['bid']) && (($node->book['bid'] != $node->nid) || !$node->book['has_children']));
return (!empty($node->book['bid']) && (($node->book['bid'] != $node->id()) || !$node->book['has_children']));
}
/**
......@@ -307,7 +307,7 @@ function book_form_node_form_alter(&$form, &$form_state, $form_id) {
$node = $form_state['controller']->getEntity();
$access = user_access('administer book outlines');
if (!$access) {
if (user_access('add content to books') && ((!empty($node->book['mlid']) && !empty($node->nid)) || book_type_is_allowed($node->type))) {
if (user_access('add content to books') && ((!empty($node->book['mlid']) && !$node->isNew()) || book_type_is_allowed($node->type))) {
// Already in the book hierarchy, or this node type is allowed.
$access = TRUE;
}
......@@ -447,11 +447,11 @@ function _book_add_form_elements(&$form, &$form_state, EntityInterface $node) {
'#description' => t('Pages at a given level are ordered first by weight and then by title.'),
);
$options = array();
$nid = isset($node->nid) ? $node->nid : 'new';
$nid = !$node->isNew() ? $node->id() : 'new';
if (isset($node->nid) && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
if ($node->id() && ($nid == $node->book['original_bid']) && ($node->book['parent_depth_limit'] == 0)) {
// This is the top level node in a maximum depth book and thus cannot be moved.
$options[$node->nid] = $node->label();
$options[$node->id()] = $node->label();
}
else {
foreach (book_get_books() as $book) {
......@@ -519,13 +519,13 @@ function _book_update_outline(EntityInterface $node) {
}
$new = empty($node->book['mlid']);
$node->book['link_path'] = 'node/' . $node->nid;
$node->book['link_path'] = 'node/' . $node->id();
$node->book['link_title'] = $node->label();
$node->book['parent_mismatch'] = FALSE; // The normal case.
if ($node->book['bid'] == $node->nid) {
if ($node->book['bid'] == $node->id()) {
$node->book['plid'] = 0;
$node->book['menu_name'] = book_menu_name($node->nid);
$node->book['menu_name'] = book_menu_name($node->id());
}
else {
// Check in case the parent is not is this book; the book takes precedence.
......@@ -548,7 +548,7 @@ function _book_update_outline(EntityInterface $node) {
// Insert new.
db_insert('book')
->fields(array(
'nid' => $node->nid,
'nid' => $node->id(),
'mlid' => $node->book['mlid'],
'bid' => $node->book['bid'],
))
......@@ -558,7 +558,7 @@ function _book_update_outline(EntityInterface $node) {
}
else {
if ($node->book['bid'] != db_query("SELECT bid FROM {book} WHERE nid = :nid", array(
':nid' => $node->nid,
':nid' => $node->id(),
))->fetchField()) {
// Update the bid for this page and all children.
book_update_bid($node->book);
......@@ -816,7 +816,7 @@ function book_node_presave(EntityInterface $node) {
$node->setNewRevision();
}
// Make sure a new node gets a new menu link.
if (empty($node->nid)) {
if ($node->isNew()) {
$node->book['mlid'] = NULL;
}
}
......@@ -828,9 +828,9 @@ function book_node_insert(EntityInterface $node) {
if (!empty($node->book['bid'])) {
if ($node->book['bid'] == 'new') {
// New nodes that are their own book.
$node->book['bid'] = $node->nid;
$node->book['bid'] = $node->id();
}
$node->book['nid'] = $node->nid;
$node->book['nid'] = $node->id();
$node->book['menu_name'] = book_menu_name($node->book['bid']);
_book_update_outline($node);
}
......@@ -843,9 +843,9 @@ function book_node_update(EntityInterface $node) {
if (!empty($node->book['bid'])) {
if ($node->book['bid'] == 'new') {
// New nodes that are their own book.
$node->book['bid'] = $node->nid;
$node->book['bid'] = $node->id();
}
$node->book['nid'] = $node->nid;
$node->book['nid'] = $node->id();
$node->book['menu_name'] = book_menu_name($node->book['bid']);
_book_update_outline($node);
}
......@@ -856,14 +856,14 @@ function book_node_update(EntityInterface $node) {
*/
function book_node_predelete(EntityInterface $node) {
if (!empty($node->book['bid'])) {
if ($node->nid == $node->book['bid']) {
if ($node->id() == $node->book['bid']) {
// Handle deletion of a top-level post.
$result = db_query("SELECT b.nid FROM {menu_links} ml INNER JOIN {book} b on b.mlid = ml.mlid WHERE ml.plid = :plid", array(
':plid' => $node->book['mlid']
));
foreach ($result as $child) {
$child_node = node_load($child->nid);
$child_node->book['bid'] = $child_node->nid;
$child_node = node_load($child->id());
$child_node->book['bid'] = $child_node->id();
_book_update_outline($child_node);
}
}
......@@ -884,7 +884,7 @@ function book_node_prepare_form(NodeInterface $node, $form_display, $operation,
$node->book = array();
$query = \Drupal::request()->query;
if (empty($node->nid) && !is_null($query->get('parent')) && is_numeric($query->get('parent'))) {
if ($node->isNew() && !is_null($query->get('parent')) && is_numeric($query->get('parent'))) {
// Handle "Add child page" links:
$parent = book_link_load($query->get('parent'));
......@@ -895,7 +895,7 @@ function book_node_prepare_form(NodeInterface $node, $form_display, $operation,
}
}
// Set defaults.
$node->book += _book_link_defaults(!empty($node->nid) ? $node->nid : 'new');
$node->book += _book_link_defaults(!$node->isNew() ? $node->id() : 'new');
}
else {
if (isset($node->book['bid']) && !isset($node->book['original_bid'])) {
......
......@@ -115,7 +115,7 @@ function book_outline(EntityInterface $node) {
function book_outline_form($form, &$form_state, EntityInterface $node) {
if (!isset($node->book)) {
// 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->id());
}
else {
$node->book['original_bid'] = $node->book['bid'];
......@@ -154,7 +154,7 @@ function book_outline_form($form, &$form_state, EntityInterface $node) {
* @see book_outline_form_submit()
*/
function book_remove_button_submit($form, &$form_state) {
$form_state['redirect'] = 'node/' . $form['#node']->nid . '/outline/remove';
$form_state['redirect'] = 'node/' . $form['#node']->id() . '/outline/remove';
}
/**
......@@ -164,7 +164,7 @@ function book_remove_button_submit($form, &$form_state) {
*/
function book_outline_form_submit($form, &$form_state) {
$node = $form['#node'];
$form_state['redirect'] = "node/" . $node->nid;
$form_state['redirect'] = "node/" . $node->id();
$book_link = $form_state['values']['book'];
if (!$book_link['bid']) {
drupal_set_message(t('No changes were made'));
......@@ -178,7 +178,7 @@ function book_outline_form_submit($form, &$form_state) {
if ($node->book['parent_mismatch']) {
// This will usually only happen when JS is disabled.
drupal_set_message(t('The post has been added to the selected book. You may now position it relative to other pages.'));
$form_state['redirect'] = "node/" . $node->nid . "/outline";
$form_state['redirect'] = "node/" . $node->id() . "/outline";
}
else {
drupal_set_message(t('The book outline has been updated.'));
......@@ -210,7 +210,7 @@ function book_remove_form($form, &$form_state, EntityInterface $node) {
$description = t('%title may be added to hierarchy again using the Outline tab.', $title);
}
return confirm_form($form, t('Are you sure you want to remove %title from the book hierarchy?', $title), 'node/' . $node->nid, $description, t('Remove'));
return confirm_form($form, t('Are you sure you want to remove %title from the book hierarchy?', $title), 'node/' . $node->id(), $description, t('Remove'));
}
/**
......@@ -221,9 +221,9 @@ function book_remove_form_submit($form, &$form_state) {
if (_book_node_is_removable($node)) {
menu_link_delete($node->book['mlid']);
db_delete('book')
->condition('nid', $node->nid)
->condition('nid', $node->id())
->execute();
drupal_set_message(t('The post has been removed from the book.'));
}
$form_state['redirect'] = 'node/' . $node->nid;
$form_state['redirect'] = 'node/' . $node->id();
}
......@@ -91,11 +91,11 @@ function createBook() {
* |- Node 4
*/
$nodes = array();
$nodes[] = $this->createBookNode($book->nid); // Node 0.
$nodes[] = $this->createBookNode($book->nid, $nodes[0]->book['mlid']); // Node 1.
$nodes[] = $this->createBookNode($book->nid, $nodes[0]->book['mlid']); // Node 2.
$nodes[] = $this->createBookNode($book->nid); // Node 3.
$nodes[] = $this->createBookNode($book->nid); // Node 4.
$nodes[] = $this->createBookNode($book->id()); // Node 0.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['mlid']); // Node 1.
$nodes[] = $this->createBookNode($book->id(), $nodes[0]->book['mlid']); // Node 2.
$nodes[] = $this->createBookNode($book->id()); // Node 3.
$nodes[] = $this->createBookNode($book->id()); // Node 4.
$this->drupalLogout();
......@@ -126,9 +126,9 @@ function testBook() {
// Create a second book, and move an existing book page into it.
$this->drupalLogin($this->book_author);
$other_book = $this->createBookNode('new');
$node = $this->createBookNode($book->nid);
$edit = array('book[bid]' => $other_book->nid);
$this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
$node = $this->createBookNode($book->id());
$edit = array('book[bid]' => $other_book->id());
$this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->drupalLogout();
$this->drupalLogin($this->web_user);
......@@ -163,7 +163,7 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
// $number does not use drupal_static as it should not be reset
// since it uniquely identifies each call to checkBookNode().
static $number = 0;
$this->drupalGet('node/' . $node->nid);
$this->drupalGet('node/' . $node->id());
// Check outline structure.
if ($nodes !== NULL) {
......@@ -175,22 +175,22 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
// Check previous, up, and next links.
if ($previous) {
$this->assertRaw(l('<b>‹</b> ' . $previous->label(), 'node/' . $previous->nid, array('html' => TRUE, 'attributes' => array('rel' => array('prev'), 'title' => t('Go to previous page')))), 'Previous page link found.');
$this->assertRaw(l('<b>‹</b> ' . $previous->label(), 'node/' . $previous->id(), array('html' => TRUE, 'attributes' => array('rel' => array('prev'), 'title' => t('Go to previous page')))), 'Previous page link found.');
}
if ($up) {
$this->assertRaw(l('Up', 'node/' . $up->nid, array('html'=> TRUE, 'attributes' => array('title' => t('Go to parent page')))), 'Up page link found.');
$this->assertRaw(l('Up', 'node/' . $up->id(), array('html'=> TRUE, 'attributes' => array('title' => t('Go to parent page')))), 'Up page link found.');
}
if ($next) {
$this->assertRaw(l($next->label() . ' <b>›</b>', 'node/' . $next->nid, array('html'=> TRUE, 'attributes' => array('rel' => array('next'), 'title' => t('Go to next page')))), 'Next page link found.');
$this->assertRaw(l($next->label() . ' <b>›</b>', 'node/' . $next->id(), array('html'=> TRUE, 'attributes' => array('rel' => array('next'), 'title' => t('Go to next page')))), 'Next page link found.');
}
// Compute the expected breadcrumb.
$expected_breadcrumb = array();
$expected_breadcrumb[] = url('');
foreach ($breadcrumb as $a_node) {
$expected_breadcrumb[] = url('node/' . $a_node->nid);
$expected_breadcrumb[] = url('node/' . $a_node->id());
}
// Fetch links in the current breadcrumb.
......@@ -204,7 +204,7 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
$this->assertIdentical($expected_breadcrumb, $got_breadcrumb, 'The breadcrumb is correctly displayed on the page.');
// Check printer friendly version.
$this->drupalGet('book/export/html/' . $node->nid);
$this->drupalGet('book/export/html/' . $node->id());
$this->assertText($node->label(), 'Printer friendly title found.');
$this->assertRaw(check_markup($node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], $node->body[Language::LANGCODE_NOT_SPECIFIED][0]['format']), 'Printer friendly body found.');
......@@ -223,10 +223,10 @@ function checkBookNode(EntityInterface $node, $nodes, $previous = FALSE, $up = F
function generateOutlinePattern($nodes) {
$outline = '';
foreach ($nodes as $node) {
$outline .= '(node\/' . $node->nid . ')(.*?)(' . $node->label() . ')(.*?)';
$outline .= '(node\/' . $node->id() . ')(.*?)(' . $node->label() . ')(.*?)';
}
return '/<nav id="book-navigation-' . $this->book->nid . '"(.*?)<ul(.*?)' . $outline . '<\/ul>/s';
return '/<nav id="book-navigation-' . $this->book->id() . '"(.*?)<ul(.*?)' . $outline . '<\/ul>/s';
}
/**
......@@ -275,7 +275,7 @@ function testBookExport() {
// Login as web user and view printer-friendly version.
$this->drupalLogin($this->web_user);
$this->drupalGet('node/' . $this->book->nid);
$this->drupalGet('node/' . $this->book->id());
$this->clickLink(t('Printer-friendly version'));
// Make sure each part of the book is there.
......@@ -285,7 +285,7 @@ function testBookExport() {
}
// Make sure we can't export an unsupported format.
$this->drupalGet('book/export/foobar/' . $this->book->nid);
$this->drupalGet('book/export/foobar/' . $this->book->id());
$this->assertResponse('404', 'Unsupported export format returned "not found".');
// Make sure we get a 404 on a not existing book node.
......@@ -296,18 +296,18 @@ function testBookExport() {
$this->drupalLogout();
// Load the book and verify there is no printer-friendly version link.
$this->drupalGet('node/' . $this->book->nid);
$this->drupalGet('node/' . $this->book->id());
$this->assertNoLink(t('Printer-friendly version'), 'Anonymous user is not shown link to printer-friendly version.');
// Try getting the URL directly, and verify it fails.
$this->drupalGet('book/export/html/' . $this->book->nid);
$this->drupalGet('book/export/html/' . $this->book->id());
$this->assertResponse('403', 'Anonymous user properly forbidden.');
// Now grant anonymous users permission to view the printer-friendly
// version and verify that node access restrictions still prevent them from
// seeing it.
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access printer-friendly version'));
$this->drupalGet('book/export/html/' . $this->book->nid);
$this->drupalGet('book/export/html/' . $this->book->id());
$this->assertResponse('403', 'Anonymous user properly forbidden from seeing the printer-friendly version when denied by node access.');
}
......@@ -352,12 +352,12 @@ function testNavigationBlockOnAccessModuleEnabled() {
// Test correct display of the block to registered users.
$this->drupalLogin($this->web_user);
$this->drupalGet('node/' . $this->book->nid);
$this->drupalGet('node/' . $this->book->id());
$this->assertText($block->label(), 'Book navigation block is displayed to registered users.');
$this->drupalLogout();
// Test correct display of the block to anonymous users.
$this->drupalGet('node/' . $this->book->nid);
$this->drupalGet('node/' . $this->book->id());
$this->assertText($block->label(), 'Book navigation block is displayed to anonymous users.');
// Test the 'book pages' block_mode setting.
......@@ -374,19 +374,19 @@ function testBookDelete() {
$edit = array();
// Test access to delete top-level and child book nodes.
$this->drupalGet('node/' . $this->book->nid . '/outline/remove');
$this->drupalGet('node/' . $this->book->id() . '/outline/remove');
$this->assertResponse('403', 'Deleting top-level book node properly forbidden.');
$this->drupalPost('node/' . $nodes[4]->nid . '/outline/remove', $edit, t('Remove'));
$node4 = node_load($nodes[4]->nid, TRUE);
$this->drupalPost('node/' . $nodes[4]->id() . '/outline/remove', $edit, t('Remove'));
$node4 = node_load($nodes[4]->id(), TRUE);
$this->assertTrue(empty($node4->book), 'Deleting child book node properly allowed.');
// Delete all child book nodes and retest top-level node deletion.
foreach ($nodes as $node) {
$nids[] = $node->nid;
$nids[] = $node->id();
}
entity_delete_multiple('node', $nids);
$this->drupalPost('node/' . $this->book->nid . '/outline/remove', $edit, t('Remove'));
$node = node_load($this->book->nid, TRUE);
$this->drupalPost('node/' . $this->book->id() . '/outline/remove', $edit, t('Remove'));
$node = node_load($this->book->id(), TRUE);
$this->assertTrue(empty($node->book), 'Deleting childless top-level book node properly allowed.');
}
......@@ -492,22 +492,22 @@ public function testBookOrdering() {
$book = $this->book;
$this->drupalLogin($this->admin_user);
$node1 = $this->createBookNode($book->nid);
$node2 = $this->createBookNode($book->nid);
$node1 = $this->createBookNode($book->id());
$node2 = $this->createBookNode($book->id());
$plid = $node1->book['mlid'];
// Head to admin screen and attempt to re-order.
$this->drupalGet('admin/structure/book/' . $book->nid);
$this->drupalGet('admin/structure/book/' . $book->id());
$edit = array(
"table[book-admin-{$node1->nid}][weight]" => 1,
"table[book-admin-{$node2->nid}][weight]" => 2,
"table[book-admin-{$node1->id()}][weight]" => 1,
"table[book-admin-{$node2->id()}][weight]" => 2,
// Put node 2 under node 1.
"table[book-admin-{$node2->nid}][plid]" => $plid,
"table[book-admin-{$node2->id()}][plid]" => $plid,
);
$this->drupalPost(NULL, $edit, t('Save book pages'));
// Verify weight was updated.
$this->assertFieldByName("table[book-admin-{$node1->nid}][weight]", 1);
$this->assertFieldByName("table[book-admin-{$node2->nid}][weight]", 2);
$this->assertFieldByName("table[book-admin-{$node2->nid}][plid]", $plid);
$this->assertFieldByName("table[book-admin-{$node1->id()}][weight]", 1);
$this->assertFieldByName("table[book-admin-{$node2->id()}][weight]", 2);
$this->assertFieldByName("table[book-admin-{$node2->id()}][plid]", $plid);
}
}
......@@ -452,7 +452,7 @@ function comment_new_page_count($num_comments, $new_replies, EntityInterface $no
// 1. Find all the threads with a new comment.
$unread_threads_query = db_select('comment')
->fields('comment', array('thread'))
->condition('nid', $node->nid)
->condition('nid', $node->id())
->condition('status', COMMENT_PUBLISHED)
->orderBy('created', 'DESC')
->orderBy('cid', 'DESC')
......@@ -472,7 +472,7 @@ function comment_new_page_count($num_comments, $new_replies, EntityInterface $no
// Find the number of the first comment of the first unread thread.
$count = db_query('SELECT COUNT(*) FROM {comment} WHERE nid = :nid AND status = :status AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread', array(
':status' => COMMENT_PUBLISHED,
':nid' => $node->nid,
':nid' => $node->id(),
':thread' => $first_thread,
))->fetchField();
......@@ -521,7 +521,7 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_
// Add a comments RSS element which is a URL to the comments of this node.
$node->rss_elements[] = array(
'key' => 'comments',
'value' => url('node/' . $node->nid, array('fragment' => 'comments', 'absolute' => TRUE))
'value' => url('node/' . $node->id(), array('fragment' => 'comments', 'absolute' => TRUE))
);
}
elseif ($view_mode == 'teaser') {
......@@ -532,16 +532,16 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_
if (!empty($node->comment_count)) {
$links['comment-comments'] = array(
'title' => format_plural($node->comment_count, '1 comment', '@count comments'),
'href' => "node/$node->nid",
'href' => 'node/' . $node->id(),
'attributes' => array('title' => t('Jump to the first comment of this posting.')),
'fragment' => 'comments',
'html' => TRUE,
);
// Show a link to the first new comment.
if ($new = comment_num_new($node->nid)) {
if ($new = comment_num_new($node->id())) {
$links['comment-new-comments'] = array(
'title' => format_plural($new, '1 new comment', '@count new comments'),
'href' => "node/$node->nid",
'href' => 'node/' . $node->id(),
'query' => comment_new_page_count($node->comment_count, $new, $node),
'attributes' => array('title' => t('Jump to the first new comment of this posting.')),
'fragment' => 'new',
......@@ -555,12 +555,12 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_
if (user_access('post comments')) {
$links['comment-add'] = array(
'title' => t('Add new comment'),
'href' => "node/$node->nid",
'href' => 'node/' . $node->id(),
'attributes' => array('title' => t('Add a new comment to this page.')),
'fragment' => 'comment-form',
);
if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) {
$links['comment-add']['href'] = "comment/reply/$node->nid";
$links['comment-add']['href'] = 'comment/reply/' . $node->id();
}
}
else {
......@@ -589,11 +589,11 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_
$links['comment-add'] = array(
'title' => t('Add new comment'),
'attributes' => array('title' => t('Share your thoughts and opinions related to this posting.')),
'href' => "node/$node->nid",
'href' => 'node/' . $node->id(),
'fragment' => 'comment-form',
);
if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) {
$links['comment-add']['href'] = "comment/reply/$node->nid";
$links['comment-add']['href'] = 'comment/reply/' . $node->id();
}
}
}
......@@ -684,7 +684,7 @@ function comment_node_page_additions(EntityInterface $node) {
* The renderable array for the comment addition form.
*/
function comment_add(EntityInterface $node, $pid = NULL) {
$values = array('nid' => $node->nid, 'pid' => $pid, 'node_type' => 'comment_node_' . $node->type);
$values = array('nid' => $node->id(), 'pid' => $pid, 'node_type' => 'comment_node_' . $node->type);
$comment = entity_create('comment', $values);
return Drupal::entityManager()->getForm($comment);
}
......@@ -761,7 +761,7 @@ function comment_get_thread(EntityInterface $node, $mode, $comments_per_page) {
->extend('Drupal\Core\Database\Query\PagerSelectExtender');
$query->addField('c', 'cid');
$query
->condition('c.nid', $node->nid)
->condition('c.nid', $node->id())
->addTag('node_access')
->addTag('comment_filter')
->addMetaData('base_table', 'comment')
......@@ -771,7 +771,7 @@ function comment_get_thread(EntityInterface $node, $mode, $comments_per_page) {
$count_query = db_select('comment', 'c');
$count_query->addExpression('COUNT(*)');
$count_query
->condition('c.nid', $node->nid)
->condition('c.nid', $node->id())
->addTag('node_access')
->addTag('comment_filter')
->addMetaData('base_table', 'comment')
......@@ -1071,7 +1071,7 @@ function comment_form_node_form_alter(&$form, $form_state) {
),
'#weight' => 30,
);
$comment_count = isset($node->nid) ? db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() : 0;
$comment_count = $node->id() ? db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array(':nid' => $node->id()))->fetchField() : 0;
$comment_settings = ($node->comment == COMMENT_NODE_HIDDEN && empty($comment_count)) ? COMMENT_NODE_CLOSED : $node->comment;
$form['comment_settings']['comment'] = array(
'#type' => 'radios',
......@@ -1114,7 +1114,7 @@ function comment_node_load($nodes, $types) {
foreach ($nodes as $node) {
// Store whether comments are enabled for this node.
if ($node->comment != COMMENT_NODE_HIDDEN) {
$comments_enabled[] = $node->nid;
$comments_enabled[] = $node->id();
}
else {
$node->cid = 0;
......@@ -1156,7 +1156,7 @@ function comment_node_insert(EntityInterface $node) {
if (variable_get('comment_maintain_node_statistics', TRUE)) {
db_insert('node_comment_statistics')
->fields(array(
'nid' => $node->nid,
'nid' => $node->id(),
'cid' => 0,