diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 915f809044756316afb4e546e728e5b3c4b6dd32..248659410e60336f94b11554fd41f1dcd37b99ee 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1008,7 +1008,7 @@ function menu_item_route_access(Route $route, $href, &$map) { * "story" content type: * @code * $node = menu_get_object(); - * $story = $node->type == 'story'; + * $story = $node->getType() == 'story'; * @endcode * * @param $type diff --git a/core/includes/theme.inc b/core/includes/theme.inc index d0161abdea1c77f583ff5a49e997626a957e0d7d..8cbdd1b1ddfc1c2a7019452a9950d46c16ccb735 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2534,7 +2534,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->getType()); } // Initializes attributes which are specific to the html and body elements. diff --git a/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php b/core/modules/action/lib/Drupal/action/Tests/BulkFormTest.php index 8a86279cddc7f7019e67e90dbbed9c4834534679..2ae5dea2412d5ba72ab0c0e306f8e1b16d5adfa6 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.module b/core/modules/book/book.module index ac26714b7465c669a9ec264cdf9ae59937f7babd..42499462b66d5938589cac7c32e14a316f8dbb45 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 = Drupal::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, @@ -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']) && !$node->isNew()) || book_type_is_allowed($node->type))) { + if (user_access('add content to books') && ((!empty($node->book['mlid']) && !$node->isNew()) || book_type_is_allowed($node->getType()))) { // Already in the book hierarchy, or this node type is allowed. $access = TRUE; } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index a68f39b39660b8fbb37c25bc328d626fa03a0d0e..1af78a5e75dfa77f709fcff7940b0294d49d4242 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -432,8 +432,8 @@ function comment_get_recent($number = 10) { * "page=X" if the page number is greater than zero; empty string otherwise. */ function comment_new_page_count($num_comments, $new_replies, EntityInterface $node) { - $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); - $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); + $mode = variable_get('comment_default_mode_' . $node->getType(), COMMENT_MODE_THREADED); + $comments_per_page = variable_get('comment_default_per_page_' . $node->getType(), 50); $pagenum = NULL; $flat = $mode == COMMENT_MODE_FLAT ? TRUE : FALSE; if ($num_comments <= $comments_per_page) { @@ -551,7 +551,7 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_ } } if ($node->comment == COMMENT_NODE_OPEN) { - $comment_form_location = variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW); + $comment_form_location = variable_get('comment_form_location_' . $node->getType(), COMMENT_FORM_BELOW); if (user_access('post comments')) { $links['comment-add'] = array( 'title' => t('Add new comment'), @@ -581,7 +581,7 @@ function comment_node_view(EntityInterface $node, EntityDisplay $display, $view_ // But we don't want this link if we're building the node for search // indexing or constructing a search result excerpt. if ($node->comment == COMMENT_NODE_OPEN) { - $comment_form_location = variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW); + $comment_form_location = variable_get('comment_form_location_' . $node->getType(), COMMENT_FORM_BELOW); if (user_access('post comments')) { // Show the "post comment" link if the form is on another page, or // if there are existing comments that the link will skip past. @@ -643,8 +643,8 @@ function comment_node_page_additions(EntityInterface $node) { // Unpublished comments are not included in $node->comment_count, so show // comments unconditionally if the user is an administrator. if (($node->comment_count && user_access('access comments')) || user_access('administer comments')) { - $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); - $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); + $mode = variable_get('comment_default_mode_' . $node->getType(), COMMENT_MODE_THREADED); + $comments_per_page = variable_get('comment_default_per_page_' . $node->getType(), 50); if ($cids = comment_get_thread($node, $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); comment_prepare_thread($comments); @@ -655,13 +655,13 @@ function comment_node_page_additions(EntityInterface $node) { } // Append comment form if needed. - if (user_access('post comments') && $node->comment == COMMENT_NODE_OPEN && (variable_get('comment_form_location_' . $node->type, COMMENT_FORM_BELOW) == COMMENT_FORM_BELOW)) { + if (user_access('post comments') && $node->comment == COMMENT_NODE_OPEN && (variable_get('comment_form_location_' . $node->getType(), COMMENT_FORM_BELOW) == COMMENT_FORM_BELOW)) { $additions['comment_form'] = comment_add($node); } if ($additions) { $additions += array( - '#theme' => 'comment_wrapper__node_' . $node->type, + '#theme' => 'comment_wrapper__node_' . $node->getType(), '#node' => $node, 'comments' => array(), 'comment_form' => array(), @@ -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->id(), 'pid' => $pid, 'node_type' => 'comment_node_' . $node->type); + $values = array('nid' => $node->id(), 'pid' => $pid, 'node_type' => 'comment_node_' . $node->getType()); $comment = entity_create('comment', $values); return Drupal::entityManager()->getForm($comment); } @@ -1118,9 +1118,9 @@ function comment_node_load($nodes, $types) { } else { $node->cid = 0; - $node->last_comment_timestamp = $node->created; + $node->last_comment_timestamp = $node->getCreatedTime(); $node->last_comment_name = ''; - $node->last_comment_uid = $node->uid; + $node->last_comment_uid = $node->getAuthorId(); $node->comment_count = 0; } } @@ -1143,7 +1143,7 @@ function comment_node_load($nodes, $types) { */ function comment_node_prepare_form(NodeInterface $node, $form_display, $operation, array &$form_state) { if (!isset($node->comment)) { - $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN); + $node->comment = variable_get('comment_' . $node->getType(), COMMENT_NODE_OPEN); } } @@ -1158,9 +1158,9 @@ function comment_node_insert(EntityInterface $node) { ->fields(array( 'nid' => $node->id(), 'cid' => 0, - 'last_comment_timestamp' => $node->changed, + 'last_comment_timestamp' => $node->getChangedTime(), 'last_comment_name' => NULL, - 'last_comment_uid' => $node->uid, + 'last_comment_uid' => $node->getAuthorId(), 'comment_count' => 0, )) ->execute(); @@ -1208,8 +1208,8 @@ function comment_node_update_index(EntityInterface $node, $langcode) { } if ($index_comments) { - $mode = variable_get('comment_default_mode_' . $node->type, COMMENT_MODE_THREADED); - $comments_per_page = variable_get('comment_default_per_page_' . $node->type, 50); + $mode = variable_get('comment_default_mode_' . $node->getType(), COMMENT_MODE_THREADED); + $comments_per_page = variable_get('comment_default_per_page_' . $node->getType(), 50); if ($node->comment && $cids = comment_get_thread($node, $mode, $comments_per_page)) { $comments = comment_load_multiple($cids); comment_prepare_thread($comments); @@ -1610,7 +1610,7 @@ function template_preprocess_comment(&$variables) { $variables['attributes']['class'][] = 'by-anonymous'; } else { - if ($comment->uid->target_id == $variables['node']->uid) { + if ($comment->uid->target_id == $variables['node']->getAuthorId()) { $variables['attributes']['class'][] = 'by-node-author'; } if ($comment->uid->target_id == $variables['user']->id()) { @@ -1651,7 +1651,7 @@ function theme_comment_post_forbidden($variables) { if ($authenticated_post_comments) { // 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) { + if (variable_get('comment_form_location_' . $node->getType(), COMMENT_FORM_BELOW) == COMMENT_FORM_SEPARATE_PAGE) { $destination = array('destination' => 'comment/reply/' . $node->id() . '#comment-form'); } else { @@ -1683,7 +1683,7 @@ function theme_comment_post_forbidden($variables) { function template_preprocess_comment_wrapper(&$variables) { // Provide contextual information. $variables['node'] = $variables['content']['#node']; - $variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->type, COMMENT_MODE_THREADED); + $variables['display_mode'] = variable_get('comment_default_mode_' . $variables['node']->getType(), COMMENT_MODE_THREADED); // The comment form is optional and may not exist. $variables['content'] += array('comment_form' => array()); diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index d5a4a508edf263ec15c76d27b28a09b014da0d97..3cef2ff757750882cba244883622aafad93db779 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -26,9 +26,9 @@ public function form(array $form, array &$form_state) { // Use #comment-form as unique jump target, regardless of node type. $form['#id'] = drupal_html_id('comment_form'); - $form['#theme'] = array('comment_form__node_' . $node->type, 'comment_form'); + $form['#theme'] = array('comment_form__node_' . $node->getType(), 'comment_form'); - $anonymous_contact = variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT); + $anonymous_contact = variable_get('comment_anonymous_' . $node->getType(), COMMENT_ANONYMOUS_MAYNOT_CONTACT); $is_admin = $comment->id() && user_access('administer comments'); if (!$user->isAuthenticated() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT) { @@ -145,7 +145,7 @@ public function form(array $form, array &$form_state) { '#title' => t('Subject'), '#maxlength' => 64, '#default_value' => $comment->subject->value, - '#access' => variable_get('comment_subject_field_' . $node->type, 1) == 1, + '#access' => variable_get('comment_subject_field_' . $node->getType(), 1) == 1, ); // Used for conditional validation of author fields. @@ -178,7 +178,7 @@ protected function actions(array $form, array &$form_state) { $element = parent::actions($form, $form_state); $comment = $this->entity; $node = $comment->nid->entity; - $preview_mode = variable_get('comment_preview_' . $node->type, DRUPAL_OPTIONAL); + $preview_mode = variable_get('comment_preview_' . $node->getType(), DRUPAL_OPTIONAL); // No delete action on the comment form. unset($element['delete']); @@ -341,7 +341,7 @@ public function save(array $form, array &$form_state) { } $query = array(); // Find the current display page for this comment. - $page = comment_get_display_page($comment->id(), $node->type); + $page = comment_get_display_page($comment->id(), $node->getType()); if ($page > 0) { $query['page'] = $page; } diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 84ef0c1a8fea3ed89c9091bc53f88a127d612000..6bd628e50123c6adc9ef1f1c444f7e92202c1e78 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -121,7 +121,7 @@ public function commentPermalink(Request $request, CommentInterface $comment) { throw new AccessDeniedHttpException(); } // Find the current display page for this comment. - $page = comment_get_display_page($comment->id(), $node->type); + $page = comment_get_display_page($comment->id(), $node->getType()); // @todo: Cleaner sub request handling. $redirect_request = Request::create('/node/' . $node->id(), 'GET', $request->query->all(), $request->cookies->all(), array(), $request->server->all()); $redirect_request->query->set('page', $page); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php index 5bad9ea4b43865b61c8dc4aa0c592d7292f6ad4b..2b711dda3a5fff6d2b850f449970838b23de9894 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Core/Entity/Comment.php @@ -217,7 +217,7 @@ public function id() { public static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) { if (empty($values['node_type']) && !empty($values['nid'])) { $node = node_load(is_object($values['nid']) ? $values['nid']->value : $values['nid']); - $values['node_type'] = 'comment_node_' . $node->type; + $values['node_type'] = 'comment_node_' . $node->getType(); } } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php index 5e40a7b62f14d466aea04422119b5c0a82fd4ed7..fd86097fba369c1272e886a7af983f2bb4233740 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php @@ -143,7 +143,7 @@ function setEnvironment(array $info) { $comment = entity_create('comment', array( 'cid' => NULL, 'nid' => $this->node->id(), - 'node_type' => $this->node->type, + 'node_type' => $this->node->getType(), 'pid' => 0, 'uid' => 0, 'status' => COMMENT_PUBLISHED, @@ -167,8 +167,8 @@ function setEnvironment(array $info) { } // Change comment settings. - variable_set('comment_form_location_' . $this->node->type, $info['form']); - variable_set('comment_anonymous_' . $this->node->type, $info['contact']); + variable_set('comment_form_location_' . $this->node->getType(), $info['form']); + variable_set('comment_anonymous_' . $this->node->getType(), $info['contact']); if ($this->node->comment != $info['comments']) { $this->node->comment = $info['comments']; $this->node->save(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php index 04fc481a8cdedc567907754a4466915e5f44d898..55deb614d72ce69552e7a4aae9179946339be6a5 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNewIndicatorTest.php @@ -49,7 +49,7 @@ public function testCommentNewCommentsIndicator() { $comment = entity_create('comment', array( 'cid' => NULL, 'nid' => $this->node->id(), - 'node_type' => $this->node->type, + 'node_type' => $this->node->getType(), 'pid' => 0, 'uid' => $this->loggedInUser->id(), 'status' => COMMENT_PUBLISHED, diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php index 2e6aab38c060a321aced6cb32b643e27bdc95f7b..e471421fd679773aa8808670d97a5acf086080ff 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentStatisticsTest.php @@ -49,7 +49,7 @@ function testCommentNodeCommentStatistics() { // Checks the initial values of node comment statistics with no comment. $node = node_load($this->node->id()); - $this->assertEqual($node->last_comment_timestamp, $this->node->created, 'The initial value of node last_comment_timestamp is the node created date.'); + $this->assertEqual($node->last_comment_timestamp, $this->node->getCreatedTime(), 'The initial value of node last_comment_timestamp is the node created date.'); $this->assertEqual($node->last_comment_name, NULL, 'The initial value of node last_comment_name is NULL.'); $this->assertEqual($node->last_comment_uid, $this->web_user->id(), 'The initial value of node last_comment_uid is the node uid.'); $this->assertEqual($node->comment_count, 0, 'The initial value of node comment_count is zero.'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php index 35724752a38c442f2cecac1ce9a56fe0920f98fb..1819b1039c4503f115312c9a8259b70a61bf8d24 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTokenReplaceTest.php @@ -67,7 +67,7 @@ function testCommentTokenReplacement() { $tests['[comment:parent:cid]'] = $comment->pid->target_id; $tests['[comment:parent:title]'] = check_plain($parent_comment->subject->value); $tests['[comment:node:nid]'] = $comment->nid->target_id; - $tests['[comment:node:title]'] = check_plain($node->title); + $tests['[comment:node:title]'] = check_plain($node->getTitle()); $tests['[comment:author:uid]'] = $comment->uid->target_id; $tests['[comment:author:name]'] = check_plain($this->admin_user->getUsername()); @@ -87,7 +87,7 @@ function testCommentTokenReplacement() { $tests['[comment:title]'] = $comment->subject->value; $tests['[comment:body]'] = $comment->comment_body->value; $tests['[comment:parent:title]'] = $parent_comment->subject->value; - $tests['[comment:node:title]'] = $node->title; + $tests['[comment:node:title]'] = $node->getTitle(); $tests['[comment:author:name]'] = $this->admin_user->getUsername(); foreach ($tests as $input => $expected) { diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php index 296a3e25c8ca2e497578cb83d816480f10a36766..5c256603b6e82b0cb89cd2bb2b84bfa9d4c2f6bb 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php @@ -77,7 +77,7 @@ protected function createEntity($values, $langcode, $node_bundle = NULL) { } $node = $this->drupalCreateNode(array('type' => $node_bundle)); $values['nid'] = $node->id(); - $values['uid'] = $node->uid; + $values['uid'] = $node->getAuthorId(); return parent::createEntity($values, $langcode); } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php index 138c5d02d7cad113e3e35754fa808be807537a7b..dabf53f0246a217fb22fc6d8533a22ed35b4607d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php @@ -41,7 +41,7 @@ function setUp() { $this->drupalLogin($this->account); $this->node_user_posted = $this->drupalCreateNode(); - $this->node_user_commented = $this->drupalCreateNode(array('uid' => $this->account2->uid)); + $this->node_user_commented = $this->drupalCreateNode(array('uid' => $this->account2->id())); $comment = array( 'uid' => $this->loggedInUser->id(), diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php index 6ffa95e461250e632550581528ccb6920fd80359..f4a4316719c359ae4bab9b943d9310c1d69de090 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php @@ -77,7 +77,7 @@ public function setUp() { // Create some comments and attach them to the created node. for ($i = 0; $i < $this->masterDisplayResults; $i++) { - $comment = entity_create('comment', array('node_type' => 'comment_node_' . $this->node->type)); + $comment = entity_create('comment', array('node_type' => 'comment_node_' . $this->node->getType())); $comment->uid->target_id = 0; $comment->nid->target_id = $this->node->id(); $comment->subject->value = 'Test comment ' . $i; diff --git a/core/modules/datetime/datetime.module b/core/modules/datetime/datetime.module index eafc616926d0f7293fdc0941bf23dd8cceaedc41..0da06cb4c8fa2cc9e6a5344d5101825094b835d2 100644 --- a/core/modules/datetime/datetime.module +++ b/core/modules/datetime/datetime.module @@ -1049,5 +1049,5 @@ function datetime_form_node_form_alter(&$form, &$form_state, $form_id) { */ function datetime_node_prepare_form(NodeInterface $node, $form_display, $operation, array &$form_state) { // Prepare the 'Authored on' date to use datetime. - $node->date = DrupalDateTime::createFromTimestamp($node->created); + $node->date = DrupalDateTime::createFromTimestamp($node->getCreatedTime()); } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php index cad4bd8e8d3606b6511c04749d69b3eef29303cc..c9b8d62e6a4139ca7d1392ef19ff8720cd35162e 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/Views/SelectionTest.php @@ -36,7 +36,7 @@ public function testSelectionHandler() { $nodes = array(); foreach (array($node1, $node2, $node3) as $node) { - $nodes[$node->type][$node->id()] = $node->label(); + $nodes[$node->getType()][$node->id()] = $node->label(); } // Create a field and instance. diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php index d9604cc84105900f2531430bdb813559873add73..a6225b501062f87c22722064ee61293c7e08b277 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldRevisionTest.php @@ -48,7 +48,7 @@ function testRevisions() { // Check that the file exists on disk and in the database. $node = node_load($nid, TRUE); $node_file_r1 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id']); - $node_vid_r1 = $node->vid; + $node_vid_r1 = $node->getRevisionId(); $this->assertFileExists($node_file_r1, 'New file saved to disk on node creation.'); $this->assertFileEntryExists($node_file_r1, 'File entry exists in database on node creation.'); $this->assertFileIsPermanent($node_file_r1, 'File is permanent.'); @@ -57,7 +57,7 @@ function testRevisions() { $this->replaceNodeFile($test_file, $field_name, $nid); $node = node_load($nid, TRUE); $node_file_r2 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id']); - $node_vid_r2 = $node->vid; + $node_vid_r2 = $node->getRevisionId(); $this->assertFileExists($node_file_r2, 'Replacement file exists on disk after creating new revision.'); $this->assertFileEntryExists($node_file_r2, 'Replacement file entry exists in database after creating new revision.'); $this->assertFileIsPermanent($node_file_r2, 'Replacement file is permanent.'); @@ -75,7 +75,7 @@ function testRevisions() { $this->drupalPost('node/' . $nid . '/edit', array('revision' => '1'), t('Save and keep published')); $node = node_load($nid, TRUE); $node_file_r3 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id']); - $node_vid_r3 = $node->vid; + $node_vid_r3 = $node->getRevisionId(); $this->assertEqual($node_file_r2->id(), $node_file_r3->id(), 'Previous revision file still in place after creating a new revision without a new file.'); $this->assertFileIsPermanent($node_file_r3, 'New revision file is permanent.'); @@ -83,7 +83,7 @@ function testRevisions() { $this->drupalPost('node/' . $nid . '/revisions/' . $node_vid_r1 . '/revert', array(), t('Revert')); $node = node_load($nid, TRUE); $node_file_r4 = file_load($node->{$field_name}[Language::LANGCODE_NOT_SPECIFIED][0]['target_id']); - $node_vid_r4 = $node->vid; + $node_vid_r4 = $node->getRevisionId(); $this->assertEqual($node_file_r1->id(), $node_file_r4->id(), 'Original revision file still in place after reverting to the original revision.'); $this->assertFileIsPermanent($node_file_r4, 'Original revision file still permanent after reverting to the original revision.'); diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php index 358289343ea39801e16798e08a55a45d097a095d..ba51a175d315d1a3dc047844ef6b810b95ced626 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldTestBase.php @@ -155,7 +155,7 @@ function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE, $node->setNewRevision(); $node->save(); $node = node_load($nid, TRUE); - $this->assertNotEqual($nid, $node->vid, 'Node revision exists.'); + $this->assertNotEqual($nid, $node->getRevisionId(), 'Node revision exists.'); } // Attach a file to the node. diff --git a/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php b/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php index e8a2f5da8e98ce0c877e3aac81d3d634bbe0ad53..693f23693176bdf20d0da19d7a10821babb189bb 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileListingTest.php @@ -75,14 +75,14 @@ function testFileListingPages() { } foreach ($nodes as &$node) { - $this->drupalGet('node/' . $node->nid . '/edit'); + $this->drupalGet('node/' . $node->id() . '/edit'); $file = $this->getTestFile('image'); $edit = array( 'files[file_' . Language::LANGCODE_NOT_SPECIFIED . '_' . 0 . ']' => drupal_realpath($file->getFileUri()), ); $this->drupalPost(NULL, $edit, t('Save')); - $node = entity_load('node', $node->nid)->getNGEntity(); + $node = entity_load('node', $node->id())->getNGEntity(); } $this->drupalGet('admin/content/files'); diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 46921af74dffc8ac580e428ea2bad14e8e5be201..886423644440da0277f82257e4e017db837a4b03 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -6,7 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; -use Drupal\entity\Plugin\Core\Entity\EntityDisplay; +use Drupal\node\NodeInterface; use Drupal\taxonomy\Plugin\Core\Entity\Term; /** @@ -264,7 +264,7 @@ function forum_uri($forum) { */ function _forum_node_check_node_type(EntityInterface $node) { // Fetch information about the forum field. - $instance = field_info_instance('node', 'taxonomy_forums', $node->type); + $instance = field_info_instance('node', 'taxonomy_forums', $node->getType()); return !empty($instance); } @@ -341,7 +341,7 @@ function forum_node_update(EntityInterface $node) { if (!empty($node->forum_tid)) { db_update('forum') ->fields(array('tid' => $node->forum_tid)) - ->condition('vid', $node->vid) + ->condition('vid', $node->getRevisionId()) ->execute(); } // The node is removed from the forum. @@ -356,7 +356,7 @@ function forum_node_update(EntityInterface $node) { db_insert('forum') ->fields(array( 'tid' => $node->forum_tid, - 'vid' => $node->vid, + 'vid' => $node->getRevisionId(), 'nid' => $node->id(), )) ->execute(); @@ -367,12 +367,12 @@ function forum_node_update(EntityInterface $node) { if (!empty($node->shadow)) { db_delete('forum') ->condition('nid', $node->id()) - ->condition('vid', $node->vid) + ->condition('vid', $node->getRevisionId()) ->execute(); db_insert('forum') ->fields(array( 'nid' => $node->id(), - 'vid' => $node->vid, + 'vid' => $node->getRevisionId(), 'tid' => $node->forum_tid, )) ->execute(); @@ -389,7 +389,7 @@ function forum_node_insert(EntityInterface $node) { $nid = db_insert('forum') ->fields(array( 'tid' => $node->forum_tid, - 'vid' => $node->vid, + 'vid' => $node->getRevisionId(), 'nid' => $node->id(), )) ->execute(); @@ -418,7 +418,7 @@ function forum_node_load($nodes) { $node_vids = array(); foreach ($nodes as $node) { if (_forum_node_check_node_type($node)) { - $node_vids[] = $node->vid; + $node_vids[] = $node->getRevisionId(); } } if (!empty($node_vids)) { @@ -501,18 +501,18 @@ function forum_comment_delete($comment) { * Implements hook_field_storage_pre_insert(). */ function forum_field_storage_pre_insert(EntityInterface $entity, &$skip_fields) { - if ($entity->entityType() == 'node' && $entity->status && _forum_node_check_node_type($entity)) { + if ($entity->entityType() == 'node' && $entity->isPublished() && _forum_node_check_node_type($entity)) { $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); foreach ($entity->getTranslationLanguages() as $langcode => $language) { $translation = $entity->getTranslation($langcode); $query->values(array( 'nid' => $entity->id(), - 'title' => $translation->title->value, + 'title' => $translation->label(), 'tid' => $translation->taxonomy_forums->target_id, - 'sticky' => $entity->sticky, - 'created' => $entity->created, + 'sticky' => (int) $entity->isSticky(), + 'created' => $entity->getCreatedTime(), 'comment_count' => 0, - 'last_comment_timestamp' => $entity->created, + 'last_comment_timestamp' => $entity->getCreatedTime(), )); } $query->execute(); @@ -528,26 +528,27 @@ function forum_field_storage_pre_update(EntityInterface $entity, &$skip_fields) if ($entity->entityType() == 'node' && _forum_node_check_node_type($entity)) { // If the node is published, update the forum index. - if ($entity->status) { + if ($entity->isPublished()) { // We don't maintain data for old revisions, so clear all previous values // from the table. Since this hook runs once per field, per object, make // sure we only wipe values once. - if (!isset($first_call[$entity->nid])) { - $first_call[$entity->nid] = FALSE; + if (!isset($first_call[$entity->id()])) { + $first_call[$entity->id()] = FALSE; db_delete('forum_index')->condition('nid', $entity->id())->execute(); } $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); - foreach ($entity->taxonomy_forums as $language) { - foreach ($language as $item) { + foreach ($entity->getTranslationLanguages() as $langcode => $language) { + $translation = $entity->getTranslation($langcode); + foreach ($translation->taxonomy_forums as $item) { $query->values(array( - 'nid' => $entity->nid, - 'title' => $entity->title, - 'tid' => $item['target_id'], - 'sticky' => $entity->sticky, - 'created' => $entity->created, + 'nid' => $entity->id(), + 'title' => $translation->label(), + 'tid' => $item->target_id, + 'sticky' => (int) $entity->isSticky(), + 'created' => $entity->getCreatedTime(), 'comment_count' => 0, - 'last_comment_timestamp' => $entity->created, + 'last_comment_timestamp' => $entity->getCreatedTime(), )); } } @@ -1109,7 +1110,7 @@ function template_preprocess_forum_topic_list(&$variables) { '#new_posts' => $topic->new, '#num_posts' => $topic->comment_count, '#comment_mode' => $topic->comment_mode, - '#sticky' => $topic->sticky, + '#sticky' => $topic->isSticky(), '#first_new' => $topic->first_new, ); $variables['topics'][$id]->zebra = $row % 2 == 0 ? 'odd' : 'even'; @@ -1120,12 +1121,12 @@ function template_preprocess_forum_topic_list(&$variables) { // them is a shadow copy. if ($variables['tid'] != $topic->forum_tid) { $variables['topics'][$id]->moved = TRUE; - $variables['topics'][$id]->title = check_plain($topic->title); + $variables['topics'][$id]->title = check_plain($topic->getTitle()); $variables['topics'][$id]->message = l(t('This topic has been moved'), "forum/$topic->forum_tid"); } else { $variables['topics'][$id]->moved = FALSE; - $variables['topics'][$id]->title = l($topic->title, 'node/' . $topic->id()); + $variables['topics'][$id]->title = l($topic->getTitle(), 'node/' . $topic->id()); $variables['topics'][$id]->message = ''; } $forum_submitted = array('#theme' => 'forum_submitted', '#topic' => $topic); diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php index 1491ce2c0bd024c166582718007df0a8ee7dc706..dde4701e668564a51d162fa67a8be0245920ee16 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumNodeAccessTest.php @@ -82,16 +82,16 @@ function testForumNodeAccess() { $this->drupalGet(''); // Ensure private node and public node are found. - $this->assertText($private_node->title, 'Private node found in block by $access_user'); - $this->assertText($public_node->title, 'Public node found in block by $access_user'); + $this->assertText($private_node->getTitle(), 'Private node found in block by $access_user'); + $this->assertText($public_node->getTitle(), 'Public node found in block by $access_user'); // Test for $no_access_user. $this->drupalLogin($no_access_user); $this->drupalGet(''); // Ensure private node is not found but public is found. - $this->assertNoText($private_node->title, 'Private node not found in block by $no_access_user'); - $this->assertText($public_node->title, 'Public node found in block by $no_access_user'); + $this->assertNoText($private_node->getTitle(), 'Private node not found in block by $no_access_user'); + $this->assertText($public_node->getTitle(), 'Public node found in block by $no_access_user'); } } diff --git a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php index d09baf5dd65316178cc60cbe28de0ed30d03c502..c6f25332a9d397f96ffdd5bbe32ee2f2804cb7cf 100644 --- a/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php +++ b/core/modules/forum/lib/Drupal/forum/Tests/ForumTest.php @@ -607,7 +607,7 @@ private function verifyForums($node_user, EntityInterface $node, $admin, $respon // Verify topic was moved to a different forum. $forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array( ':nid' => $node->id(), - ':vid' => $node->vid, + ':vid' => $node->getRevisionId(), ))->fetchField(); $this->assertTrue($forum_tid == $this->root_forum['tid'], 'The forum topic is linked to a different forum'); diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php index 8ec672783542ead5174bcc13418e0b811f76b733..27e67efd3d72f6b7839a82deb27beea1908bd701 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDisplayTest.php @@ -72,7 +72,7 @@ function _testImageFieldFormatters($scheme) { 'type' => 'image', 'settings' => array('image_link' => 'file'), ); - $display = entity_get_display('node', $node->type, 'default'); + $display = entity_get_display('node', $node->getType(), 'default'); $display->setComponent($field_name, $display_options) ->save(); diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 01c9a4f38b2926bdcbfe910665e10ab4461df164..c4ff11f78ed436ac55a42b95c79bdc544cf76500 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -869,15 +869,15 @@ function locale_system_file_system_settings_submit(&$form, $form_state) { * Implements hook_preprocess_HOOK() for node.html.twig. */ function locale_preprocess_node(&$variables) { - if ($variables['node']->langcode != Language::LANGCODE_NOT_SPECIFIED) { + if ($variables['node']->language()->id != Language::LANGCODE_NOT_SPECIFIED) { $language_interface = language(Language::TYPE_INTERFACE); - $node_language = language_load($variables['node']->langcode); + $node_language = $variables['node']->language(); if ($node_language->id != $language_interface->id) { // If the node language was different from the page language, we should // add markup to identify the language. Otherwise the page language is // inherited. - $variables['attributes']['lang'] = $variables['node']->langcode; + $variables['attributes']['lang'] = $node_language->id; if ($node_language->direction != $language_interface->direction) { // If text direction is different form the page's text direction, add // direction information as well. diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module index 5d833821cc0c5ef1d26b930f9a4f8cc6f0120726..a9a50a260e8f07267f2d3984f1d1c5ae64888aee 100644 --- a/core/modules/menu/menu.module +++ b/core/modules/menu/menu.module @@ -457,12 +457,12 @@ function menu_node_predelete(EntityInterface $node) { function menu_node_prepare_form(NodeInterface $node, $form_display, $operation, array &$form_state) { if (empty($node->menu)) { // Prepare the node for the edit form so that $node->menu always exists. - $menu_name = strtok(variable_get('menu_parent_' . $node->type, 'main:0'), ':'); + $menu_name = strtok(variable_get('menu_parent_' . $node->getType(), 'main:0'), ':'); $menu_link = FALSE; if ($node->id()) { $mlid = FALSE; // Give priority to the default menu - $type_menus = variable_get('menu_options_' . $node->type, array('main' => 'main')); + $type_menus = variable_get('menu_options_' . $node->getType(), array('main' => 'main')); if (in_array($menu_name, $type_menus)) { $query = Drupal::entityQuery('menu_link') ->condition('link_path', 'node/' . $node->id()) @@ -526,7 +526,7 @@ function menu_form_node_form_alter(&$form, $form_state) { // @todo This must be handled in a #process handler. $node = $form_state['controller']->getEntity(); $link = $node->menu; - $type = $node->type; + $type = $node->getType(); $options = menu_parent_options(menu_get_menus(), $link, $type); // If no possible parent menu items were found, there is nothing to display. if (empty($options)) { diff --git a/core/modules/node/lib/Drupal/node/NodeAccessController.php b/core/modules/node/lib/Drupal/node/NodeAccessController.php index 2556d7673769228b3ad35cf4c7a094eb0f8b2001..3e4d97b8aa96de7ab67efdbdd43b1809764e6b49 100644 --- a/core/modules/node/lib/Drupal/node/NodeAccessController.php +++ b/core/modules/node/lib/Drupal/node/NodeAccessController.php @@ -100,13 +100,8 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = */ protected function checkAccess(EntityInterface $node, $operation, $langcode, AccountInterface $account) { // Fetch information from the node object if possible. - $status = isset($node->status) ? $node->status : NULL; - $uid = isset($node->uid) ? $node->uid : NULL; - // If it is a proper EntityNG object, use the proper methods. - if ($node instanceof EntityNG) { - $status = $node->getTranslation($langcode)->status->value; - $uid = $node->getTranslation($langcode)->uid->value; - } + $status = $node->getTranslation($langcode)->isPublished(); + $uid = $node->getTranslation($langcode)->getAuthorId(); // Check if authors can view their own unpublished nodes. if ($operation === 'view' && !$status && user_access('view own unpublished content', $account)) { diff --git a/core/modules/node/lib/Drupal/node/NodeBCDecorator.php b/core/modules/node/lib/Drupal/node/NodeBCDecorator.php index 77694fc8cb0ea7b553e77a01fce0c7ce8df8df8c..b65bc4e1503850d1d3ba7eafe7ae0c0f8932ea2f 100644 --- a/core/modules/node/lib/Drupal/node/NodeBCDecorator.php +++ b/core/modules/node/lib/Drupal/node/NodeBCDecorator.php @@ -14,11 +14,24 @@ */ class NodeBCDecorator extends EntityBCDecorator implements NodeInterface { + /** + * {@inheritdoc} + */ + public function getType() { + return $this->decorated->getType(); + } + /** * {@inheritdoc} */ public function setTitle($title) { - $this->decorated->setTitle($title); + return $this->decorated->setTitle($title); + } + /** + * {@inheritdoc} + */ + public function getTitle() { + return $this->decorated->getTitle(); } /** diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index ccc1dccc86009e6e29af84e0316f6fe44f22442c..045f1d97a8c0612cefdc9e09131b03768ca5c0ff 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -47,11 +47,11 @@ protected function prepareEntity() { } } global $user; - $node->uid = $user->id(); - $node->created = REQUEST_TIME; + $node->setAuthorId($user->id()); + $node->setCreatedTime(REQUEST_TIME); } else { - $node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O'); + $node->date = format_date($node->getCreatedTime(), 'custom', 'Y-m-d H:i:s O'); // Remove the log message from the original node entity. $node->log = NULL; } @@ -82,7 +82,7 @@ public function form(array $form, array &$form_state) { // Override the default CSS class name, since the user-defined node type // name in 'TYPE-node-form' potentially clashes with third-party class // names. - $form['#attributes']['class'][0] = drupal_html_class('node-' . $node->type . '-form'); + $form['#attributes']['class'][0] = drupal_html_class('node-' . $node->getType() . '-form'); // Basic node information. // These elements are just values so they are not even sent to the client. @@ -96,10 +96,10 @@ public function form(array $form, array &$form_state) { // Changed must be sent to the client, for later overwrite error checking. $form['changed'] = array( '#type' => 'hidden', - '#default_value' => isset($node->changed) ? $node->changed : NULL, + '#default_value' => $node->getChangedTime(), ); - $node_type = node_type_load($node->type); + $node_type = node_type_load($node->getType()); if ($node_type->has_title) { $form['title'] = array( '#type' => 'textfield', @@ -111,11 +111,11 @@ public function form(array $form, array &$form_state) { ); } - $language_configuration = module_invoke('language', 'get_default_configuration', 'node', $node->type); + $language_configuration = module_invoke('language', 'get_default_configuration', 'node', $node->getType()); $form['langcode'] = array( '#title' => t('Language'), '#type' => 'language_select', - '#default_value' => $node->langcode, + '#default_value' => $node->getUntranslated()->language()->id, '#languages' => Language::STATE_ALL, '#access' => isset($language_configuration['language_show']) && $language_configuration['language_show'], ); @@ -199,7 +199,7 @@ public function form(array $form, array &$form_state) { '#type' => 'textfield', '#title' => t('Authored on'), '#maxlength' => 25, - '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? date_format(date_create($node->date), 'Y-m-d H:i:s O') : format_date($node->created, 'custom', 'Y-m-d H:i:s O'), '%timezone' => !empty($node->date) ? date_format(date_create($node->date), 'O') : format_date($node->created, 'custom', 'O'))), + '#description' => t('Format: %time. The date format is YYYY-MM-DD and %timezone is the time zone offset from UTC. Leave blank to use the time of form submission.', array('%time' => !empty($node->date) ? date_format(date_create($node->date), 'Y-m-d H:i:s O') : format_date($node->getCreatedTime(), 'custom', 'Y-m-d H:i:s O'), '%timezone' => !empty($node->date) ? date_format(date_create($node->date), 'O') : format_date($node->getCreatedTime(), 'custom', 'O'))), '#default_value' => !empty($node->date) ? $node->date : '', ); @@ -222,13 +222,13 @@ public function form(array $form, array &$form_state) { $form['options']['promote'] = array( '#type' => 'checkbox', '#title' => t('Promoted to front page'), - '#default_value' => $node->promote, + '#default_value' => $node->isPromoted(), ); $form['options']['sticky'] = array( '#type' => 'checkbox', '#title' => t('Sticky at top of lists'), - '#default_value' => $node->sticky, + '#default_value' => $node->isSticky(), ); // This form uses a button-level #submit handler for the form's main submit @@ -271,7 +271,7 @@ protected function actions(array $form, array &$form_state) { $element['publish']['#value'] = t('Save and publish'); } else { - $element['publish']['#value'] = $node->status ? t('Save and keep published') : t('Save and publish'); + $element['publish']['#value'] = $node->isPublished() ? t('Save and keep published') : t('Save and publish'); } $element['publish']['#weight'] = 0; array_unshift($element['publish']['#submit'], array($this, 'publish')); @@ -283,13 +283,13 @@ protected function actions(array $form, array &$form_state) { $element['unpublish']['#value'] = t('Save as unpublished'); } else { - $element['unpublish']['#value'] = !$node->status ? t('Save and keep unpublished') : t('Save and unpublish'); + $element['unpublish']['#value'] = !$node->isPublished() ? t('Save and keep unpublished') : t('Save and unpublish'); } $element['unpublish']['#weight'] = 10; array_unshift($element['unpublish']['#submit'], array($this, 'unpublish')); // If already published, the 'publish' button is primary. - if ($node->status) { + if ($node->isPublished()) { unset($element['unpublish']['#button_type']); } // Otherwise, the 'unpublish' button is primary and should come first. @@ -327,7 +327,7 @@ protected function actions(array $form, array &$form_state) { public function validate(array $form, array &$form_state) { $node = $this->buildEntity($form, $form_state); - if ($node->id() && (node_last_changed($node->id(), $this->getFormLangcode($form_state)) > $node->changed)) { + if ($node->id() && (node_last_changed($node->id(), $this->getFormLangcode($form_state)) > $node->getChangedTime())) { form_set_error('changed', t('The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.')); } @@ -411,7 +411,7 @@ public function preview(array $form, array &$form_state) { */ public function publish(array $form, array &$form_state) { $node = $this->entity; - $node->status = 1; + $node->setPublished(TRUE); return $node; } @@ -425,7 +425,7 @@ public function publish(array $form, array &$form_state) { */ public function unpublish(array $form, array &$form_state) { $node = $this->entity; - $node->status = 0; + $node->setPublished(FALSE); return $node; } @@ -437,7 +437,7 @@ public function save(array $form, array &$form_state) { $insert = $node->isNew(); $node->save(); $node_link = l(t('view'), 'node/' . $node->id()); - $watchdog_args = array('@type' => $node->type, '%title' => $node->label()); + $watchdog_args = array('@type' => $node->getType(), '%title' => $node->label()); $t_args = array('@type' => node_get_type_label($node), '%title' => $node->label()); if ($insert) { diff --git a/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php b/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php index 9688390dd200e86829e07a1a5bf1400ab885937e..e7da48c9ff0d5682afd4a181708992c00c9bb601 100644 --- a/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php +++ b/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php @@ -71,7 +71,7 @@ public function access(EntityInterface $node, $operation, $langcode, AccountInte ->condition('langcode', $langcode); // If the node is published, also take the default grant into account. The // default is saved with a node ID of 0. - $status = $node instanceof EntityNG ? $node->status : $node->get('status', $langcode)->value; + $status = $node->isPublished(); if ($status) { $nids = $query->orConditionGroup() ->condition($nids) diff --git a/core/modules/node/lib/Drupal/node/NodeInterface.php b/core/modules/node/lib/Drupal/node/NodeInterface.php index 61e60a5f33817a8f99c7232eb09a2dc4c9985ab8..a9acd3470f48e0a237beaa411867783666b20ad4 100644 --- a/core/modules/node/lib/Drupal/node/NodeInterface.php +++ b/core/modules/node/lib/Drupal/node/NodeInterface.php @@ -15,6 +15,23 @@ */ interface NodeInterface extends ContentEntityInterface { + /** + * Returns the node type. + * + * @return string + * The node type. + */ + public function getType(); + + /** + * + * Returns the node title. + * + * @return string + * Title of the node. + */ + public function getTitle(); + /** * Sets the node title. * diff --git a/core/modules/node/lib/Drupal/node/NodeRenderController.php b/core/modules/node/lib/Drupal/node/NodeRenderController.php index 1b234f738e475c4a1a71939195f98a31da73e776..c5712923eb04c29b839e0732048b1fc19060942d 100644 --- a/core/modules/node/lib/Drupal/node/NodeRenderController.php +++ b/core/modules/node/lib/Drupal/node/NodeRenderController.php @@ -49,7 +49,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang 'title' => t('Read more<span class="visually-hidden"> about @title</span>', array( '@title' => $node_title_stripped, )), - 'href' => 'node/' . $entity->nid, + 'href' => 'node/' . $entity->id(), 'html' => TRUE, 'attributes' => array( 'rel' => 'tag', diff --git a/core/modules/node/lib/Drupal/node/NodeTranslationController.php b/core/modules/node/lib/Drupal/node/NodeTranslationController.php index 4df39461f3b377bb3c17f598d952a1bd426539ed..9436996841ea0e54e8a272f64736380a9a4008c8 100644 --- a/core/modules/node/lib/Drupal/node/NodeTranslationController.php +++ b/core/modules/node/lib/Drupal/node/NodeTranslationController.php @@ -54,7 +54,7 @@ public function entityFormEntityBuild($entity_type, EntityInterface $entity, arr if (isset($form_state['values']['content_translation'])) { $form_controller = content_translation_form_controller($form_state); $translation = &$form_state['values']['content_translation']; - $translation['status'] = $form_controller->getEntity()->status; + $translation['status'] = $form_controller->getEntity()->isPublished(); $translation['name'] = $form_state['values']['name']; $translation['created'] = $form_state['values']['date']; } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Action/DemoteNode.php b/core/modules/node/lib/Drupal/node/Plugin/Action/DemoteNode.php index 7676a765790fcb4f5ddb3b1549532de3e394f1c6..8adbdb1c5f81f7469ee60038c6120469302d062c 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Action/DemoteNode.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Action/DemoteNode.php @@ -26,7 +26,7 @@ class DemoteNode extends ActionBase { * {@inheritdoc} */ public function execute($entity = NULL) { - $entity->promote = NODE_NOT_PROMOTED; + $entity->setPromoted(FALSE); $entity->save(); } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Action/PromoteNode.php b/core/modules/node/lib/Drupal/node/Plugin/Action/PromoteNode.php index 56f86584c0fb44859483b03ed2df66b3b5a1fa15..0b87b382bcc488dfcb270411687e2c2fdadcb314 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Action/PromoteNode.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Action/PromoteNode.php @@ -26,8 +26,8 @@ class PromoteNode extends ActionBase { * {@inheritdoc} */ public function execute($entity = NULL) { - $entity->status = NODE_PUBLISHED; - $entity->promote = NODE_PROMOTED; + $entity->setPublished(TRUE); + $entity->setPromoted(TRUE); $entity->save(); } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Action/UnpublishByKeywordNode.php b/core/modules/node/lib/Drupal/node/Plugin/Action/UnpublishByKeywordNode.php index 2ad65f815af12bbe6c24e90c78a635b92ea48752..a52580295539e24793f3c2bcd6c42a2e5b8c266d 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Action/UnpublishByKeywordNode.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Action/UnpublishByKeywordNode.php @@ -29,7 +29,7 @@ public function execute($node = NULL) { foreach ($this->configuration['keywords'] as $keyword) { $elements = node_view(clone $node); if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($node->label(), $keyword) !== FALSE) { - $node->status = NODE_NOT_PUBLISHED; + $node->setPublished(FALSE); $node->save(); break; } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Condition/NodeType.php b/core/modules/node/lib/Drupal/node/Plugin/Condition/NodeType.php index 4f30bb78c25136aa6ca2349d5804d0a72f8fc363..bf71eb28c191366781760309a5d52ae0c7e3911c 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Condition/NodeType.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Condition/NodeType.php @@ -85,7 +85,7 @@ public function summary() { */ public function evaluate() { $node = $this->getContextValue('node'); - return in_array($node->type, $this->configuration['bundles']); + return in_array($node->getType(), $this->configuration['bundles']); } } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php index 54ae77febe46dc8822abbc413088cc0f9b79f933..a79c796d7a2885a2fd085fa6ee07d9f5f2b1caff 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php @@ -142,6 +142,20 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr } } + /** + * {@inheritdoc} + */ + public function getType() { + return $this->bundle(); + } + + /** + * {@inheritdoc} + */ + public function getTitle() { + return $this->get('title')->value; + } + /** * {@inheritdoc} */ @@ -184,7 +198,7 @@ public function isPromoted() { * {@inheritdoc} */ public function setPromoted($promoted) { - $this->set('promoted', $promoted ? NODE_PROMOTED : NODE_NOT_PROMOTED); + $this->set('promote', $promoted ? NODE_PROMOTED : NODE_NOT_PROMOTED); return $this; } @@ -221,12 +235,7 @@ public function setPublished($published) { * {@inheritdoc} */ public function getAuthor() { - $entity = $this->get('uid')->entity; - // If no user is given, default to the anonymous user. - if (!$entity) { - return user_load(0); - } - return $entity; + return $this->get('uid')->entity; } /** diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php b/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php index 36f3ab02e23f8689a7fdfb86b84eff41df7633ac..ac76687ef2a3fe9eaeb74345ab5f01ef5d72abb1 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/argument_validator/Node.php @@ -106,7 +106,7 @@ public function validateArgument($argument) { return TRUE; } - return isset($types[$node->type]); + return isset($types[$node->getType()]); case 'nids': $nids = new stdClass(); @@ -121,7 +121,7 @@ public function validateArgument($argument) { $nodes = node_load_multiple($nids->value); foreach ($nodes as $node) { - if ($types && empty($types[$node->type])) { + if ($types && empty($types[$node->getType()])) { return FALSE; } diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkEdit.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkEdit.php index 63c07fba8a02af30796fee9dedbc12be59f425d2..fdf933e087049c9d54f4b6df27249aa10c1fe295 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkEdit.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkEdit.php @@ -30,7 +30,7 @@ protected function renderLink($node, ResultRow $values) { } $this->options['alter']['make_link'] = TRUE; - $this->options['alter']['path'] = "node/$node->nid/edit"; + $this->options['alter']['path'] = "node/" . $node->id() . "/edit"; $this->options['alter']['query'] = drupal_get_destination(); $text = !empty($this->options['text']) ? $this->options['text'] : t('edit'); diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLink.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLink.php index 6b43b8105f749c5201f95ff8e3e1051e8f3715c5..8b3d3d77241381615c811575e4f67ab87787f991 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLink.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLink.php @@ -70,7 +70,7 @@ function get_revision_entity($values, $op) { $vid = $this->getValue($values, 'node_vid'); $node = $this->getEntity($values); // Unpublished nodes ignore access control. - $node->status = 1; + $node->setPublished(TRUE); // Ensure user has access to perform the operation on this node. if (!node_access($op, $node)) { return array($node, NULL); diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/row/Rss.php b/core/modules/node/lib/Drupal/node/Plugin/views/row/Rss.php index 89c7940f6c50db198cc3cfabfa19e6fa50ca0345..9d73565c8f31e8529cef26f1deb34b77ddf28e88 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/row/Rss.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/row/Rss.php @@ -117,7 +117,7 @@ public function render($row) { $node->rss_elements = array( array( 'key' => 'pubDate', - 'value' => gmdate('r', $node->created), + 'value' => gmdate('r', $node->getCreatedTime()), ), array( 'key' => 'dc:creator', diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php index 54ba0857ad1c697f10fe1f85f49ca16b72af079f..6facbdb93092442fdbc38b061d9157b03fa94dc4 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php @@ -47,6 +47,10 @@ function setUp() { 'id' => 'ca', )); language_save($language); + $language = new Language(array( + 'id' => 'hr', + )); + language_save($language); } /** @@ -61,7 +65,7 @@ function testNodeAccess() { // Creating a public node with langcode Hungarian, will be saved as the // fallback in node access table. $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE)); - $this->assertTrue($node_public->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public->language()->id == 'hu', 'Node created as Hungarian.'); // Tests the default access is provided for the public Hungarian node. $this->assertNodeAccess($expected_node_access, $node_public, $web_user); @@ -78,7 +82,7 @@ function testNodeAccess() { // Creating a public node with no special langcode, like when no language // module enabled. $node_public_no_language = $this->drupalCreateNode(array('private' => FALSE)); - $this->assertTrue($node_public_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_public_no_language->language()->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Tests that access is granted if requested with no language. $this->assertNodeAccess($expected_node_access, $node_public_no_language, $web_user); @@ -113,14 +117,14 @@ function testNodeAccessPrivate() { $web_user = $this->drupalCreateUser(array('access content')); $node = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu')); - $this->assertTrue($node->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node->language()->id == 'hu', 'Node created as Hungarian.'); $expected_node_access = array('view' => TRUE, 'update' => FALSE, 'delete' => FALSE); $expected_node_access_no_access = array('view' => FALSE, 'update' => FALSE, 'delete' => FALSE); // Creating a private node with langcode Hungarian, will be saved as the // fallback in node access table. $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE)); - $this->assertTrue($node_public->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public->language()->id == 'hu', 'Node created as Hungarian.'); // Tests the default access is not provided for the private Hungarian node. $this->assertNodeAccess($expected_node_access_no_access, $node_public, $web_user); @@ -137,7 +141,7 @@ function testNodeAccessPrivate() { // Creating a private node with no special langcode, like when no language // module enabled. $node_private_no_language = $this->drupalCreateNode(array('private' => TRUE)); - $this->assertTrue($node_private_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_private_no_language->language()->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Tests that access is not granted if requested with no language. $this->assertNodeAccess($expected_node_access_no_access, $node_private_no_language, $web_user); @@ -179,17 +183,17 @@ function testNodeAccessQueryTag() { // Creating a private node with langcode Hungarian, will be saved as // the fallback in node access table. $node_private = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => TRUE)); - $this->assertTrue($node_private->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_private->language()->id == 'hu', 'Node created as Hungarian.'); // Creating a public node with langcode Hungarian, will be saved as // the fallback in node access table. $node_public = $this->drupalCreateNode(array('body' => array(array()), 'langcode' => 'hu', 'private' => FALSE)); - $this->assertTrue($node_public->langcode == 'hu', 'Node created as Hungarian.'); + $this->assertTrue($node_public->language()->id == 'hu', 'Node created as Hungarian.'); // Creating a public node with no special langcode, like when no language // module enabled. $node_no_language = $this->drupalCreateNode(array('private' => FALSE)); - $this->assertTrue($node_no_language->langcode == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); + $this->assertTrue($node_no_language->language()->id == Language::LANGCODE_NOT_SPECIFIED, 'Node created with not specified language.'); // Query the nodes table as the web user with the node access tag and no // specific langcode. diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index f652895e7999aa269f69d745edd834539a2b9910..a63bcf8e2c6068c3c07df146e8f6c1642431920a 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -76,13 +76,13 @@ public function testRecentNodeBlock() { // Change the changed time for node so that we can test ordering. db_update('node_field_data') ->fields(array( - 'changed' => $node1->changed + 100, + 'changed' => $node1->getChangedTime() + 100, )) ->condition('nid', $node2->id()) ->execute(); db_update('node_field_data') ->fields(array( - 'changed' => $node1->changed + 200, + 'changed' => $node1->getChangedTime() + 200, )) ->condition('nid', $node3->id()) ->execute(); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php index 2a8f025bb1d1674b9906cb5bc9e0438ebe78728a..6a0902f893580055090e3695f7ff68fb5cb8ab74 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php @@ -52,7 +52,7 @@ function testNodeFormButtons() { // Get the node. $node_1 = node_load(1); - $this->assertEqual(1, $node_1->status, 'Node is published'); + $this->assertTrue($node_1->isPublished(), 'Node is published'); // Verify the buttons on a node edit form. $this->drupalGet('node/' . $node_1->id() . '/edit'); @@ -62,13 +62,13 @@ function testNodeFormButtons() { // 'Save and keep published'. $this->drupalPost(NULL, $edit, t('Save and keep published')); $node = node_load(1, TRUE); - $this->assertEqual(1, $node_1->status, 'Node is published'); + $this->assertTrue($node_1->isPublished(), 'Node is published'); // Save the node and verify it's unpublished after clicking // 'Save and unpublish'. $this->drupalPost('node/' . $node_1->id() . '/edit', $edit, t('Save and unpublish')); $node_1 = node_load(1, TRUE); - $this->assertEqual(0, $node_1->status, 'Node is unpublished'); + $this->assertFalse($node_1->isPublished(), 'Node is unpublished'); // Verify the buttons on an unpublished node edit screen. $this->drupalGet('node/' . $node_1->id() . '/edit'); @@ -86,7 +86,7 @@ function testNodeFormButtons() { $edit = array('title' => $this->randomString()); $this->drupalPost('node/add/article', $edit, t('Save')); $node_2 = node_load(2); - $this->assertEqual(1, $node_2->status, 'Node is published'); + $this->assertTrue($node_2->isPublished(), 'Node is published'); // Login as an administrator and unpublish the node that just // was created by the normal user. @@ -94,7 +94,7 @@ function testNodeFormButtons() { $this->drupalLogin($this->admin_user); $this->drupalPost('node/' . $node_2->id() . '/edit', array(), t('Save and unpublish')); $node_2 = node_load(2, TRUE); - $this->assertEqual(0, $node_2->status, 'Node is unpublished'); + $this->assertFalse($node_2->isPublished(), 'Node is unpublished'); // Login again as the normal user, save the node and verify // it's still unpublished. @@ -102,7 +102,7 @@ function testNodeFormButtons() { $this->drupalLogin($this->web_user); $this->drupalPost('node/' . $node_2->id() . '/edit', array(), t('Save')); $node_2 = node_load(2, TRUE); - $this->assertEqual(0, $node_2->status, 'Node is still unpublished'); + $this->assertFalse($node_2->isPublished(), 'Node is still unpublished'); $this->drupalLogout(); // Set article content type default to unpublished. This will change the @@ -122,7 +122,7 @@ function testNodeFormButtons() { $edit = array('title' => $this->randomString()); $this->drupalPost('node/add/article', $edit, t('Save')); $node_3 = node_load(3); - $this->assertEqual(0, $node_3->status, 'Node is unpublished'); + $this->assertFalse($node_3->isPublished(), 'Node is unpublished'); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php index 3906c94c9ef9b2ea2263d01bc5f9f7b55a6686ad..d6ddc3b15072e2ccd4afda0828bd265abf62ae21 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php @@ -97,11 +97,11 @@ function testRevisions() { $this->drupalLogin($content_admin); // Confirm the correct revision text appears on "view revisions" page. - $this->drupalGet("node/$node->nid/revisions/$node->vid/view"); + $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/view"); $this->assertText($node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], 'Correct text displays for version.'); // Confirm the correct log message appears on "revisions overview" page. - $this->drupalGet("node/$node->nid/revisions"); + $this->drupalGet("node/" . $node->id() . "/revisions"); foreach ($logs as $log) { $this->assertText($log, 'Log message found.'); } @@ -110,47 +110,47 @@ function testRevisions() { $this->assertTrue($node->isDefaultRevision(), 'Third node revision is the current one.'); // Confirm that revisions revert properly. - $this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/revert", array(), t('Revert')); + $this->drupalPost("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/revert", array(), t('Revert')); $this->assertRaw(t('@type %title has been reverted back to the revision from %revision-date.', array( '@type' => 'Basic page', - '%title' => $nodes[1]->title, - '%revision-date' => format_date($nodes[1]->revision_timestamp) + '%title' => $nodes[1]->getTitle(), + '%revision-date' => format_date($nodes[1]->getRevisionCreationTime()) )), 'Revision reverted.'); $reverted_node = node_load($node->id(), TRUE); $this->assertTrue(($nodes[1]->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value']), 'Node reverted correctly.'); // Confirm that this is not the current version. - $node = node_revision_load($node->vid); + $node = node_revision_load($node->getRevisionId()); $this->assertFalse($node->isDefaultRevision(), 'Third node revision is not the current one.'); // Confirm revisions delete properly. - $this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/delete", array(), t('Delete')); + $this->drupalPost("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", array(), t('Delete')); $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', array( - '%revision-date' => format_date($nodes[1]->revision_timestamp), + '%revision-date' => format_date($nodes[1]->getRevisionCreationTime()), '@type' => 'Basic page', - '%title' => $nodes[1]->title, + '%title' => $nodes[1]->getTitle(), )), 'Revision deleted.'); $this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid and vid = :vid', - array(':nid' => $node->id(), ':vid' => $nodes[1]->vid))->fetchField() == 0, + array(':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()))->fetchField() == 0, 'Revision not found.'); // Set the revision timestamp to an older date to make sure that the // confirmation message correctly displays the stored revision date. $old_revision_date = REQUEST_TIME - 86400; db_update('node_field_revision') - ->condition('vid', $nodes[2]->vid) + ->condition('vid', $nodes[2]->getRevisionId()) ->fields(array( 'revision_timestamp' => $old_revision_date, )) ->execute(); - $this->drupalPost("node/$node->nid/revisions/{$nodes[2]->vid}/revert", array(), t('Revert')); + $this->drupalPost("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert", array(), t('Revert')); $this->assertRaw(t('@type %title has been reverted back to the revision from %revision-date.', array( '@type' => 'Basic page', - '%title' => $nodes[2]->title, + '%title' => $nodes[2]->getTitle(), '%revision-date' => format_date($old_revision_date), ))); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php index 62ebcb1f40af560c71b3d68f16ceb20a059d039c..1580f8629ec8f4ac91fec7bd7fdb94b9bb02853d 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php @@ -85,11 +85,11 @@ function testRevisions() { $node = $nodes[3]; // Confirm the correct revision text appears on "view revisions" page. - $this->drupalGet("node/$node->nid/revisions/$node->vid/view"); + $this->drupalGet("node/" . $node->id() . "/revisions/" . $node->getRevisionId() . "/view"); $this->assertText($node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'], 'Correct text displays for version.'); // Confirm the correct log message appears on "revisions overview" page. - $this->drupalGet("node/$node->nid/revisions"); + $this->drupalGet("node/" . $node->id() . "/revisions"); foreach ($logs as $log) { $this->assertText($log, 'Log message found.'); } @@ -98,34 +98,34 @@ function testRevisions() { $this->assertTrue($node->isDefaultRevision(), 'Third node revision is the default one.'); // Confirm that revisions revert properly. - $this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/revert", array(), t('Revert')); + $this->drupalPost("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionid() . "/revert", array(), t('Revert')); $this->assertRaw(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => 'Basic page', '%title' => $nodes[1]->label(), - '%revision-date' => format_date($nodes[1]->revision_timestamp))), 'Revision reverted.'); + '%revision-date' => format_date($nodes[1]->getRevisionCreationTime()))), 'Revision reverted.'); $reverted_node = node_load($node->id(), TRUE); $this->assertTrue(($nodes[1]->body[Language::LANGCODE_NOT_SPECIFIED][0]['value'] == $reverted_node->body[Language::LANGCODE_NOT_SPECIFIED][0]['value']), 'Node reverted correctly.'); // Confirm that this is not the default version. - $node = node_revision_load($node->vid); + $node = node_revision_load($node->getRevisionId()); $this->assertFalse($node->isDefaultRevision(), 'Third node revision is not the default one.'); // Confirm revisions delete properly. - $this->drupalPost("node/$node->nid/revisions/{$nodes[1]->vid}/delete", array(), t('Delete')); + $this->drupalPost("node/" . $node->id() . "/revisions/" . $nodes[1]->getRevisionId() . "/delete", array(), t('Delete')); $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', - array('%revision-date' => format_date($nodes[1]->revision_timestamp), + array('%revision-date' => format_date($nodes[1]->getRevisionCreationTime()), '@type' => 'Basic page', '%title' => $nodes[1]->label())), 'Revision deleted.'); - $this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid and vid = :vid', array(':nid' => $node->id(), ':vid' => $nodes[1]->vid))->fetchField() == 0, 'Revision not found.'); + $this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid and vid = :vid', array(':nid' => $node->id(), ':vid' => $nodes[1]->getRevisionId()))->fetchField() == 0, 'Revision not found.'); // Set the revision timestamp to an older date to make sure that the // confirmation message correctly displays the stored revision date. $old_revision_date = REQUEST_TIME - 86400; db_update('node_field_revision') - ->condition('vid', $nodes[2]->vid) + ->condition('vid', $nodes[2]->getRevisionId()) ->fields(array( 'revision_timestamp' => $old_revision_date, )) ->execute(); - $this->drupalPost("node/$node->nid/revisions/{$nodes[2]->vid}/revert", array(), t('Revert')); + $this->drupalPost("node/" . $node->id() . "/revisions/" . $nodes[2]->getRevisionId() . "/revert", array(), t('Revert')); $this->assertRaw(t('@type %title has been reverted back to the revision from %revision-date.', array( '@type' => 'Basic page', '%title' => $nodes[2]->label(), @@ -146,7 +146,7 @@ function testRevisions() { $this->assertNoText($new_body, 'Revision body text is not present on default version of node.'); // Verify that the new body text is present on the revision. - $this->drupalGet("node/$node->nid/revisions/" . $new_node_revision->vid . "/view"); + $this->drupalGet("node/" . $node->id() . "/revisions/" . $new_node_revision->getRevisionId() . "/view"); $this->assertText($new_body, 'Revision body text is present when loading specific revision.'); // Verify that the non-default revision vid is greater than the default @@ -157,7 +157,7 @@ function testRevisions() { ->execute() ->fetchCol(); $default_revision_vid = $default_revision[0]; - $this->assertTrue($new_node_revision->vid > $default_revision_vid, 'Revision vid is greater than default revision vid.'); + $this->assertTrue($new_node_revision->getRevisionId() > $default_revision_vid, 'Revision vid is greater than default revision vid.'); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php index c33aa057338a63818cbcea9768f107fa912b04f9..64f109a605fc8f5ee3fa9b55f596f2b37c3574cc 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php @@ -60,7 +60,7 @@ function testImport() { $node->enforceIsNew(); // Verify that node_submit did not overwrite the user ID. - $this->assertEqual($node->uid, $this->web_user->id(), 'Function node_submit() preserves user ID'); + $this->assertEqual($node->getAuthorId(), $this->web_user->id(), 'Function node_submit() preserves user ID'); $node->save(); // Test the import. @@ -84,24 +84,24 @@ function testTimestamps() { entity_create('node', $edit)->save(); $node = $this->drupalGetNodeByTitle($edit['title']); - $this->assertEqual($node->created, REQUEST_TIME, 'Creating a node sets default "created" timestamp.'); - $this->assertEqual($node->changed, REQUEST_TIME, 'Creating a node sets default "changed" timestamp.'); + $this->assertEqual($node->getCreatedTime(), REQUEST_TIME, 'Creating a node sets default "created" timestamp.'); + $this->assertEqual($node->getChangedTime(), REQUEST_TIME, 'Creating a node sets default "changed" timestamp.'); // Store the timestamps. - $created = $node->created; - $changed = $node->changed; + $created = $node->getCreatedTime(); + $changed = $node->getChangedTime(); $node->save(); $node = $this->drupalGetNodeByTitle($edit['title'], TRUE); - $this->assertEqual($node->created, $created, 'Updating a node preserves "created" timestamp.'); + $this->assertEqual($node->getCreatedTime(), $created, 'Updating a node preserves "created" timestamp.'); // Programmatically set the timestamps using hook_node_presave. $node->title = 'testing_node_presave'; $node->save(); $node = $this->drupalGetNodeByTitle('testing_node_presave', TRUE); - $this->assertEqual($node->created, 280299600, 'Saving a node uses "created" timestamp set in presave hook.'); - $this->assertEqual($node->changed, 979534800, 'Saving a node uses "changed" timestamp set in presave hook.'); + $this->assertEqual($node->getCreatedTime(), 280299600, 'Saving a node uses "created" timestamp set in presave hook.'); + $this->assertEqual($node->getChangedTime(), 979534800, 'Saving a node uses "changed" timestamp set in presave hook.'); // Programmatically set the timestamps on the node. $edit = array( @@ -114,17 +114,17 @@ function testTimestamps() { entity_create('node', $edit)->save(); $node = $this->drupalGetNodeByTitle($edit['title']); - $this->assertEqual($node->created, 280299600, 'Creating a node uses user-set "created" timestamp.'); - $this->assertNotEqual($node->changed, 979534800, 'Creating a node does not use user-set "changed" timestamp.'); + $this->assertEqual($node->getCreatedTime(), 280299600, 'Creating a node uses user-set "created" timestamp.'); + $this->assertNotEqual($node->getChangedTime(), 979534800, 'Creating a node does not use user-set "changed" timestamp.'); // Update the timestamps. - $node->created = 979534800; + $node->setCreatedTime(979534800); $node->changed = 280299600; $node->save(); $node = $this->drupalGetNodeByTitle($edit['title'], TRUE); - $this->assertEqual($node->created, 979534800, 'Updating a node uses user-set "created" timestamp.'); - $this->assertNotEqual($node->changed, 280299600, 'Updating a node does not use user-set "changed" timestamp.'); + $this->assertEqual($node->getCreatedTime(), 979534800, 'Updating a node uses user-set "created" timestamp.'); + $this->assertNotEqual($node->getChangedTime(), 280299600, 'Updating a node does not use user-set "changed" timestamp.'); } /** @@ -172,6 +172,6 @@ function testNodeSaveOnInsert() { // node_test_node_insert() tiggers a save on insert if the title equals // 'new'. $node = $this->drupalCreateNode(array('title' => 'new')); - $this->assertEqual($node->title, 'Node ' . $node->id(), 'Node saved on node insert.'); + $this->assertEqual($node->getTitle(), 'Node ' . $node->id(), 'Node saved on node insert.'); } } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php index 6416a774cbeb14a886e10588207927d811d1289d..0713d751dbdf72c855d777b9f31a2853f53dd6ed 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php @@ -44,26 +44,26 @@ function testNodeTokenReplacement() { // Load node so that the body and summary fields are structured properly. $node = node_load($node->id()); - $instance = field_info_instance('node', 'body', $node->type); + $instance = field_info_instance('node', 'body', $node->getType()); // Generate and test sanitized tokens. $tests = array(); $tests['[node:nid]'] = $node->id(); - $tests['[node:vid]'] = $node->vid; + $tests['[node:vid]'] = $node->getRevisionId(); $tests['[node:tnid]'] = $node->tnid; $tests['[node:type]'] = 'article'; $tests['[node:type-name]'] = 'Article'; - $tests['[node:title]'] = check_plain($node->title); - $tests['[node:body]'] = text_sanitize($instance['settings']['text_processing'], $node->langcode, $node->body[$node->langcode][0], 'value'); - $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->langcode, $node->body[$node->langcode][0], 'summary'); - $tests['[node:langcode]'] = check_plain($node->langcode); + $tests['[node:title]'] = check_plain($node->getTitle()); + $tests['[node:body]'] = text_sanitize($instance['settings']['text_processing'], $node->language()->id, $node->body[$node->language()->id][0], 'value'); + $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->language()->id, $node->body[$node->language()->id][0], 'summary'); + $tests['[node:langcode]'] = check_plain($node->language()->id); $tests['[node:url]'] = url('node/' . $node->id(), $url_options); $tests['[node:edit-url]'] = url('node/' . $node->id() . '/edit', $url_options); $tests['[node:author]'] = check_plain(user_format_name($account)); - $tests['[node:author:uid]'] = $node->uid; + $tests['[node:author:uid]'] = $node->getAuthorId(); $tests['[node:author:name]'] = check_plain(user_format_name($account)); - $tests['[node:created:since]'] = format_interval(REQUEST_TIME - $node->created, 2, $language_interface->id); - $tests['[node:changed:since]'] = format_interval(REQUEST_TIME - $node->changed, 2, $language_interface->id); + $tests['[node:created:since]'] = format_interval(REQUEST_TIME - $node->getCreatedTime(), 2, $language_interface->id); + $tests['[node:changed:since]'] = format_interval(REQUEST_TIME - $node->getChangedTime(), 2, $language_interface->id); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); @@ -74,10 +74,10 @@ function testNodeTokenReplacement() { } // Generate and test unsanitized tokens. - $tests['[node:title]'] = $node->title; - $tests['[node:body]'] = $node->body[$node->langcode][0]['value']; - $tests['[node:summary]'] = $node->body[$node->langcode][0]['summary']; - $tests['[node:langcode]'] = $node->langcode; + $tests['[node:title]'] = $node->getTitle(); + $tests['[node:body]'] = $node->body[$node->language()->id][0]['value']; + $tests['[node:summary]'] = $node->body[$node->language()->id][0]['summary']; + $tests['[node:langcode]'] = $node->language()->id; $tests['[node:author:name]'] = user_format_name($account); foreach ($tests as $input => $expected) { @@ -92,11 +92,11 @@ function testNodeTokenReplacement() { // Load node (without summary) so that the body and summary fields are // structured properly. $node = node_load($node->id()); - $instance = field_info_instance('node', 'body', $node->type); + $instance = field_info_instance('node', 'body', $node->getType()); // Generate and test sanitized token - use full body as expected value. $tests = array(); - $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->langcode, $node->body[$node->langcode][0], 'value'); + $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->language()->id, $node->body[$node->language()->id][0], 'value'); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated for node without a summary.'); @@ -107,7 +107,7 @@ function testNodeTokenReplacement() { } // Generate and test unsanitized tokens. - $tests['[node:summary]'] = $node->body[$node->langcode][0]['value']; + $tests['[node:summary]'] = $node->body[$node->language()->id][0]['value']; foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('node' => $node), array('language' => $language_interface, 'sanitize' => FALSE)); diff --git a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php index b9243b2f0648aa57572c34929c6d26bc10f1eee1..43704b00417efb03c390e5cc072b4d28583ef4a8 100644 --- a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php @@ -52,7 +52,7 @@ function testPageEdit() { // Check that "edit" link points to correct page. $this->clickLink(t('Edit')); - $edit_url = url("node/$node->nid/edit", array('absolute' => TRUE)); + $edit_url = url("node/" . $node->id() . "/edit", array('absolute' => TRUE)); $actual_url = $this->getURL(); $this->assertEqual($edit_url, $actual_url, 'On edit page.'); @@ -78,7 +78,7 @@ function testPageEdit() { $second_web_user = $this->drupalCreateUser(array('administer nodes', 'edit any page content')); $this->drupalLogin($second_web_user); // Edit the same node, creating a new revision. - $this->drupalGet("node/$node->nid/edit"); + $this->drupalGet("node/" . $node->id() . "/edit"); $edit = array(); $edit['title'] = $this->randomName(8); $edit[$body_key] = $this->randomName(16); @@ -87,15 +87,15 @@ function testPageEdit() { // Ensure that the node revision has been created. $revised_node = $this->drupalGetNodeByTitle($edit['title'], TRUE); - $this->assertNotIdentical($node->vid, $revised_node->vid, 'A new revision has been created.'); + $this->assertNotIdentical($node->getRevisionId(), $revised_node->getRevisionId(), 'A new revision has been created.'); // Ensure that the node author is preserved when it was not changed in the // edit form. - $this->assertIdentical($node->uid, $revised_node->uid, 'The node author has been preserved.'); + $this->assertIdentical($node->getAuthorId(), $revised_node->getAuthorId(), 'The node author has been preserved.'); // Ensure that the revision authors are different since the revisions were // made by different users. - $first_node_version = node_revision_load($node->vid); - $second_node_version = node_revision_load($revised_node->vid); - $this->assertNotIdentical($first_node_version->revision_uid, $second_node_version->revision_uid, 'Each revision has a distinct user.'); + $first_node_version = node_revision_load($node->getRevisionId()); + $second_node_version = node_revision_load($revised_node->getRevisionId()); + $this->assertNotIdentical($first_node_version->getRevisionAuthor()->id(), $second_node_version->getRevisionAuthor()->id(), 'Each revision has a distinct user.'); } /** @@ -114,7 +114,7 @@ function testPageAuthoredBy() { // Check that the node was authored by the currently logged in user. $node = $this->drupalGetNodeByTitle($edit['title']); - $this->assertIdentical($node->uid, $this->admin_user->id(), 'Node authored by admin user.'); + $this->assertIdentical($node->getAuthorId(), $this->admin_user->id(), 'Node authored by admin user.'); // Try to change the 'authored by' field to an invalid user name. $edit = array( @@ -128,14 +128,14 @@ function testPageAuthoredBy() { $edit['name'] = ''; $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); $node = node_load($node->id(), TRUE); - $this->assertIdentical($node->uid, '0', 'Node authored by anonymous user.'); + $this->assertIdentical($node->getAuthorId(), '0', 'Node authored by anonymous user.'); // Change the authored by field to another user's name (that is not // logged in). $edit['name'] = $this->web_user->getUsername(); $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save and keep published')); - $node = node_load($node->nid, TRUE); - $this->assertIdentical($node->uid, $this->web_user->id(), 'Node authored by normal user.'); + $node = node_load($node->id(), TRUE); + $this->assertIdentical($node->getAuthorId(), $this->web_user->id(), 'Node authored by normal user.'); // Check that normal users cannot change the authored by information. $this->drupalLogin($this->web_user); diff --git a/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php b/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php index ececc4c13e90efe25aa55639149dee037fb8d3e9..7186d45878df1cdbf27e2e449badb517fe1b315c 100644 --- a/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php @@ -28,7 +28,7 @@ function testPageView() { $this->assertTrue(node_load($node->id()), 'Node created.'); // Try to edit with anonymous user. - $this->drupalGet("node/$node->nid/edit"); + $this->drupalGet("node/" . $node->id() . "/edit"); $this->assertResponse(403); // Create a user without permission to edit node. @@ -36,7 +36,7 @@ function testPageView() { $this->drupalLogin($web_user); // Attempt to access edit page. - $this->drupalGet("node/$node->nid/edit"); + $this->drupalGet("node/" . $node->id() . "/edit"); $this->assertResponse(403); // Create user with permission to edit node. @@ -44,7 +44,7 @@ function testPageView() { $this->drupalLogin($web_user); // Attempt to access edit page. - $this->drupalGet("node/$node->nid/edit"); + $this->drupalGet("node/" . $node->id() . "/edit"); $this->assertResponse(200); } } diff --git a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php index 21b1fe6db4d79022e22368e0cee7e2d4f67837e9..2b0c493abcecd036faa4a4a62798604d61ed2741 100644 --- a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php @@ -47,7 +47,7 @@ function testSummaryLength() { $this->assertRaw($expected); // Change the teaser length for "Basic page" content type. - $display = entity_get_display('node', $node->type, 'teaser'); + $display = entity_get_display('node', $node->getType(), 'teaser'); $display_options = $display->getComponent('body'); $display_options['settings']['trim_length'] = 200; $display->setComponent('body', $display_options) diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index ded77897a33d06bdeab932acb4887017e4b6e072..03387f873741f118518e3e70072494c4ab9da98b 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -236,10 +236,10 @@ function node_admin_nodes() { '#empty' => t('No content available.'), ); foreach ($nodes as $node) { - $l_options = $node->langcode != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$node->langcode]) ? array('language' => $languages[$node->langcode]) : array(); + $l_options = $node->language()->id != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$node->language()->id]) ? array('language' => $languages[$node->language()->id]) : array(); $mark = array( '#theme' => 'mark', - '#status' => node_mark($node->id(), $node->changed), + '#status' => node_mark($node->id(), $node->getChangedTime()), ); $form['nodes'][$node->id()]['title'] = array( '#type' => 'link', @@ -253,17 +253,17 @@ function node_admin_nodes() { ); $form['nodes'][$node->id()]['author'] = array( '#theme' => 'username', - '#account' => user_load($node->uid), + '#account' => $node->getAuthor(), ); $form['nodes'][$node->id()]['status'] = array( - '#markup' => $node->status ? t('published') : t('not published'), + '#markup' => $node->isPublished() ? t('published') : t('not published'), ); $form['nodes'][$node->id()]['changed'] = array( - '#markup' => format_date($node->changed, 'short'), + '#markup' => format_date($node->getChangedTime(), 'short'), ); if ($multilingual) { $form['nodes'][$node->id()]['language_name'] = array( - '#markup' => language_name($node->langcode), + '#markup' => $node->language()->name, ); } diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index 216639161f371ed257d387a627a78c173a4eb8ff..4fe295f467dbc9a74c2976fbf4f503bae7f86814 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -214,7 +214,7 @@ function hook_node_grants($account, $op) { * - 'gid': A 'grant ID' from hook_node_grants(). * - 'grant_view': If set to 1 a user that has been identified as a member * of this gid within this realm can view this node. This should usually be - * set to $node->status. Failure to do so may expose unpublished content + * set to $node->isPublished(). Failure to do so may expose unpublished content * to some users. * - 'grant_update': If set to 1 a user that has been identified as a member * of this gid within this realm can edit this node. @@ -257,15 +257,15 @@ function hook_node_grants($account, $op) { * @see hook_node_access_records_alter() * @ingroup node_access */ -function hook_node_access_records(\Drupal\Core\Entity\EntityInterface $node) { +function hook_node_access_records(\Drupal\node\NodeInterface $node) { // We only care about the node if it has been marked private. If not, it is // treated just like any other node and we completely ignore it. if ($node->private) { $grants = array(); // Only published Catalan translations of private nodes should be viewable - // to all users. If we fail to check $node->status, all users would be able + // to all users. If we fail to check $node->isPublished(), all users would be able // to view an unpublished node. - if ($node->status) { + if ($node->isPublished()) { $grants[] = array( 'realm' => 'example', 'gid' => 1, @@ -281,7 +281,7 @@ function hook_node_access_records(\Drupal\Core\Entity\EntityInterface $node) { // have status unpublished. $grants[] = array( 'realm' => 'example_author', - 'gid' => $node->uid, + 'gid' => $node->getAuthorId(), 'grant_view' => 1, 'grant_update' => 1, 'grant_delete' => 1, @@ -438,7 +438,7 @@ function hook_node_delete(\Drupal\Core\Entity\EntityInterface $node) { */ function hook_node_revision_delete(\Drupal\Core\Entity\EntityInterface $node) { db_delete('mytable') - ->condition('vid', $node->vid) + ->condition('vid', $node->getRevisionId()) ->execute(); } @@ -567,8 +567,8 @@ function hook_node_load($nodes, $types) { * * @ingroup node_access */ -function hook_node_access($node, $op, $account, $langcode) { - $type = is_string($node) ? $node : $node->type; +function hook_node_access(\Drupal\node\NodeInterface $node, $op, $account, $langcode) { + $type = is_string($node) ? $node : $node->getType(); $configured_types = node_permissions_get_configured_types(); if (isset($configured_types[$type])) { @@ -577,13 +577,13 @@ function hook_node_access($node, $op, $account, $langcode) { } if ($op == 'update') { - if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->id() == $node->uid))) { + if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->id() == $node->getAuthorId()))) { return NODE_ACCESS_ALLOW; } } if ($op == 'delete') { - if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->id() == $node->uid))) { + if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->id() == $node->getAuthorId()))) { return NODE_ACCESS_ALLOW; } } @@ -612,7 +612,7 @@ function hook_node_access($node, $op, $account, $langcode) { */ function hook_node_prepare_form(\Drupal\node\NodeInterface $node, $form_display, $operation, array &$form_state) { if (!isset($node->comment)) { - $node->comment = variable_get("comment_$node->type", COMMENT_NODE_OPEN); + $node->comment = variable_get('comment_' . $node->getType(), COMMENT_NODE_OPEN); } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 200c6f63218603b7eda39f2144dede2911598460..a47b72bad6268a428aee336d370e13e3079cb504 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -537,8 +537,8 @@ function node_load_multiple(array $nids = NULL, $reset = FALSE) { * (optional) Whether to reset the node_load_multiple() cache. Defaults to * FALSE. * - * @return \Drupal\node\Node|null - * A fully-populated node entity or NULL if the node is not found. + * @return \Drupal\node\NodeInterface|null + * A fully-populated node entity, or NULL if the node is not found. */ function node_load($nid = NULL, $reset = FALSE) { $entity = entity_load('node', $nid, $reset); @@ -548,11 +548,11 @@ function node_load($nid = NULL, $reset = FALSE) { /** * Loads a node revision from the database. * - * @param int $nid + * @param int $vid * The node revision id. * - * @return \Drupal\node\Node|null - * A fully-populated node entity or NULL if the node is not found. + * @return \Drupal\node\NodeInterface|null + * A fully-populated node entity, or NULL if the node is not found. */ function node_revision_load($vid = NULL) { return entity_revision_load('node', $vid); @@ -693,7 +693,7 @@ function template_preprocess_node(&$variables) { // http://drupal.org/node/1941286. $username = array( '#theme' => 'username', - '#account' => user_load($node->uid), + '#account' => $node->getAuthor(), '#link_options' => array('attributes' => array('rel' => 'author')), ); $variables['name'] = drupal_render($username); @@ -951,7 +951,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) { $uri = $node->uri(); $username = array( '#theme' => 'username', - '#account' => user_load($node->uid), + '#account' => $node->getAuthor(), ); $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 48ad45f37b13e76bceef721733f3cc0bb603693a..4cb383b348059b6ed6cc5962915f3694f06d0b07 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -11,6 +11,7 @@ use Drupal\Core\Entity\EntityInterface; use Symfony\Component\HttpFoundation\RedirectResponse; +use Drupal\node\NodeInterface; /** * Page callback: Displays add content links for available content types. @@ -106,21 +107,21 @@ function node_add($node_type) { * * @see node_form_build_preview() */ -function node_preview(EntityInterface $node) { +function node_preview(NodeInterface $node) { if (node_access('create', $node) || node_access('update', $node)) { // Load the user's name when needed. if (isset($node->name)) { // The use of isset() is mandatory in the context of user IDs, because // user ID 0 denotes the anonymous user. if ($user = user_load_by_name($node->name)) { - $node->uid = $user->id(); + $node->setAuthorId($user->id()); } else { - $node->uid = 0; // anonymous user + $node->setAuthorId(0); // anonymous user } } - elseif ($node->uid) { - $user = user_load($node->uid); + elseif ($node->getAuthorId()) { + $user = $node->getAuthor(); $node->name = $user->getUsername(); } @@ -198,7 +199,7 @@ function node_revision_overview($node) { $revisions = node_revision_list($node); $rows = array(); - $type = $node->type; + $type = $node->getType(); $revert_permission = FALSE; if ((user_access("revert $type revisions") || user_access('revert all revisions') || user_access('administer nodes')) && node_access('update', $node)) { @@ -225,18 +226,18 @@ function node_revision_overview($node) { '#theme' => 'username', '#account' => user_load($revision->uid), ); - $row[] = t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), "node/$node->nid/revisions/$revision->vid/view"), '!username' => drupal_render($username))) + $row[] = t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), "node/" . $node->id() . "/revisions/" . $revision->vid . "/view"), '!username' => drupal_render($username))) . (($revision->log != '') ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''); if ($revert_permission) { $links['revert'] = array( 'title' => t('Revert'), - 'href' => "node/$node->nid/revisions/$revision->vid/revert", + 'href' => "node/" . $node->id() . "/revisions/" . $revision->vid . "/revert", ); } if ($delete_permission) { $links['delete'] = array( 'title' => t('Delete'), - 'href' => "node/$node->nid/revisions/$revision->vid/delete", + 'href' => "node/" . $node->id() . "/revisions/" . $revision->vid . "/delete", ); } $row[] = array( diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc index 357562144046e850299f53623e3a37286d238e3b..3094ae6830e987a06b277c8298d397415a74c21a 100644 --- a/core/modules/node/node.tokens.inc +++ b/core/modules/node/node.tokens.inc @@ -115,7 +115,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'vid': - $replacements[$original] = $node->vid; + $replacements[$original] = $node->getRevisionId(); break; case 'tnid': @@ -123,7 +123,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'type': - $replacements[$original] = $sanitize ? check_plain($node->type) : $node->type; + $replacements[$original] = $sanitize ? check_plain($node->getType()) : $node->getType(); break; case 'type-name': @@ -132,14 +132,14 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'title': - $replacements[$original] = $sanitize ? check_plain($node->title) : $node->title; + $replacements[$original] = $sanitize ? check_plain($node->getTitle()) : $node->getTitle(); break; case 'body': case 'summary': if (($items = $node->getTranslation($langcode)->get('body')) && !$items->isEmpty()) { $item = $items[0]; - $instance = field_info_instance('node', 'body', $node->type); + $instance = field_info_instance('node', 'body', $node->getType()); $field_langcode = field_language($node, 'body', $langcode); // If the summary was requested and is not empty, use it. @@ -155,7 +155,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr // Get the 'trim_length' size used for the 'teaser' mode, if // present, or use the default trim_length size. - $display_options = entity_get_display('node', $node->type, 'teaser')->getComponent('body'); + $display_options = entity_get_display('node', $node->getType(), 'teaser')->getComponent('body'); if (isset($display_options['settings']['trim_length'])) { $length = $display_options['settings']['trim_length']; } @@ -172,7 +172,7 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'langcode': - $replacements[$original] = $sanitize ? check_plain($node->langcode) : $node->langcode; + $replacements[$original] = $sanitize ? check_plain($node->language()->id) : $node->language()->id; break; case 'url': @@ -185,32 +185,30 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr // Default values for the chained tokens handled below. case 'author': - $account = user_load($node->uid); - $name = user_format_name($account); - $replacements[$original] = $sanitize ? check_plain($name) : $name; + $account = $node->getAuthor() ? $node->getAuthor() : user_load(0); + $replacements[$original] = $sanitize ? check_plain($account->label()) : $account->label(); break; case 'created': - $replacements[$original] = format_date($node->created, 'medium', '', NULL, $langcode); + $replacements[$original] = format_date($node->getCreatedTime(), 'medium', '', NULL, $langcode); break; case 'changed': - $replacements[$original] = format_date($node->changed, 'medium', '', NULL, $langcode); + $replacements[$original] = format_date($node->getChangedTime(), 'medium', '', NULL, $langcode); break; } } if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) { - $author = user_load($node->uid); - $replacements += $token_service->generate('user', $author_tokens, array('user' => $author), $options); + $replacements += $token_service->generate('user', $author_tokens, array('user' => $node->getAuthor()), $options); } if ($created_tokens = $token_service->findWithPrefix($tokens, 'created')) { - $replacements += $token_service->generate('date', $created_tokens, array('date' => $node->created), $options); + $replacements += $token_service->generate('date', $created_tokens, array('date' => $node->getCreatedTime()), $options); } if ($changed_tokens = $token_service->findWithPrefix($tokens, 'changed')) { - $replacements += $token_service->generate('date', $changed_tokens, array('date' => $node->changed), $options); + $replacements += $token_service->generate('date', $changed_tokens, array('date' => $node->getChangedTime()), $options); } } diff --git a/core/modules/node/templates/node.html.twig b/core/modules/node/templates/node.html.twig index ad128114867c57f236c93acb4ae7ed58f13e460c..daf308a1dfc5d2b5bff214dc63279b1ece8644b2 100644 --- a/core/modules/node/templates/node.html.twig +++ b/core/modules/node/templates/node.html.twig @@ -5,15 +5,16 @@ * * Available variables: * - node: Full node entity. - * - type: The type of the node, for example, "page" or "article". - * - uid: The user ID of the node author. - * - created: Formatted creation date. Preprocess functions can reformat it by + * - id: The node ID + * - bundle: The type of the node, for example, "page" or "article". + * - authorid: The user ID of the node author. + * - createdtime: Formatted creation date. Preprocess functions can reformat it by * calling format_date() with the desired parameters on - * $variables['node']->created. - * - promote: Whether the node is promoted to the front page. + * $variables['node']->getCreatedTime(). + * - promoted: Whether the node is promoted to the front page. * - sticky: Whether the node is 'sticky'. Sticky nodes are ordered above * other non-sticky nodes in teaser listings - * - status: Whether the node is published. + * - published: Whether the node is published. * - comment: A value representing the comment status of the current node. May * be one of the following: * - 0: The comment form and any existing comments are hidden. @@ -81,7 +82,7 @@ * @ingroup themeable */ #} -<article id="node-{{ node.nid }}" class="{{ attributes.class }} clearfix"{{ attributes }}> +<article id="node-{{ node.id }}" class="{{ attributes.class }} clearfix"{{ attributes }}> {{ title_prefix }} {% if not page %} diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module index d4bfc2956b51362177ae425f521d47a2ffd8c253..c200908b964d41994cf534f6da7467bf1f1b66dd 100644 --- a/core/modules/node/tests/modules/node_access_test/node_access_test.module +++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module @@ -10,6 +10,7 @@ */ use Drupal\Core\Entity\EntityInterface; +use Drupal\node\NodeInterface; /** * Implements hook_node_grants(). @@ -32,7 +33,7 @@ function node_access_test_node_grants($account, $op) { /** * Implements hook_node_access_records(). */ -function node_access_test_node_access_records(EntityInterface $node) { +function node_access_test_node_access_records(NodeInterface $node) { $grants = array(); // For NodeAccessBaseTableTestCase, only set records for private nodes. if (!Drupal::state()->get('node_access_test.private') || $node->private) { @@ -56,7 +57,7 @@ function node_access_test_node_access_records(EntityInterface $node) { // means there are many many groups of just 1 user. $grants[] = array( 'realm' => 'node_access_test_author', - 'gid' => $node->uid, + 'gid' => $node->getAuthorId(), 'grant_view' => 1, 'grant_update' => 1, 'grant_delete' => 1, diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module index a11a616993a0c0d312da77d8af78ae19e76d9370..c0622a48ed4c4b748fe8ba3b52f9ecac159c7f9f 100644 --- a/core/modules/node/tests/modules/node_test/node_test.module +++ b/core/modules/node/tests/modules/node_test/node_test.module @@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\entity\Plugin\Core\Entity\EntityDisplay; +use Drupal\node\NodeInterface; /** * Implements hook_node_load(). @@ -77,7 +78,7 @@ function node_test_node_access_records(EntityInterface $node) { return; } $grants = array(); - if ($node->type == 'article') { + if ($node->getType() == 'article') { // Create grant in arbitrary article_realm for article nodes. $grants[] = array( 'realm' => 'test_article_realm', @@ -88,7 +89,7 @@ function node_test_node_access_records(EntityInterface $node) { 'priority' => 0, ); } - elseif ($node->type == 'page') { + elseif ($node->getType() == 'page') { // Create grant in arbitrary page_realm for page nodes. $grants[] = array( 'realm' => 'test_page_realm', @@ -105,11 +106,11 @@ function node_test_node_access_records(EntityInterface $node) { /** * Implements hook_node_access_records_alter(). */ -function node_test_node_access_records_alter(&$grants, EntityInterface $node) { +function node_test_node_access_records_alter(&$grants, NodeInterface $node) { if (!empty($grants)) { foreach ($grants as $key => $grant) { // Alter grant from test_page_realm to test_alter_realm and modify the gid. - if ($grant['realm'] == 'test_page_realm' && $node->promote) { + if ($grant['realm'] == 'test_page_realm' && $node->isPromoted()) { $grants[$key]['realm'] = 'test_alter_realm'; $grants[$key]['gid'] = 2; } @@ -129,15 +130,15 @@ function node_test_node_grants_alter(&$grants, $account, $op) { * Implements hook_node_presave(). */ function node_test_node_presave(EntityInterface $node) { - if ($node->title == 'testing_node_presave') { + if ($node->getTitle() == 'testing_node_presave') { // Sun, 19 Nov 1978 05:00:00 GMT - $node->created = 280299600; + $node->setCreatedTime(280299600); // Drupal 1.0 release. $node->changed = 979534800; } // Determine changes. - if (!empty($node->original) && $node->original->title == 'test_changes') { - if ($node->original->title != $node->title) { + if (!empty($node->original) && $node->original->getTitle() == 'test_changes') { + if ($node->original->getTitle() != $node->getTitle()) { $node->title .= '_presave'; } } @@ -148,8 +149,8 @@ function node_test_node_presave(EntityInterface $node) { */ function node_test_node_update(EntityInterface $node) { // Determine changes on update. - if (!empty($node->original) && $node->original->title == 'test_changes') { - if ($node->original->title != $node->title) { + if (!empty($node->original) && $node->original->getTitle() == 'test_changes') { + if ($node->original->getTitle() != $node->getTitle()) { $node->title .= '_update'; } } @@ -175,7 +176,7 @@ function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\Entity */ function node_test_node_insert(EntityInterface $node) { // Set the node title to the node ID and save. - if ($node->title == 'new') { + if ($node->getTitle() == 'new') { $node->title = 'Node '. $node->id(); $node->save(); } diff --git a/core/modules/node/tests/modules/node_test_exception/node_test_exception.module b/core/modules/node/tests/modules/node_test_exception/node_test_exception.module index 9eaa4f1e4880987c25a8a89b443f816635988b1d..184dfce962257d5faa3e5c1da9fe4f5b4ae3c92f 100644 --- a/core/modules/node/tests/modules/node_test_exception/node_test_exception.module +++ b/core/modules/node/tests/modules/node_test_exception/node_test_exception.module @@ -11,7 +11,7 @@ * Implements hook_node_insert(). */ function node_test_exception_node_insert(EntityInterface $node) { - if ($node->title == 'testing_transaction_exception') { + if ($node->getTitle() == 'testing_transaction_exception') { throw new Exception('Test exception for rollback.'); } } diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php index 122747d97a73c2bffaec6e828d7526d1dfd8985e..1724a4abb4764eb7411e761cef410c8efe768058 100644 --- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php +++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php @@ -86,6 +86,11 @@ function testAliasTranslation() { // Clear the path lookup cache. $this->container->get('path.alias_manager')->cacheClear(); + // Languages are cached on many levels, and we need to clear those caches. + drupal_static_reset('language_list'); + $this->rebuildContainer(); + $languages = language_list(); + // Ensure the node was created. $french_node = $this->drupalGetNodeByTitle($edit["title"]); $this->assertTrue(($french_node), 'Node found in database.'); @@ -94,12 +99,8 @@ function testAliasTranslation() { $this->drupalGet('fr/' . $edit['path[alias]']); $this->assertText($french_node->label(), 'Alias for French translation works.'); - // Confirm that the alias is returned by url(). Languages are cached on - // many levels, and we need to clear those caches. - drupal_static_reset('language_list'); - $this->rebuildContainer(); - $languages = language_list(); - $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->id(), array('language' => $languages[$french_node->langcode])); + // Confirm that the alias is returned by url(). + $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->id(), array('language' => $languages[$french_node->language()->id])); $this->assertTrue(strpos($url, $edit['path[alias]']), 'URL contains the path alias.'); @@ -150,17 +151,17 @@ function testAliasTranslation() { // The alias manager has an internal path lookup cache. Check to see that // it has the appropriate contents at this point. $this->container->get('path.alias_manager')->cacheClear(); - $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode); + $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->language()->id); $this->assertEqual($french_node_path, 'node/' . $french_node->id(), 'Normal path works.'); // Second call should return the same path. - $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->langcode); + $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->language()->id); $this->assertEqual($french_node_path, 'node/' . $french_node->id(), 'Normal path is the same.'); // Confirm that the alias works. - $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), $french_node->langcode); + $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), $french_node->language()->id); $this->assertEqual($french_node_alias, $french_alias, 'Alias works.'); // Second call should return the same alias. - $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), $french_node->langcode); + $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), $french_node->language()->id); $this->assertEqual($french_node_alias, $french_alias, 'Alias is the same.'); } } diff --git a/core/modules/path/path.module b/core/modules/path/path.module index 0966334649d5603acc1c1c38f4e51ecac94e2e38..683f637e0469c724bbb7dcd98b88b55e444b05f4 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -5,9 +5,8 @@ * Enables users to rename URLs. */ -use Drupal\Core\Entity\EntityInterface; - use Drupal\Core\Language\Language; +use Drupal\node\NodeInterface; use Drupal\taxonomy\Plugin\Core\Entity\Term; /** @@ -101,8 +100,8 @@ function path_form_node_form_alter(&$form, $form_state) { $path = array(); if (!$node->isNew()) { $conditions = array('source' => 'node/' . $node->id()); - if ($node->langcode != Language::LANGCODE_NOT_SPECIFIED) { - $conditions['langcode'] = $node->langcode; + if ($node->language()->id != Language::LANGCODE_NOT_SPECIFIED) { + $conditions['langcode'] = $node->language()->id; } $path = Drupal::service('path.crud')->load($conditions); if ($path === FALSE) { @@ -113,7 +112,7 @@ function path_form_node_form_alter(&$form, $form_state) { 'pid' => NULL, 'source' => $node->id() ? 'node/' . $node->id() : NULL, 'alias' => '', - 'langcode' => isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED, + 'langcode' => $node->language()->id, ); $form['path'] = array( @@ -184,14 +183,14 @@ function path_form_element_validate($element, &$form_state, $complete_form) { /** * Implements hook_node_insert(). */ -function path_node_insert(EntityInterface $node) { +function path_node_insert(NodeInterface $node) { if (isset($node->path)) { $alias = trim($node->path['alias']); // Only save a non-empty alias. if (!empty($alias)) { // Ensure fields for programmatic executions. $source = 'node/' . $node->id(); - $langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED; + $langcode = $node->language()->id; Drupal::service('path.crud')->save($source, $alias, $langcode); } } @@ -200,7 +199,7 @@ function path_node_insert(EntityInterface $node) { /** * Implements hook_node_update(). */ -function path_node_update(EntityInterface $node) { +function path_node_update(NodeInterface $node) { if (isset($node->path)) { $path = $node->path; $alias = trim($path['alias']); @@ -212,7 +211,7 @@ function path_node_update(EntityInterface $node) { if (!empty($path['alias'])) { // Ensure fields for programmatic executions. $source = 'node/' . $node->id(); - $langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED; + $langcode = $node->language()->id; Drupal::service('path.crud')->save($source, $alias, $langcode, $path['pid']); } } @@ -221,7 +220,7 @@ function path_node_update(EntityInterface $node) { /** * Implements hook_node_predelete(). */ -function path_node_predelete(EntityInterface $node) { +function path_node_predelete(NodeInterface $node) { // Delete all aliases associated with this node. Drupal::service('path.crud')->delete(array('source' => 'node/' . $node->id())); } diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/NodeAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/NodeAttributesTest.php index a026bd64e6c54336eb8ecebff8d47ae87acc4509..e8ba1d3898e2092513e0ad12cd319a885282f50c 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/NodeAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/NodeAttributesTest.php @@ -77,21 +77,21 @@ function testNodeAttributes() { // Node title. $expected_value = array( 'type' => 'literal', - 'value' => $node->title, + 'value' => $node->getTitle(), 'lang' => 'en', ); $this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/title', $expected_value), 'Node title found in RDF output (dc:title).'); // Node date. $expected_value = array( 'type' => 'literal', - 'value' => date('c', $node->created), + 'value' => date('c', $node->getCreatedTime()), 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime', ); $this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Node date found in RDF output (dc:date).'); // Node date. $expected_value = array( 'type' => 'literal', - 'value' => date('c', $node->created), + 'value' => date('c', $node->getCreatedTime()), 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime', ); $this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Node date found in RDF output (dc:created).'); diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php index 909b7b5ae684ecd0bc61b147e651890730fcc7c6..072fcc5b3bb95d9934b63ba095f6f6ebdd8d651b 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php @@ -119,9 +119,9 @@ function testAttributesInTracker() { */ function _testBasicTrackerRdfaMarkup(EntityInterface $node) { $node_uri = url('node/' . $node->id(), array('absolute' => TRUE)); - $user_uri = url('user/' . $node->uid, array('absolute' => TRUE)); + $user_uri = url('user/' . $node->getAuthorId(), array('absolute' => TRUE)); - $user = ($node->uid == 0) ? 'Anonymous user' : 'Registered user'; + $user = ($node->getAuthorId() == 0) ? 'Anonymous user' : 'Registered user'; // Parses tracker page where the nodes are displayed in a table. $parser = new \EasyRdf_Parser_Rdfa(); @@ -134,7 +134,7 @@ function _testBasicTrackerRdfaMarkup(EntityInterface $node) { 'type' => 'literal', // The theme layer adds a space after the title a element, and the RDFa // attribute is on the wrapping td. Adds a space to match this. - 'value' => $node->title . ' ', + 'value' => $node->getTitle() . ' ', 'lang' => 'en', ); $this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/title', $expected_value), 'Title found in RDF output (dc:title).'); @@ -150,16 +150,16 @@ function _testBasicTrackerRdfaMarkup(EntityInterface $node) { 'type' => 'uri', 'value' => $user_uri, ); - if ($node->uid == 0) { + if ($node->getAuthorId() == 0) { $this->assertFalse($graph->hasProperty($node_uri, 'http://rdfs.org/sioc/ns#has_creator', $expected_value), 'No relation to author found in RDF output (sioc:has_creator).'); } - elseif ($node->uid > 0) { + elseif ($node->getAuthorId() > 0) { $this->assertTrue($graph->hasProperty($node_uri, 'http://rdfs.org/sioc/ns#has_creator', $expected_value), 'Relation to author found in RDF output (sioc:has_creator).'); } // Last updated. $expected_value = array( 'type' => 'literal', - 'value' => date('c', $node->changed), + 'value' => date('c', $node->getChangedTime()), 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime', ); $this->assertTrue($graph->hasProperty($node_uri, 'http://rdfs.org/sioc/ns#last_activity_date', $expected_value), 'Last activity date found in RDF output (sioc:last_activity_date).'); diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module index 06b25a05812b40ab5b4a9f8438ae4936e5629567..16f4b911ac929f2c4b29d8a0e140eac22ba6e4ac 100644 --- a/core/modules/rdf/rdf.module +++ b/core/modules/rdf/rdf.module @@ -277,7 +277,7 @@ function rdf_preprocess_node(&$variables) { // Adds RDFa markup for the date. $created_mapping = $mapping->getPreparedFieldMapping('created'); if (!empty($created_mapping) && $variables['submitted']) { - $date_attributes = rdf_rdfa_attributes($created_mapping, $variables['node']->created); + $date_attributes = rdf_rdfa_attributes($created_mapping, $variables['node']->getCreatedTime()); $rdf_metadata = array( '#theme' => 'rdf_metadata', '#metadata' => array($date_attributes), diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php index 5b0efebb781a26db78d3bb573c05a4cb326c3120..ed47384400d90f405d8c8fa45d7c5d0b32a1c8fd 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchAdvancedSearchFormTest.php @@ -42,7 +42,7 @@ function setUp() { * Test using the advanced search form to limit search to nodes of type "Basic page". */ function testNodeType() { - $this->assertTrue($this->node->type == 'page', 'Node type is Basic page.'); + $this->assertTrue($this->node->getType() == 'page', 'Node type is Basic page.'); // Assert that the dummy title doesn't equal the real title. $dummy_title = 'Lorem ipsum'; diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index 649a933fa93ff7a693eb001306e1150c8b129f0c..1fff4a6fe71a5e4ef068f063b9db37b82881339a 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -226,12 +226,12 @@ function hook_search_execute($keys = NULL, $conditions = NULL) { 'type' => check_plain(node_get_type_label($node)), 'title' => $node->label($item->langcode), 'user' => drupal_render($username), - 'date' => $node->changed, + 'date' => $node->getChangedTime(), 'node' => $node, 'extra' => $extra, 'score' => $item->calculated_score, 'snippet' => search_excerpt($keys, $node->rendered, $item->langcode), - 'langcode' => $node->langcode, + 'langcode' => $node->language()->id, ); } return $results; @@ -347,7 +347,7 @@ function hook_update_index() { // Save the changed time of the most recent indexed node, for the search // results half-life calculation. - \Drupal::state()->set('node.cron_last', $node->changed); + \Drupal::state()->set('node.cron_last', $node->getChangedTime()); // Render the node. $build = node_view($node, 'search_index'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php index 80e8a6b3987958d8c579ba8f763a1d738d66febe..4404ca575e46acdaf1f9ecb698dc7c64136793cc 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationFormTest.php @@ -69,12 +69,12 @@ function testEntityFormLanguage() { $this->drupalPost(NULL, $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit["title"]); - $this->assertTrue($node->langcode == $form_langcode, 'Form language is the same as the entity language.'); + $this->assertTrue($node->language()->id == $form_langcode, 'Form language is the same as the entity language.'); // Edit the node and test the form language. $this->drupalGet($this->langcodes[0] . '/node/' . $node->id() . '/edit'); $form_langcode = \Drupal::state()->get('entity_test.form_langcode') ?: FALSE; - $this->assertTrue($node->langcode == $form_langcode, 'Form language is the same as the entity language.'); + $this->assertTrue($node->language()->id == $form_langcode, 'Form language is the same as the entity language.'); // Explicitly set form langcode. $langcode = $this->langcodes[0]; diff --git a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php index d51c9ea75c3fb239e8b8825b5c2feb6336cff6e7..7d1814efaedde7917c79ea71f06c2f90c7c20cd8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php @@ -174,15 +174,15 @@ function testBreadCrumbs() { $trail = $home; $this->assertBreadcrumb("node/$nid1", $trail); // Also verify that the node does not appear elsewhere (e.g., menu trees). - $this->assertNoLink($node1->title); + $this->assertNoLink($node1->getTitle()); // The node itself should not be contained in the breadcrumb on the default // local task, since there is no difference between both pages. $this->assertBreadcrumb("node/$nid1/view", $trail); // Also verify that the node does not appear elsewhere (e.g., menu trees). - $this->assertNoLink($node1->title); + $this->assertNoLink($node1->getTitle()); $trail += array( - "node/$nid1" => $node1->title, + "node/$nid1" => $node1->getTitle(), ); $this->assertBreadcrumb("node/$nid1/edit", $trail); @@ -220,10 +220,10 @@ function testBreadCrumbs() { $tree = array( "node/$nid2" => $node2->menu['link_title'], ); - $this->assertBreadcrumb("node/$nid2", $trail, $node2->title, $tree); + $this->assertBreadcrumb("node/$nid2", $trail, $node2->getTitle(), $tree); // The node itself should not be contained in the breadcrumb on the // default local task, since there is no difference between both pages. - $this->assertBreadcrumb("node/$nid2/view", $trail, $node2->title, $tree); + $this->assertBreadcrumb("node/$nid2/view", $trail, $node2->getTitle(), $tree); $trail += array( "node/$nid2" => $node2->menu['link_title'], ); @@ -244,10 +244,10 @@ function testBreadCrumbs() { )); $nid3 = $node3->id(); - $this->assertBreadcrumb("node/$nid3", $trail, $node3->title, $tree, FALSE); + $this->assertBreadcrumb("node/$nid3", $trail, $node3->getTitle(), $tree, FALSE); // The node itself should not be contained in the breadcrumb on the // default local task, since there is no difference between both pages. - $this->assertBreadcrumb("node/$nid3/view", $trail, $node3->title, $tree, FALSE); + $this->assertBreadcrumb("node/$nid3/view", $trail, $node3->getTitle(), $tree, FALSE); $trail += array( "node/$nid3" => $node3->menu['link_title'], ); @@ -288,14 +288,14 @@ function testBreadCrumbs() { $tree = $expected + array( 'node/' . $parent->id() => $parent->menu['link_title'], ); - $this->assertBreadcrumb(NULL, $trail, $parent->title, $tree); + $this->assertBreadcrumb(NULL, $trail, $parent->getTitle(), $tree); $trail += array( 'node/' . $parent->id() => $parent->menu['link_title'], ); $tree += array( 'node/' . $parent->id() => $child->menu['link_title'], ); - $this->assertBreadcrumb('node/' . $child->id(), $trail, $child->title, $tree); + $this->assertBreadcrumb('node/' . $child->id(), $trail, $child->getTitle(), $tree); // Add a taxonomy term/tag to last node, and add a link for that term to the // Tools menu. @@ -350,7 +350,7 @@ function testBreadCrumbs() { $link['link_path'] => $link['link_title'], ); $this->assertBreadcrumb($link['link_path'], $trail, $term->label(), $tree); - $this->assertRaw(check_plain($parent->title), 'Tagged node found.'); + $this->assertRaw(check_plain($parent->getTitle()), 'Tagged node found.'); // Additionally make sure that this link appears only once; i.e., the // untranslated menu links automatically generated from menu router items diff --git a/core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php b/core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php index ad966e2a24dd1d2deaed05daaa603bdae30175c7..f1ff08fcd94e33cd9d89f3ef84f14c1b0750f5d7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/ParamConverter/UpcastingTest.php @@ -51,12 +51,12 @@ public function testUpcasting() { // paramconverter_test/test_node_user_user/{node}/{foo}/{user} // options.parameters.foo.type = entity:user - $this->drupalGet("paramconverter_test/test_node_user_user/{$node->nid}/" . $user->id() . "/" . $user->id()); + $this->drupalGet("paramconverter_test/test_node_user_user/" . $node->id() . "/" . $user->id() . "/" . $user->id()); $this->assertRaw("user: {$user->label()}, node: {$node->label()}, foo: {$user->label()}", 'foo converted to user as well'); // paramconverter_test/test_node_node_foo/{user}/{node}/{foo} // options.parameters.user.type = entity:node - $this->drupalGet("paramconverter_test/test_node_node_foo/{$node->nid}/{$node->nid}/$foo"); + $this->drupalGet("paramconverter_test/test_node_node_foo/" . $node->id() . "/" . $node->id() . "/$foo"); $this->assertRaw("user: {$node->label()}, node: {$node->label()}, foo: $foo", 'user is upcast to node (rather than to user)'); } @@ -68,7 +68,7 @@ public function testSameTypes() { $parent = $this->drupalCreateNode(array('title' => $this->randomName(8))); // paramconverter_test/node/{node}/set/parent/{parent} // options.parameters.parent.type = entity:node - $this->drupalGet("paramconverter_test/node/" . $node->nid . "/set/parent/" . $parent->nid); - $this->assertRaw("Setting '" . $parent->title . "' as parent of '" . $node->title . "'."); + $this->drupalGet("paramconverter_test/node/" . $node->id() . "/set/parent/" . $parent->id()); + $this->assertRaw("Setting '" . $parent->getTitle() . "' as parent of '" . $node->getTitle() . "'."); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php index 962d21f7648ba2249bca92f90c60c2fc5cfb7205..e17c7094f694b0dd066312f339e90a9907209eb5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php @@ -100,10 +100,10 @@ function testLocalizeDateFormats() { // Configure format for the node posted date changes with the language. $this->drupalGet('node/' . $node->id()); - $english_date = format_date($node->created, 'custom', 'j M Y'); + $english_date = format_date($node->getCreatedTime(), 'custom', 'j M Y'); $this->assertText($english_date, 'English date format appears'); $this->drupalGet('fr/node/' . $node->id()); - $french_date = format_date($node->created, 'custom', 'd.m.Y'); + $french_date = format_date($node->getCreatedTime(), 'custom', 'd.m.Y'); $this->assertText($french_date, 'French date format appears'); // Make sure we can reset dates back to default. diff --git a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php index 84bf929e9e07658bf254986fe456aabfa33500dd..4350d10ef7bff3bf964f66fb2b9a3471fea9d0a5 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/TokenReplaceTest.php @@ -43,9 +43,9 @@ function testTokenReplacement() { $source .= '[user:name]'; // No user passed in, should be untouched $source .= '[bogus:token]'; // Non-existent token - $target = check_plain($node->title); + $target = check_plain($node->getTitle()); $target .= check_plain($account->getUsername()); - $target .= format_interval(REQUEST_TIME - $node->created, 2, $language_interface->id); + $target .= format_interval(REQUEST_TIME - $node->getCreatedTime(), 2, $language_interface->id); $target .= check_plain($user->getUsername()); $target .= format_date(REQUEST_TIME, 'short', '', NULL, $language_interface->id); @@ -65,10 +65,10 @@ function testTokenReplacement() { // correctly by a 'known' token, [node:title]. $raw_tokens = array('title' => '[node:title]'); $generated = $token_service->generate('node', $raw_tokens, array('node' => $node)); - $this->assertEqual($generated['[node:title]'], check_plain($node->title), 'Token sanitized.'); + $this->assertEqual($generated['[node:title]'], check_plain($node->getTitle()), 'Token sanitized.'); $generated = $token_service->generate('node', $raw_tokens, array('node' => $node), array('sanitize' => FALSE)); - $this->assertEqual($generated['[node:title]'], $node->title, 'Unsanitized token generated properly.'); + $this->assertEqual($generated['[node:title]'], $node->getTitle(), 'Unsanitized token generated properly.'); // Test token replacement when the string contains no tokens. $this->assertEqual($token_service->replace('No tokens here.'), 'No tokens here.'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php index f7d53e2cb2d454e66e10105ef48cbc33b4a83f51..bf62114480e67618a95fabe384762b7f4b6d27ed 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php @@ -108,7 +108,7 @@ function setUp() { // Create a test comment on the test node. $this->comment = entity_create('comment', array( 'nid' => $this->node->id(), - 'node_type' => $this->node->type, + 'node_type' => $this->node->getType(), 'status' => COMMENT_PUBLISHED, 'subject' => $this->xss_label, 'comment_body' => array($this->randomName()), diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php index 4c5f59093ba8fc0e7a8ea22fae73946b7b283561..2fba93f6a9ba7f27e8f5e94e9164b1b8f3799ba1 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/LanguageUpgradePathTest.php @@ -84,9 +84,9 @@ public function testLanguageUpgrade() { $spanish_nid = 51; $translation_source_nid = 52; $translation_nid = 53; - // Check directly for the $node->langcode property. - $this->assertEqual(node_load($language_none_nid)->langcode, Language::LANGCODE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for Language::LANGCODE_NOT_SPECIFIED node."); - $this->assertEqual(node_load($spanish_nid)->langcode, 'ca', "'language' property was renamed to 'langcode' for Catalan node."); + // Check directly for the node langcode. + $this->assertEqual(node_load($language_none_nid)->language()->id, Language::LANGCODE_NOT_SPECIFIED, "'language' property was renamed to 'langcode' for Language::LANGCODE_NOT_SPECIFIED node."); + $this->assertEqual(node_load($spanish_nid)->language()->id, 'ca', "'language' property was renamed to 'langcode' for Catalan node."); // Check that the translation table works correctly. $this->drupalGet("node/$translation_source_nid/translate"); $this->assertResponse(200, 'The translated node has a proper translation table.'); diff --git a/core/modules/system/system.api.php b/core/modules/system/system.api.php index bbc3c72f40635a8b39d61d6bc17403d53f2ba05c..fca2eb0304f5d9b273571e563b1d774cbd0a3e5f 100644 --- a/core/modules/system/system.api.php +++ b/core/modules/system/system.api.php @@ -1861,10 +1861,10 @@ function hook_mail($key, &$message, $params) { if (isset($params['node'])) { $node = $params['node']; $variables += array( - '%uid' => $node->uid, + '%uid' => $node->getAuthorId(), '%node_url' => url('node/' . $node->id(), array('absolute' => TRUE)), '%node_type' => node_get_type_label($node), - '%title' => $node->title, + '%title' => $node->getTitle(), '%teaser' => $node->teaser, '%body' => $node->body, ); @@ -3144,7 +3144,7 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr break; case 'title': - $replacements[$original] = $sanitize ? check_plain($node->title) : $node->title; + $replacements[$original] = $sanitize ? check_plain($node->getTitle()) : $node->getTitle(); break; case 'edit-url': @@ -3153,23 +3153,22 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr // Default values for the chained tokens handled below. case 'author': - $name = ($node->uid == 0) ? Drupal::config('user.settings')->get('anonymous') : $node->name; - $replacements[$original] = $sanitize ? filter_xss($name) : $name; + $account = $node->getAuthor() ? $node->getAuthor() : user_load(0); + $replacements[$original] = $sanitize ? check_plain($account->label()) : $account->label(); break; case 'created': - $replacements[$original] = format_date($node->created, 'medium', '', NULL, $langcode); + $replacements[$original] = format_date($node->getCreatedTime(), 'medium', '', NULL, $langcode); break; } } if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) { - $author = user_load($node->uid); - $replacements += $token_service->generate('user', $author_tokens, array('user' => $author), $options); + $replacements += $token_service->generate('user', $author_tokens, array('user' => $node->getAuthor()), $options); } if ($created_tokens = $token_service->findWithPrefix($tokens, 'created')) { - $replacements += $token_service->generate('date', $created_tokens, array('date' => $node->created), $options); + $replacements += $token_service->generate('date', $created_tokens, array('date' => $node->getCreatedTime()), $options); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php index 02574353db6303d87e489fc61de3651286fc4db7..2ceb8438dc0bf6e8b3bbf3df8f74ae51c0d8c797 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/argument_default/Tid.php @@ -135,7 +135,7 @@ public function getArgument() { // Just check, if a node could be detected. if ($node) { $taxonomy = array(); - $fields = field_info_instances('node', $node->type); + $fields = field_info_instances('node', $node->getType()); foreach ($fields as $name => $info) { $field_info = field_info_field($name); if ($field_info['type'] == 'taxonomy_term_reference') { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php index 5a34e15914e540afe6073915b966b566700b033a..3758df78b4a0427180c53c7025d5b523597d021b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LegacyTest.php @@ -48,6 +48,6 @@ function testTaxonomyLegacyNode() { $this->drupalPost('node/add/article', $edit, t('Save and publish')); // Checks that the node has been saved. $node = $this->drupalGetNodeByTitle($edit['title']); - $this->assertEqual($node->created, $date->getTimestamp(), 'Legacy node was saved with the right date.'); + $this->assertEqual($node->getCreatedTime(), $date->getTimestamp(), 'Legacy node was saved with the right date.'); } } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 090baaffdf2e1719d6bf5470ec1790e9e15e2ec6..17bbb8cf6a6bf920e23a830d4206cca6225f8039 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -1130,22 +1130,14 @@ function taxonomy_build_node_index($node) { // only data for current, published nodes. $status = NULL; if (Drupal::config('taxonomy.settings')->get('maintain_index_table')) { - // If a node property is not set in the node object when $node->save() is - // called, the old value from $node->original is used. - if (!empty($node->original)) { - $status = (int)(!empty($node->status) || (!isset($node->status) && !empty($node->original->status))); - $sticky = (int)(!empty($node->sticky) || (!isset($node->sticky) && !empty($node->original->sticky))); - } - else { - $status = (int)(!empty($node->status)); - $sticky = (int)(!empty($node->sticky)); - } + $status = $node->isPublished(); + $sticky = (int) $node->isSticky(); } // We only maintain the taxonomy index for published nodes. if ($status && $node->isDefaultRevision()) { // Collect a unique list of all the term IDs from all node fields. $tid_all = array(); - foreach (field_info_instances('node', $node->type) as $instance) { + foreach (field_info_instances('node', $node->getType()) as $instance) { $field_name = $instance['field_name']; $field = field_info_field($field_name); if ($field['module'] == 'taxonomy' && $field['storage']['type'] == 'field_sql_storage') { @@ -1177,7 +1169,7 @@ function taxonomy_build_node_index($node) { 'nid' => $node->id(), 'tid' => $tid, 'sticky' => $sticky, - 'created' => $node->created, + 'created' => $node->getCreatedTime(), )); } $query->execute(); diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php index 76033fb52b612c12c8802c09727f2ea0da05dd70..4598aae2df45915c830f4e2db2404ec23c1eb28a 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php @@ -59,19 +59,19 @@ function testTrackerNodeAccess() { // User with access should see both nodes created. $this->drupalGet('tracker'); - $this->assertText($private_node->title, 'Private node is visible to user with private access.'); - $this->assertText($public_node->title, 'Public node is visible to user with private access.'); + $this->assertText($private_node->getTitle(), 'Private node is visible to user with private access.'); + $this->assertText($public_node->getTitle(), 'Public node is visible to user with private access.'); $this->drupalGet('user/' . $access_user->id() . '/track'); - $this->assertText($private_node->title, 'Private node is visible to user with private access.'); - $this->assertText($public_node->title, 'Public node is visible to user with private access.'); + $this->assertText($private_node->getTitle(), 'Private node is visible to user with private access.'); + $this->assertText($public_node->getTitle(), 'Public node is visible to user with private access.'); // User without access should not see private node. $this->drupalLogin($no_access_user); $this->drupalGet('tracker'); - $this->assertNoText($private_node->title, 'Private node is not visible to user without private access.'); - $this->assertText($public_node->title, 'Public node is visible to user without private access.'); + $this->assertNoText($private_node->getTitle(), 'Private node is not visible to user without private access.'); + $this->assertText($public_node->getTitle(), 'Public node is visible to user without private access.'); $this->drupalGet('user/' . $access_user->id() . '/track'); - $this->assertNoText($private_node->title, 'Private node is not visible to user without private access.'); - $this->assertText($public_node->title, 'Public node is visible to user without private access.'); + $this->assertNoText($private_node->getTitle(), 'Private node is not visible to user without private access.'); + $this->assertText($public_node->getTitle(), 'Public node is visible to user without private access.'); } } diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php index 804774d791738b26b3f2842f164fe06bf24b3c6f..54a689b8f10772f672668250a14128c5140ac0eb 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerUserUidTest.php @@ -52,7 +52,7 @@ public function testUserUid() { // Change the filter value to our user. $view->initHandlers(); - $view->filter['uid_touch_tracker']->value = $this->node->uid; + $view->filter['uid_touch_tracker']->value = $this->node->getAuthorId(); $this->executeView($view); // We should have one result as the filter is set for the created user. @@ -70,7 +70,7 @@ public function testUserUid() { // Test the correct argument UID. $view->initHandlers(); - $this->executeView($view, array($this->node->uid)); + $this->executeView($view, array($this->node->getAuthorId())); $this->assertIdenticalResultSet($view, $expected, $map); } diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index 1052b5fcebb6f6a204292b1be894262aa9df29a6..581a10df1e33486e97daf676eb3af653d20ecfcb 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -6,6 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; +use Drupal\node\NodeInterface; /** * Implements hook_help(). @@ -195,8 +196,8 @@ function _tracker_user_access($account) { * * Adds new tracking information for this node since it's new. */ -function tracker_node_insert(EntityInterface $node, $arg = 0) { - _tracker_add($node->id(), $node->uid, $node->changed); +function tracker_node_insert(NodeInterface $node, $arg = 0) { + _tracker_add($node->id(), $node->getAuthorId(), $node->getChangedTime()); } /** @@ -204,8 +205,8 @@ function tracker_node_insert(EntityInterface $node, $arg = 0) { * * Adds tracking information for this node since it's been updated. */ -function tracker_node_update(EntityInterface $node, $arg = 0) { - _tracker_add($node->id(), $node->uid, $node->changed); +function tracker_node_update(NodeInterface $node, $arg = 0) { + _tracker_add($node->id(), $node->getAuthorId(), $node->getChangedTime()); } /** @@ -302,14 +303,14 @@ function _tracker_add($nid, $uid, $changed) { } /** - * Determines the max timestamp between $node->changed and the last comment. + * Picks the most recent timestamp between node changed and the last comment. * * @param $nid * A node ID. * * @return - * The $node->changed timestamp, or most recent comment timestamp, whichever - * is the greatest. + * The node changed timestamp, or most recent comment timestamp, whichever is + * the greatest. */ function _tracker_calculate_changed($nid) { // @todo This should be actually filtering on the desired language and just diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index cf2f51a33f215e4ad88526bffbd61be014cb93a6..8e187eff74666cb8206b05f8f5f886c714674bed 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -76,21 +76,20 @@ function tracker_page($account = NULL, $set_title = FALSE) { $mark_build = array( '#theme' => 'mark', - '#status' => node_mark($node->id(), $node->changed), + '#status' => node_mark($node->id(), $node->getChangedTime()), ); $row = array( 'type' => check_plain(node_get_type_label($node)), - // Do not use $node->label(), because $node comes from the database. - 'title' => array('data' => l($node->title, 'node/' . $node->id()) . ' ' . drupal_render($mark_build)), - 'author' => array('data' => array('#theme' => 'username', '#account' => user_load($node->uid))), + 'title' => array('data' => l($node->getTitle(), 'node/' . $node->id()) . ' ' . drupal_render($mark_build)), + 'author' => array('data' => array('#theme' => 'username', '#account' => $node->getAuthor())), 'replies' => array('class' => array('replies'), 'data' => $comments), 'last updated' => array('data' => t('!time ago', array('!time' => format_interval(REQUEST_TIME - $node->last_activity)))), ); // Adds extra RDFa markup to the $row array if the RDF module is enabled. if (module_exists('rdf')) { - $mapping = rdf_get_mapping('node', $node->type); + $mapping = rdf_get_mapping('node', $node->getType()); // Adds RDFa markup to the title of the node. Because the RDFa markup is // added to the td tag which might contain HTML code, we specify an // empty datatype to ensure the value of the title read by the RDFa diff --git a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php index 761197ac299fa2293f4304558d4fc10efbed647d..434464e9844757cceb367aa819472963508a559e 100644 --- a/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php +++ b/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php @@ -86,7 +86,7 @@ function testContentTranslation() { $languages = language_list(); $prefixes = language_negotiation_url_prefixes(); $this->drupalGet('node/' . $node->id() . '/translate'); - $this->assertLinkByHref($prefixes['es'] . '/node/add/' . $node->type, 0, format_string('The "add translation" link for %language points to the localized path of the target language.', array('%language' => $languages['es']->name))); + $this->assertLinkByHref($prefixes['es'] . '/node/add/' . $node->getType(), 0, format_string('The "add translation" link for %language points to the localized path of the target language.', array('%language' => $languages['es']->name))); // Submit translation in Spanish. $node_translation_title = $this->randomName(); @@ -450,7 +450,7 @@ function assertLanguageSwitchLinks(NodeInterface $node, $translation, $find = TR $result = TRUE; $languages = language_list(); - $page_language = $languages[$node->langcode]; + $page_language = $languages[$node->language()->id]; $translation_language = $languages[$translation->langcode]; $url = url("node/$translation->nid", array('language' => $translation_language)); diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index 5846ca2c01131a9bdbc0f95e1503ee7629baec5d..56a514787146d89c5d96cea90b4361bfb7e6ccc4 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -87,8 +87,8 @@ function translation_menu() { * * @see translation_menu() */ -function _translation_tab_access($node) { - if ($node->langcode != Language::LANGCODE_NOT_SPECIFIED && translation_supported_type($node->type) && node_access('view', $node)) { +function _translation_tab_access(NodeInterface $node) { + if ($node->language()->id != Language::LANGCODE_NOT_SPECIFIED && translation_supported_type($node->getType()) && node_access('view', $node)) { return translation_user_can_translate_node($node); } return FALSE; @@ -154,7 +154,7 @@ function translation_user_can_translate_node($node, $account = NULL) { if (empty($account)) { $account = $GLOBALS['user']; } - return node_access('view', $node, $account) && (user_access('translate all content', $account) || ($node->uid == $account->id() && user_access('translate own content', $account))); + return node_access('view', $node, $account) && (user_access('translate all content', $account) || ($node->getAuthorId() == $account->id() && user_access('translate own content', $account))); } /** @@ -199,7 +199,7 @@ function translation_node_type_language_translation_enabled_validate($element, & */ function translation_form_node_form_alter(&$form, &$form_state) { $node = $form_state['controller']->getEntity(); - if (translation_supported_type($node->type)) { + if (translation_supported_type($node->getType())) { if (!empty($node->translation_source)) { // We are creating a translation. Add values and lock language field. $form['translation_source'] = array('#type' => 'value', '#value' => $node->translation_source); @@ -272,7 +272,7 @@ function translation_node_view(EntityInterface $node, EntityDisplay $display, $v foreach ($translations as $langcode => $translation) { // Do not show links to the same node or to unpublished translations. - if ($translation->status && isset($languages[$langcode]) && $langcode != $node->langcode) { + if ($translation->status && isset($languages[$langcode]) && $langcode != $node->language()->id) { $key = "translation_$langcode"; if (isset($custom_links->links[$langcode])) { @@ -313,7 +313,7 @@ function translation_node_prepare_form(NodeInterface $node, $form_display, $oper $translation = $query->get('translation'); $target = $query->get('target'); // Only act if we are dealing with a content type supporting translations. - if (translation_supported_type($node->type) && + if (translation_supported_type($node->getType()) && // And it's a new node. $node->isNew() && // And the request variables are set properly. @@ -325,7 +325,7 @@ function translation_node_prepare_form(NodeInterface $node, $form_display, $oper $language_list = language_list(); $langcode = $target; - if (!isset($language_list[$langcode]) || ($source_node->langcode == $langcode)) { + if (!isset($language_list[$langcode]) || ($source_node->language()->id == $langcode)) { // If not supported language, or same language as source node, break. return; } @@ -334,7 +334,7 @@ function translation_node_prepare_form(NodeInterface $node, $form_display, $oper if (!empty($source_node->tnid)) { $translations = translation_node_get_translations($source_node->tnid); if (isset($translations[$langcode])) { - drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->label(), '%language' => $language_list[$langcode]->name, '%type' => $node->type)), 'error'); + drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->label(), '%language' => $language_list[$langcode]->name, '%type' => $node->getType())), 'error'); return; } } @@ -342,7 +342,7 @@ function translation_node_prepare_form(NodeInterface $node, $form_display, $oper // Populate fields based on source node. $node->langcode = $langcode; $node->translation_source = $source_node; - $node->title = $source_node->title; + $node->title = $source_node->getTitle(); } } @@ -351,7 +351,7 @@ function translation_node_prepare_form(NodeInterface $node, $form_display, $oper */ function translation_node_insert(EntityInterface $node) { // Only act if we are dealing with a content type supporting translations. - if (translation_supported_type($node->type)) { + if (translation_supported_type($node->getType())) { if (!empty($node->translation_source)) { if ($node->translation_source->tnid) { // Add node to existing translation set. @@ -384,10 +384,10 @@ function translation_node_insert(EntityInterface $node) { /** * Implements hook_node_update(). */ -function translation_node_update(EntityInterface $node) { +function translation_node_update(NodeInterface $node) { // Only act if we are dealing with a content type supporting translations. - if (translation_supported_type($node->type)) { - if (isset($node->translation) && $node->translation && !empty($node->langcode) && $node->tnid) { + if (translation_supported_type($node->getType())) { + if (isset($node->translation) && $node->translation && $node->tnid) { // Update translation information. db_update('node') ->fields(array( @@ -416,7 +416,7 @@ function translation_node_update(EntityInterface $node) { function translation_node_validate(EntityInterface $node, $form, &$form_state) { // Only act on translatable nodes with a tnid or translation_source. $form_node = $form_state['controller']->getEntity(); - if (translation_supported_type($node->type) && (!empty($node->tnid) || ($form_node->translation_source && $form_node->translation_source->id()))) { + if (translation_supported_type($node->getType()) && (!empty($node->tnid) || ($form_node->translation_source && $form_node->translation_source->id()))) { $tnid = !empty($node->tnid) ? $node->tnid : $form_node->translation_source->id(); $translations = translation_node_get_translations($tnid); if (isset($translations[$node->language()->id]) && $translations[$node->language()->id]->nid != $node->id()) { @@ -430,7 +430,7 @@ function translation_node_validate(EntityInterface $node, $form, &$form_state) { */ function translation_node_predelete(EntityInterface $node) { // Only act if we are dealing with a content type supporting translations. - if (translation_supported_type($node->type)) { + if (translation_supported_type($node->getType())) { translation_remove_from_set($node); } } @@ -554,10 +554,10 @@ function translation_language_switch_links_alter(array &$links, $type, $path) { // have translations it might be a language neutral node, in which case we // must leave the language switch links unaltered. This is true also for // nodes not having translation support enabled. - if (empty($node) || $node->langcode == Language::LANGCODE_NOT_SPECIFIED || !translation_supported_type($node->type)) { + if (empty($node) || $node->language()->id == Language::LANGCODE_NOT_SPECIFIED || !translation_supported_type($node->getType())) { return; } - $translations = array($node->langcode => $node); + $translations = array($node->language()->id => $node); } else { $translations = translation_node_get_translations($node->tnid); diff --git a/core/modules/translation/translation.pages.inc b/core/modules/translation/translation.pages.inc index 62d2ada411ea72cc58e9da8ae93a9295ff0091fe..2b787bf9b02d5f4d37b53d5b0251359e22ae585a 100644 --- a/core/modules/translation/translation.pages.inc +++ b/core/modules/translation/translation.pages.inc @@ -30,7 +30,7 @@ function translation_node_overview(EntityInterface $node) { else { // We have no translation source nid, this could be a new set, emulate that. $tnid = $node->nid; - $translations = array($node->langcode => $node); + $translations = array($node->language()->id => $node); } $type = Drupal::config('translation.settings')->get('language_type'); @@ -55,7 +55,7 @@ function translation_node_overview(EntityInterface $node) { ) + $links->links[$langcode]; } } - $status = $translation_node->status ? t('Published') : t('Not published'); + $status = $translation_node->isPublished() ? t('Published') : t('Not published'); $status .= $translation_node->translate ? ' - <span class="marker">' . t('outdated') . '</span>' : ''; if ($translation_node->id() == $tnid) { $language_name = t('<strong>@language_name</strong> (source)', array('@language_name' => $language_name)); @@ -65,7 +65,7 @@ function translation_node_overview(EntityInterface $node) { // No such translation in the set yet: help user to create it. $title = t('n/a'); if (node_access('create', $node)) { - $path = 'node/add/' . $node->type; + $path = 'node/add/' . $node->getType(); $links = language_negotiation_get_switch_links($type, $path); $query = array('query' => array('translation' => $node->id(), 'target' => $langcode)); if (!empty($links->links[$langcode]['href'])) { diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php index f58c641eed06fae113625b0ee9934ee57d2e09b5..42d39a7cf629c45b9a8dbc3e46712554b12fb242 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/argument_default/User.php @@ -56,7 +56,7 @@ public function getArgument() { foreach (range(1, 3) as $i) { $node = menu_get_object('node', $i); if (!empty($node)) { - return $node->uid; + return $node->getAuthorId(); } } } @@ -69,7 +69,7 @@ public function getArgument() { if (arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(arg(1)); if ($node) { - return $node->uid; + return $node->getAuthorId(); } } } diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php index e87393324ced53bb01fa15d89a80277cc7d4c406..af8d8c97abe733b6c19c10131a734f2ceee71389 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php @@ -57,7 +57,7 @@ function testUserCancelWithoutPermission() { // Confirm user's content has not been altered. $test_node = node_load($node->id(), TRUE); - $this->assertTrue(($test_node->uid == $account->id() && $test_node->status == 1), 'Node of the user has not been altered.'); + $this->assertTrue(($test_node->getAuthorId() == $account->id() && $test_node->isPublished()), 'Node of the user has not been altered.'); } /** @@ -138,7 +138,7 @@ function testUserCancelInvalid() { // Confirm user's content has not been altered. $test_node = node_load($node->id(), TRUE); - $this->assertTrue(($test_node->uid == $account->id() && $test_node->status == 1), 'Node of the user has not been altered.'); + $this->assertTrue(($test_node->getAuthorId() == $account->id() && $test_node->isPublished()), 'Node of the user has not been altered.'); } /** @@ -212,9 +212,9 @@ function testUserBlockUnpublish() { // Confirm user's content has been unpublished. $test_node = node_load($node->id(), TRUE); - $this->assertTrue($test_node->status == 0, 'Node of the user has been unpublished.'); - $test_node = node_revision_load($node->vid); - $this->assertTrue($test_node->status == 0, 'Node revision of the user has been unpublished.'); + $this->assertFalse($test_node->isPublished(), 'Node of the user has been unpublished.'); + $test_node = node_revision_load($node->getRevisionId()); + $this->assertFalse($test_node->isPublished(), 'Node revision of the user has been unpublished.'); // Confirm that the confirmation message made it through to the end user. $this->assertRaw(t('%name has been disabled.', array('%name' => $account->getUsername())), "Confirmation message displayed to user."); @@ -238,7 +238,7 @@ function testUserAnonymize() { // Create a node with two revisions, the initial one belonging to the // cancelling user. $revision_node = $this->drupalCreateNode(array('uid' => $account->id())); - $revision = $revision_node->vid; + $revision = $revision_node->getRevisionId(); $settings = get_object_vars($revision_node); $settings['revision'] = 1; $settings['uid'] = 1; // Set new/current revision to someone else. @@ -261,11 +261,11 @@ function testUserAnonymize() { // Confirm that user's content has been attributed to anonymous user. $test_node = node_load($node->id(), TRUE); - $this->assertTrue(($test_node->uid == 0 && $test_node->status == 1), 'Node of the user has been attributed to anonymous user.'); + $this->assertTrue(($test_node->getAuthorId() == 0 && $test_node->isPublished()), 'Node of the user has been attributed to anonymous user.'); $test_node = node_revision_load($revision, TRUE); - $this->assertTrue(($test_node->revision_uid == 0 && $test_node->status == 1), 'Node revision of the user has been attributed to anonymous user.'); + $this->assertTrue(($test_node->getRevisionAuthor()->id() == 0 && $test_node->isPublished()), 'Node revision of the user has been attributed to anonymous user.'); $test_node = node_load($revision_node->id(), TRUE); - $this->assertTrue(($test_node->uid != 0 && $test_node->status == 1), "Current revision of the user's node was not attributed to anonymous user."); + $this->assertTrue(($test_node->getAuthorId() != 0 && $test_node->isPublished()), "Current revision of the user's node was not attributed to anonymous user."); // Confirm that the confirmation message made it through to the end user. $this->assertRaw(t('%name has been deleted.', array('%name' => $account->getUsername())), "Confirmation message displayed to user."); @@ -304,7 +304,7 @@ function testUserDelete() { // Create a node with two revisions, the initial one belonging to the // cancelling user. $revision_node = $this->drupalCreateNode(array('uid' => $account->id())); - $revision = $revision_node->vid; + $revision = $revision_node->getRevisionId(); $settings = get_object_vars($revision_node); $settings['revision'] = 1; $settings['uid'] = 1; // Set new/current revision to someone else. diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 42d59adc40f8da6a3416e0e2a256a60bd36dd008..e3ff5257f7db338ae80ead376b7343c442be9b38 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -168,14 +168,14 @@ function user_label($entity_type, $entity) { function user_attach_accounts(array $entities) { $uids = array(); foreach ($entities as $entity) { - $uids[] = $entity->uid; + $uids[] = $entity->getAuthorId(); } $uids = array_unique($uids); $accounts = user_load_multiple($uids); $anonymous = drupal_anonymous_user(); foreach ($entities as $id => $entity) { - if (isset($accounts[$entity->uid])) { - $entities[$id]->account = $accounts[$entity->uid]; + if (isset($accounts[$entity->getAuthorId()])) { + $entities[$id]->account = $accounts[$entity->getAuthorId()]; } else { $entities[$id]->account = $anonymous; @@ -1966,7 +1966,7 @@ function user_node_load($nodes, $types) { // Build an array of all uids for node authors, keyed by nid. $uids = array(); foreach ($nodes as $nid => $node) { - $uids[$nid] = $node->uid; + $uids[$nid] = $node->getAuthorId(); } // Fetch name and data for these users. diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php b/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php index fefd5d1fcce8c1c9ebbe3c6b6654a1080f0cc5ed..868c20d20ad0e016a504c3eae264432653091bd2 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/Date.php @@ -77,10 +77,10 @@ public function getDefaultArgument($raw = FALSE) { return parent::getDefaultArgument(); } elseif ($this->options['default_argument_type'] == 'node_created') { - return date($this->argFormat, $node->created); + return date($this->argFormat, $node->getCreatedTime()); } elseif ($this->options['default_argument_type'] == 'node_changed') { - return date($this->argFormat, $node->changed); + return date($this->argFormat, $node->getChangedTime()); } } diff --git a/core/themes/bartik/templates/node.html.twig b/core/themes/bartik/templates/node.html.twig index d8af3d54798f6d69e9595932ccd8a276fea66dc4..d45cc55bdbedf81d67a819800747f24ea3d61a51 100644 --- a/core/themes/bartik/templates/node.html.twig +++ b/core/themes/bartik/templates/node.html.twig @@ -5,15 +5,16 @@ * * Available variables: * - node: Full node entity. - * - type: The type of the node, for example, "page" or "article". - * - uid: The user ID of the node author. - * - created: Formatted creation date. Preprocess functions can reformat it by - * calling format_date() with the desired parameters on - * $variables['node']->created. - * - promote: Whether the node is promoted to the front page. + * - id: The node ID + * - bundle: The type of the node, for example, "page" or "article". + * - authorid: The user ID of the node author. + * - createdtime: Formatted creation date. Preprocess functions can reformat + it by calling format_date() with the desired parameters on + * $variables['node']->getCreatedTime(). + * - promoted: Whether the node is promoted to the front page. * - sticky: Whether the node is 'sticky'. Sticky nodes are ordered above * other non-sticky nodes in teaser listings - * - status: Whether the node is published. + * - published: Whether the node is published. * - comment: A value representing the comment status of the current node. May * be one of the following: * - 0: The comment form and any existing comments are hidden. @@ -77,7 +78,7 @@ * @ingroup themeable */ #} -<article id="node-{{ node.nid }}" class="{{ attributes.class}} clearfix"{{ attributes }} role="article"> +<article id="node-{{ node.id }}" class="{{ attributes.class}} clearfix"{{ attributes }} role="article"> <header> {{ title_prefix }} diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index a73fb56121711b79bb415345b206dd18c6a79800..5735f2913e9c51681943601a66628691c95378d3 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -172,20 +172,20 @@ function seven_form_node_form_alter(&$form, &$form_state) { 'published' => array( '#type' => 'item', '#wrapper_attributes' => array('class' => array('published')), - '#markup' => !empty($node->status) ? t('Published') : t('Not published'), + '#markup' => $node->isPublished() ? t('Published') : t('Not published'), '#access' => !$node->isNew(), ), 'changed' => array( '#type' => 'item', '#wrapper_attributes' => array('class' => array('changed', 'container-inline')), '#title' => t('Last saved'), - '#markup' => !$node->isNew() ? format_date($node->changed, 'short') : t('Not saved yet'), + '#markup' => !$node->isNew() ? format_date($node->getChangedTime(), 'short') : t('Not saved yet'), ), 'author' => array( '#type' => 'item', '#wrapper_attributes' => array('class' => array('author', 'container-inline')), '#title' => t('Author'), - '#markup' => user_format_name(user_load($node->uid)), + '#markup' => $node->getAuthor()->getUsername(), ), ); $form['revision_information']['#type'] = 'container';