diff --git a/core/includes/form.inc b/core/includes/form.inc index 4689711..6d836e2 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -4959,7 +4959,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()); * } * diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 3442c36..449ef4e 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1005,7 +1005,7 @@ function menu_item_route_access(Route $route, $href, &$map) { * "story" content type: * @code * $node = menu_get_object(); - * $story = $node->type == 'story'; + * $story = $node->bundle() == 'story'; * @endcode * * @param $type diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 846d28a..8427ce1 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2583,7 +2583,7 @@ function template_preprocess_html(&$variables) { // If on an individual node page, add the node type to body classes. if ($node = menu_get_object()) { - $variables['attributes']['class'][] = drupal_html_class('node-type-' . $node->type); + $variables['attributes']['class'][] = drupal_html_class('node-type-' . $node->bundle()); } // Initializes attributes which are specific to the html and body elements. diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index 076cfd3..234ac57 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -6,6 +6,7 @@ */ namespace Drupal\Core\Template; +use Drupal\Core\Entity\Field\Type\Field; /** @@ -102,6 +103,9 @@ public function offsetExists($name) { public function __toString() { $return = ''; foreach ($this->storage as $name => $value) { + if ($value instanceof Field) { + var_dump($value); + } if (!$value->printed()) { $rendered = is_object($value) ? $value->render() : (check_plain($name) . ' = "' . check_plain($value) . '"'); if ($rendered) { diff --git a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php index 8a86279..2ae5dea 100644 --- a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php +++ b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php @@ -64,14 +64,14 @@ public function testBulkForm() { foreach ($nodes as $node) { $changed_node = node_load($node->id()); - $this->assertTrue($changed_node->sticky, format_string('Node @nid got marked as sticky.', array('@nid' => $node->id()))); + $this->assertTrue($changed_node->isSticky(), format_string('Node @nid got marked as sticky.', array('@nid' => $node->id()))); } $this->assertText('Make content sticky was applied to 10 items.'); // Unpublish just one node. $node = node_load($nodes[0]->id()); - $this->assertTrue($node->status, 'The node is published.'); + $this->assertTrue($node->isPublished(), 'The node is published.'); $edit = array('action_bulk_form[0]' => TRUE, 'action' => 'node_unpublish_action'); $this->drupalPost(NULL, $edit, t('Apply')); @@ -80,11 +80,11 @@ public function testBulkForm() { // Load the node again. $node = node_load($node->id(), TRUE); - $this->assertFalse($node->status, 'A single node has been unpublished.'); + $this->assertFalse($node->isPublished(), 'A single node has been unpublished.'); // The second node should still be published. $node = node_load($nodes[1]->id(), TRUE); - $this->assertTrue($node->status, 'An unchecked node is still published.'); + $this->assertTrue($node->isPublished(), 'An unchecked node is still published.'); // Set up to include just the sticky actions. $view = views_get_view('test_bulk_form'); diff --git a/core/modules/book/book.admin.inc b/core/modules/book/book.admin.inc index 63118ab..611537b 100644 --- a/core/modules/book/book.admin.inc +++ b/core/modules/book/book.admin.inc @@ -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())); } } } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index d577bd3..81ba56a 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -120,13 +120,13 @@ function book_permission() { * @param $view_mode * The view mode of the node. */ -function book_node_view_link(EntityInterface $node, $view_mode) { +function book_node_view_link(NodeInterface $node, $view_mode) { $links = array(); if (isset($node->book['depth'])) { if ($view_mode == 'full' && node_is_page($node)) { $child_type = config('book.settings')->get('child_type'); - if ((user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && $node->book['depth'] < MENU_MAX_DEPTH) { + if ((user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->isPublished() && $node->book['depth'] < MENU_MAX_DEPTH) { $links['book_add_child'] = array( 'title' => t('Add child page'), 'href' => 'node/add/' . $child_type, @@ -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->bundle()))) { // 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->id() ? $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'])) { diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc index bc5ec53..4cd7e25 100644 --- a/core/modules/book/book.pages.inc +++ b/core/modules/book/book.pages.inc @@ -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(); } diff --git a/core/modules/book/lib/Drupal/book/Tests/BookTest.php b/core/modules/book/lib/Drupal/book/Tests/BookTest.php index b13a4e7..c1ed99d 100644 --- a/core/modules/book/lib/Drupal/book/Tests/BookTest.php +++ b/core/modules/book/lib/Drupal/book/Tests/BookTest.php @@ -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(' ' . $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(' ' . $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() . ' ', '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() . ' ', '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 '/