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();
}
......@@ -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,
'last_comment_timestamp' => $node->changed,
'last_comment_name' => NULL,
......@@ -1171,10 +1171,10 @@ function comment_node_insert(EntityInterface $node) {
* Implements hook_node_predelete().
*/
function comment_node_predelete(EntityInterface $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->id()))->fetchCol();
entity_delete_multiple('comment', $cids);
db_delete('node_comment_statistics')
->condition('nid', $node->nid)
->condition('nid', $node->id())
->execute();
}
......@@ -1237,7 +1237,7 @@ function comment_update_index() {
function comment_node_search_result(EntityInterface $node) {
// Do not make a string if comments are 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();
$comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->id()))->fetchField();
// Do not make a string if comments are closed and there are currently
// zero comments.
if ($node->comment != COMMENT_NODE_CLOSED || $comments > 0) {
......@@ -1652,10 +1652,10 @@ function theme_comment_post_forbidden($variables) {
// We cannot use drupal_get_destination() because these links
// sometimes appear on /node and taxonomy listing pages.
if (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_SEPARATE_PAGE) {
$destination = array('destination' => "comment/reply/$node->nid#comment-form");
$destination = array('destination' => 'comment/reply/' . $node->id() . '#comment-form');
}
else {
$destination = array('destination' => "node/$node->nid#comment-form");
$destination = array('destination' => 'node/' . $node->id() . '#comment-form');
}
if (config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
......
......@@ -37,7 +37,7 @@
*/
function comment_reply(EntityInterface $node, $pid = NULL) {
// Set the breadcrumb trail.
drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->label(), 'node/' . $node->nid)));
drupal_set_breadcrumb(array(l(t('Home'), NULL), l($node->label(), 'node/' . $node->id())));
$op = Drupal::request()->request->get('op');
$build = array();
......@@ -48,7 +48,7 @@ function comment_reply(EntityInterface $node, $pid = NULL) {
}
else {
drupal_set_message(t('You are not authorized to post comments.'), 'error');
return new RedirectResponse(url("node/$node->nid", array('absolute' => TRUE)));
return new RedirectResponse(url('node/' . $node->id(), array('absolute' => TRUE)));
}
}
else {
......@@ -60,22 +60,22 @@ function comment_reply(EntityInterface $node, $pid = NULL) {
if ($comment->status->value == COMMENT_PUBLISHED) {
// If that comment exists, make sure that the current comment and the
// parent comment both belong to the same parent node.
if ($comment->nid->target_id != $node->nid) {
if ($comment->nid->target_id != $node->id()) {
// Attempting to reply to a comment not belonging to the current nid.
drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
return new RedirectResponse(url("node/$node->nid", array('absolute' => TRUE)));
return new RedirectResponse(url('node/' . $node->id(), array('absolute' => TRUE)));
}
// Display the parent comment
$build['comment_parent'] = comment_view($comment);
}
else {
drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
return new RedirectResponse(url("node/$node->nid", array('absolute' => TRUE)));
return new RedirectResponse(url('node/' . $node->id(), array('absolute' => TRUE)));
}
}
else {
drupal_set_message(t('You are not authorized to view comments.'), 'error');
return new RedirectResponse(url("node/$node->nid", array('absolute' => TRUE)));
return new RedirectResponse(url('node/' . $node->id(), array('absolute' => TRUE)));
}
}
// This is the case where the comment is in response to a node. Display the node.
......@@ -86,14 +86,14 @@ function comment_reply(EntityInterface $node, $pid = NULL) {
// Should we show the reply box?
if ($node->comment != COMMENT_NODE_OPEN) {
drupal_set_message(t("This discussion is closed: you can't post new comments."), 'error');
return new RedirectResponse(url("node/$node->nid", array('absolute' => TRUE)));
return new RedirectResponse(url('node/' . $node->id(), array('absolute' => TRUE)));
}
elseif (user_access('post comments')) {
$build['comment_form'] = comment_add($node, $pid);
}
else {
drupal_set_message(t('You are not authorized to post comments.'), 'error');
return new RedirectResponse(url("node/$node->nid", array('absolute' => TRUE)));
return new RedirectResponse(url('node/' . $node->id(), array('absolute' => TRUE)));
}
}
......
......@@ -231,7 +231,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'comment-count-new':
$replacements[$original] = comment_num_new($node->nid);
$replacements[$original] = comment_num_new($node->id());
break;
}
}
......
......@@ -346,13 +346,13 @@ public function save(array $form, array &$form_state) {
$query['page'] = $page;
}
// Redirect to the newly posted comment.
$redirect = array('node/' . $node->nid, array('query' => $query, 'fragment' => 'comment-' . $comment->id()));
$redirect = array('node/' . $node->id(), array('query' => $query, 'fragment' => 'comment-' . $comment->id()));
}
else {
watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject->value), WATCHDOG_WARNING);
drupal_set_message(t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject->value)), 'error');
// Redirect the user to the node they are commenting on.
$redirect = 'node/' . $node->nid;
$redirect = 'node/' . $node->id();
}
$form_state['redirect'] = $redirect;
// Clear the block and page caches so that anonymous users see the comment
......
......@@ -123,7 +123,7 @@ public function commentPermalink(Request $request, CommentInterface $comment) {
// Find the current display page for this comment.
$page = comment_get_display_page($comment->id(), $node->type);
// @todo: Cleaner sub request handling.
$redirect_request = Request::create('/node/' . $node->nid, 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all());
$redirect_request = Request::create('/node/' . $node->id(), 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all());
$redirect_request->query->set('page', $page);
// @todo: Convert the pager to use the request object.
$request->query->set('page', $page);
......
......@@ -120,7 +120,7 @@ public function preRender(&$values) {
));
foreach ($result as $node) {
foreach ($ids[$node->nid] as $id) {
foreach ($ids[$node->id()] as $id) {
$values[$id]->{$this->field_alias} = $node->num_comments;
}
}
......@@ -134,7 +134,7 @@ function render_link($data, $values) {
'type' => $this->getValue($values, 'type'),
));
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'node/' . $node->nid;
$this->options['alter']['path'] = 'node/' . $node->id();
$this->options['alter']['query'] = comment_new_page_count($this->getValue($values, 'comment_count'), $this->getValue($values), $node);
$this->options['alter']['fragment'] = 'new';
}
......
......@@ -61,7 +61,7 @@ function testAnonymous() {
$this->drupalLogout();
// Post anonymous comment with contact info (optional).
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->drupalGet('comment/reply/' . $this->node->id());
$this->assertTrue($this->commentContactInfoAvailable(), 'Contact information available.');
$anonymous_comment2 = $this->postComment($this->node, $this->randomName(), $this->randomName());
......@@ -75,7 +75,7 @@ function testAnonymous() {
'subject' => $this->randomName(),
"comment_body[$langcode][0][value]" => $this->randomName(),
);
$this->drupalPost('comment/reply/' . $this->node->nid, $edit, t('Save'));
$this->drupalPost('comment/reply/' . $this->node->id(), $edit, t('Save'));
$this->assertText(t('The name you used belongs to a registered user.'));
// Require contact info.
......@@ -84,7 +84,7 @@ function testAnonymous() {
$this->drupalLogout();
// Try to post comment with contact info (required).
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->drupalGet('comment/reply/' . $this->node->id());
$this->assertTrue($this->commentContactInfoAvailable(), 'Contact information available.');
$anonymous_comment3 = $this->postComment($this->node, $this->randomName(), $this->randomName(), TRUE);
......@@ -133,12 +133,12 @@ function testAnonymous() {
// Attempt to view comments while disallowed.
// NOTE: if authenticated user has permission to post comments, then a
// "Login or register to post comments" type link may be shown.
$this->drupalGet('node/' . $this->node->nid);
$this->drupalGet('node/' . $this->node->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertNoLink('Add new comment', 'Link to add comment was found.');
// Attempt to view node-comment form while disallowed.
$this->drupalGet('comment/reply/' . $this->node->nid);
$this->drupalGet('comment/reply/' . $this->node->id());
$this->assertText('You are not authorized to post comments', 'Error attempting to post comment.');
$this->assertNoFieldByName('subject', '', 'Subject field not found.');
$this->assertNoFieldByName("comment_body[$langcode][0][value]", '', 'Comment field not found.');
......@@ -148,7 +148,7 @@ function testAnonymous() {
'post comments' => FALSE,
'skip comment approval' => FALSE,
));
$this->drupalGet('node/' . $this->node->nid);
$this->drupalGet('node/' . $this->node->id());
$this->assertPattern('@<h2[^>]*>Comments</h2>@', 'Comments were displayed.');
$this->assertLink('Log in', 1, 'Link to log in was found.');
$this->assertLink('register', 1, 'Link to register was found.');
......@@ -158,12 +158,12 @@ function testAnonymous() {
'post comments' => TRUE,
'skip comment approval' => TRUE,
));
$this->drupalGet('node/' . $this->node->nid);
$this->drupalGet('node/' . $this->node->id());
$this->assertNoPattern('@<h2[^>]*>Comments</h2>@', 'Comments were not displayed.');
$this->assertFieldByName('subject', '', 'Subject field found.');
$this->assertFieldByName("comment_body[$langcode][0][value]", '', 'Comment field found.');
$this->drupalGet('comment/reply/' . $this->node->nid . '/' . $anonymous_comment3->id());
$this->drupalGet('comment/reply/' . $this->node->id() . '/' . $anonymous_comment3->id());
$this->assertText('You are not authorized to view comments', 'Error attempting to post reply.');
$this->assertNoText($author_name, 'Comment not displayed.');
}
......
......@@ -47,7 +47,7 @@ function testApprovalAdminInterface() {
// Get unapproved comment id.
$this->drupalLogin($this->admin_user);
$anonymous_comment4 = $this->getUnapprovedComment($subject);
$anonymous_comment4 = entity_create('comment', array('cid' => $anonymous_comment4, 'node_type' => '', 'subject' => $subject, 'comment_body' => $body, 'nid' => $this->node->nid));
$anonymous_comment4 = entity_create('comment', array('cid' => $anonymous_comment4, 'node_type' => '', 'subject' => $subject, 'comment_body' => $body, 'nid' => $this->node->id()));
$this->drupalLogout();
$this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.');
......@@ -57,7 +57,7 @@ function testApprovalAdminInterface() {
$this->performCommentOperation($anonymous_comment4, 'publish', TRUE);
$this->drupalLogout();
$this->drupalGet('node/' . $this->node->nid);
$this->drupalGet('node/' . $this->node->id());
$this->assertTrue($this->commentExists($anonymous_comment4), 'Anonymous comment visible.');
// Post 2 anonymous comments without contact info.
......@@ -111,7 +111,7 @@ function testApprovalNodeInterface() {
// Get unapproved comment id.
$this->drupalLogin($this->admin_user);
$anonymous_comment4 = $this->getUnapprovedComment($subject);
$anonymous_comment4 = entity_create('comment', array('cid' => $anonymous_comment4, 'node_type' => '', 'subject' => $subject, 'comment_body' => $body, 'nid' => $this->node->nid));
$anonymous_comment4 = entity_create('comment', array('cid' => $anonymous_comment4, 'node_type' => '', 'subject' => $subject, 'comment_body' => $body, 'nid' => $this->node->id()));
$this->drupalLogout();
$this->assertFalse($this->commentExists($anonymous_comment4), 'Anonymous comment was not published.');
......@@ -122,11 +122,11 @@ function testApprovalNodeInterface() {
$this->assertResponse(403, 'Forged comment approval was denied.');
$this->drupalGet('comment/1/approve', array('query' => array('token' => 'forged')));
$this->assertResponse(403, 'Forged comment approval was denied.');
$this->drupalGet('node/' . $this->node->nid);
$this->drupalGet('node/' . $this->node->id());
$this->clickLink(t('approve'));
$this->drupalLogout();
$this->drupalGet('node/' . $this->node->nid);
$this->drupalGet('node/' . $this->node->id());
$this->assertTrue($this->commentExists($anonymous_comment4), 'Anonymous comment visible.');
}
}
......@@ -51,7 +51,7 @@ function testCommentClasses() {
// Add a comment.
$comment = entity_create('comment', array(
'nid' => $node->nid,
'nid' => $node->id(),
'node_type' => 'node_type_' . $node->bundle(),
'uid' => $case['comment_uid'],
'status' => $case['comment_status'],
......@@ -81,7 +81,7 @@ function testCommentClasses() {
break;
}
// Request the node with the comment.
$this->drupalGet('node/' . $node->nid);