', 'No image displayed when no image is attached and no default image specified.');
@@ -235,7 +235,7 @@ function testImageFieldDefaultImage() {
$image = file_load($field['settings']['default_image']);
$this->assertTrue($image->isPermanent(), 'The default image status is permanent.');
$default_output = theme('image', array('uri' => $image->getFileUri()));
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$this->assertRaw($default_output, 'Default image displayed when no user supplied image is present.');
// Create a node with an image attached and ensure that the default image
@@ -281,7 +281,7 @@ function testImageFieldDefaultImage() {
// image is displayed.
$node = $this->drupalCreateNode(array('type' => 'article'));
$default_output = theme('image', array('uri' => $image->getFileUri()));
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$this->assertRaw($default_output, 'Default private image displayed when no user supplied image is present.');
}
}
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php
index c55927f..211a7d0 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php
@@ -122,7 +122,7 @@ function testContentTypeLanguageConfiguration() {
);
$node = $this->drupalCreateNode($edit);
// Edit the content and ensure correct language is selected.
- $path = 'node/' . $node->nid . '/edit';
+ $path = 'node/' . $node->id() . '/edit';
$this->drupalGet($path);
$this->assertRaw('
', t('Correct language selected.'));
// Ensure we can change the node language.
@@ -184,26 +184,26 @@ function testContentTypeDirLang() {
// Check if English node does not have lang tag.
- $this->drupalGet('node/' . $nodes['en']->nid);
- $pattern = '|id="node-' . $nodes['en']->nid . '"[^<>]*lang="en"|';
+ $this->drupalGet('node/' . $nodes['en']->id());
+ $pattern = '|id="node-' . $nodes['en']->id() . '"[^<>]*lang="en"|';
$this->assertNoPattern($pattern, 'The lang tag has not been assigned to the English node.');
// Check if English node does not have dir tag.
- $pattern = '|id="node-' . $nodes['en']->nid . '"[^<>]*dir="ltr"|';
+ $pattern = '|id="node-' . $nodes['en']->id() . '"[^<>]*dir="ltr"|';
$this->assertNoPattern($pattern, 'The dir tag has not been assigned to the English node.');
// Check if Arabic node has lang="ar" & dir="rtl" tags.
- $this->drupalGet('node/' . $nodes['ar']->nid);
- $pattern = '|id="node-' . $nodes['ar']->nid . '"[^<>]*lang="ar" dir="rtl"|';
+ $this->drupalGet('node/' . $nodes['ar']->id());
+ $pattern = '|id="node-' . $nodes['ar']->id() . '"[^<>]*lang="ar" dir="rtl"|';
$this->assertPattern($pattern, 'The lang and dir tags have been assigned correctly to the Arabic node.');
// Check if Spanish node has lang="es" tag.
- $this->drupalGet('node/' . $nodes['es']->nid);
- $pattern = '|id="node-' . $nodes['es']->nid . '"[^<>]*lang="es"|';
+ $this->drupalGet('node/' . $nodes['es']->id());
+ $pattern = '|id="node-' . $nodes['es']->id() . '"[^<>]*lang="es"|';
$this->assertPattern($pattern, 'The lang tag has been assigned correctly to the Spanish node.');
// Check if Spanish node does not have dir="ltr" tag.
- $pattern = '|id="node-' . $nodes['es']->nid . '"[^<>]*lang="es" dir="ltr"|';
+ $pattern = '|id="node-' . $nodes['es']->id() . '"[^<>]*lang="es" dir="ltr"|';
$this->assertNoPattern($pattern, 'The dir tag has not been assigned to the Spanish node.');
}
@@ -230,8 +230,8 @@ function testNodeAdminLanguageFilter() {
// Verify filtering by language.
$this->drupalGet('admin/content', array('query' => array('langcode' => 'zh-hant')));
- $this->assertLinkByHref('node/' . $node_zh_hant->nid . '/edit');
- $this->assertNoLinkByHref('node/' . $node_en->nid . '/edit');
+ $this->assertLinkByHref('node/' . $node_zh_hant->id() . '/edit');
+ $this->assertNoLinkByHref('node/' . $node_en->id() . '/edit');
}
}
diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
index 77b27c8..847047f 100644
--- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
+++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php
@@ -78,7 +78,7 @@ function testPathLanguageConfiguration() {
$path = 'admin/config/search/path/add';
$english_path = $this->randomName(8);
$edit = array(
- 'source' => 'node/' . $node->nid,
+ 'source' => 'node/' . $node->id(),
'alias' => $english_path,
'langcode' => 'en',
);
@@ -87,7 +87,7 @@ function testPathLanguageConfiguration() {
// Create a path alias in new custom language.
$custom_language_path = $this->randomName(8);
$edit = array(
- 'source' => 'node/' . $node->nid,
+ 'source' => 'node/' . $node->id(),
'alias' => $custom_language_path,
'langcode' => $langcode,
);
@@ -106,15 +106,15 @@ function testPathLanguageConfiguration() {
// Check priority of language for alias by source path.
$edit = array(
- 'source' => 'node/' . $node->nid,
+ 'source' => 'node/' . $node->id(),
'alias' => $custom_path,
'langcode' => Language::LANGCODE_NOT_SPECIFIED,
);
$this->container->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']);
- $lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->nid, 'en');
+ $lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->id(), 'en');
$this->assertEqual($english_path, $lookup_path, t('English language alias has priority.'));
// Same check for language 'xx'.
- $lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->nid, $prefix);
+ $lookup_path = $this->container->get('path.alias_manager')->getPathAlias('node/' . $node->id(), $prefix);
$this->assertEqual($custom_language_path, $lookup_path, t('Custom language alias has priority.'));
$this->container->get('path.crud')->delete($edit);
@@ -124,7 +124,7 @@ function testPathLanguageConfiguration() {
// Assign a custom path alias to the first node with the English language.
$edit = array(
- 'source' => 'node/' . $first_node->nid,
+ 'source' => 'node/' . $first_node->id(),
'alias' => $custom_path,
'langcode' => 'en',
);
@@ -132,7 +132,7 @@ function testPathLanguageConfiguration() {
// Assign a custom path alias to second node with Language::LANGCODE_NOT_SPECIFIED.
$edit = array(
- 'source' => 'node/' . $second_node->nid,
+ 'source' => 'node/' . $second_node->id(),
'alias' => $custom_path,
'langcode' => Language::LANGCODE_NOT_SPECIFIED,
);
diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
index 4a9c187..29d0223 100644
--- a/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuNodeTest.php
@@ -77,7 +77,7 @@ function testMenuNodeFormWidget() {
$edit = array(
'menu[enabled]' => 1,
);
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save'));
// Assert that there is no link for the node.
$this->drupalGet('test-page');
$this->assertNoLink($node_title);
@@ -88,26 +88,26 @@ function testMenuNodeFormWidget() {
'menu[link_title]' => $node_title,
'menu[weight]' => 17,
);
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save'));
// Assert that the link exists.
$this->drupalGet('test-page');
$this->assertLink($node_title);
- $this->drupalGet('node/' . $node->nid . '/edit');
+ $this->drupalGet('node/' . $node->id() . '/edit');
$this->assertOptionSelected('edit-menu-weight', 17, 'Menu weight correct in edit form');
// Edit the node and remove the menu link.
$edit = array(
'menu[enabled]' => FALSE,
);
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save'));
// Assert that there is no link for the node.
$this->drupalGet('test-page');
$this->assertNoLink($node_title);
// Add a menu link to the Administration menu.
$item = entity_create('menu_link', array(
- 'link_path' => 'node/' . $node->nid,
+ 'link_path' => 'node/' . $node->id(),
'link_title' => $this->randomName(16),
'menu_name' => 'admin',
));
@@ -115,10 +115,10 @@ function testMenuNodeFormWidget() {
// Assert that disabled Administration menu is not shown on the
// node/$nid/edit page.
- $this->drupalGet('node/' . $node->nid . '/edit');
+ $this->drupalGet('node/' . $node->id() . '/edit');
$this->assertText('Provide a menu link', 'Link in not allowed menu not shown in node edit form');
// Assert that the link is still in the Administration menu after save.
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save'));
$link = menu_link_load($item['mlid']);
$this->assertTrue($link, 'Link in not allowed menu still exists after saving node');
@@ -129,13 +129,13 @@ function testMenuNodeFormWidget() {
$child_node = $this->drupalCreateNode(array('type' => 'article'));
// Assign a menu link to the second node, being a child of the first one.
$child_item = entity_create('menu_link', array(
- 'link_path' => 'node/'. $child_node->nid,
+ 'link_path' => 'node/'. $child_node->id(),
'link_title' => $this->randomName(16),
'plid' => $item['mlid'],
));
$child_item->save();
// Edit the first node.
- $this->drupalGet('node/'. $node->nid .'/edit');
+ $this->drupalGet('node/'. $node->id() .'/edit');
// Assert that it is not possible to set the parent of the first node to itself or the second node.
$this->assertNoOption('edit-menu-parent', 'tools:'. $item['mlid']);
$this->assertNoOption('edit-menu-parent', 'tools:'. $child_item['mlid']);
diff --git a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
index b914837..d91b8d5 100644
--- a/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
+++ b/core/modules/menu/lib/Drupal/menu/Tests/MenuTest.php
@@ -428,7 +428,7 @@ public function testMenuBundles() {
// Test if moving a menu link between menus changes the bundle.
$node = $this->drupalCreateNode(array('type' => 'article'));
- $item = $this->addMenuLink(0, 'node/' . $node->nid, 'tools');
+ $item = $this->addMenuLink(0, 'node/' . $node->id(), 'tools');
$this->moveMenuLink($item, 0, $menu->id());
$this->assertEqual($item->bundle(), 'tools', 'Menu link bundle matches the menu');
diff --git a/core/modules/menu/menu.module b/core/modules/menu/menu.module
index f3dd6c2..6f2ae11 100644
--- a/core/modules/menu/menu.module
+++ b/core/modules/menu/menu.module
@@ -459,7 +459,7 @@ function menu_node_save(EntityInterface $node) {
}
elseif (trim($link['link_title'])) {
$link['link_title'] = trim($link['link_title']);
- $link['link_path'] = "node/$node->nid";
+ $link['link_path'] = 'node/' . $node->id();
if (trim($link['description'])) {
$link['options']['attributes']['title'] = trim($link['description']);
}
@@ -481,7 +481,7 @@ function menu_node_save(EntityInterface $node) {
function menu_node_predelete(EntityInterface $node) {
// Delete all menu module links that point to this node.
$query = Drupal::entityQuery('menu_link')
- ->condition('link_path', 'node/' . $node->nid)
+ ->condition('link_path', 'node/' . $node->id())
->condition('module', 'menu');
$result = $query->execute();
@@ -496,15 +496,15 @@ 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->bundle(), 'main:0'), ':');
$menu_link = FALSE;
- if (isset($node->nid)) {
+ 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->bundle(), array('main' => 'main'));
if (in_array($menu_name, $type_menus)) {
$query = Drupal::entityQuery('menu_link')
- ->condition('link_path', 'node/' . $node->nid)
+ ->condition('link_path', 'node/' . $node->id())
->condition('menu_name', $menu_name)
->condition('module', 'menu')
->sort('mlid', 'ASC')
@@ -516,7 +516,7 @@ function menu_node_prepare_form(NodeInterface $node, $form_display, $operation,
// Check all allowed menus if a link does not exist in the default menu.
if (!$mlid && !empty($type_menus)) {
$query = Drupal::entityQuery('menu_link')
- ->condition('link_path', 'node/' . $node->nid)
+ ->condition('link_path', 'node/' . $node->id())
->condition('menu_name', array_values($type_menus), 'IN')
->condition('module', 'menu')
->sort('mlid', 'ASC')
@@ -565,7 +565,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->bundle();
$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 d7cfd2c..a5ec56b 100644
--- a/core/modules/node/lib/Drupal/node/NodeAccessController.php
+++ b/core/modules/node/lib/Drupal/node/NodeAccessController.php
@@ -35,19 +35,10 @@ public function access(EntityInterface $entity, $operation, $langcode = Language
* {@inheritdoc}
*/
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, FALSE)->status->value;
- $uid = $node->getTranslation($langcode, FALSE)->uid->value;
- }
-
// Check if authors can view their own unpublished nodes.
- if ($operation === 'view' && !$status && user_access('view own unpublished content', $account)) {
+ if ($operation === 'view' && !$node->isPublished() && user_access('view own unpublished content', $account)) {
- if ($account->id() != 0 && $account->id() == $uid) {
+ if ($account->id() != 0 && $account->id() == $node->getAuthorId()) {
return TRUE;
}
}
@@ -61,7 +52,7 @@ protected function checkAccess(EntityInterface $node, $operation, $langcode, Acc
// If no modules implement hook_node_grants(), the default behavior is to
// allow all users to view published nodes, so reflect that here.
if ($operation === 'view') {
- return $status;
+ return $node->isPublished();
}
}
@@ -101,7 +92,7 @@ protected function accessGrants(EntityInterface $node, $operation, $langcode, Ac
->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 = db_or()
->condition($nids)
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index e55e056..b003e02 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -39,7 +39,7 @@ protected function prepareEntity() {
);
// If this is a new node, fill in the default values.
- if (!isset($node->nid) || isset($node->is_new)) {
+ if ($node->isNew()) {
foreach (array('status', 'promote', 'sticky') as $key) {
// Multistep node forms might have filled in something already.
if (!isset($node->$key)) {
@@ -47,11 +47,11 @@ protected function prepareEntity() {
}
}
global $user;
- $node->uid = $user->uid;
- $node->created = REQUEST_TIME;
+ $node->setAuthorId($user->uid);
+ $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->bundle() . '-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->bundle());
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->bundle());
$form['langcode'] = array(
'#title' => t('Language'),
'#type' => 'language_select',
- '#default_value' => $node->langcode,
+ '#default_value' => $node->language()->langcode,
'#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 (isset($node->nid) && (node_last_changed($node->nid, $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;
}
@@ -434,10 +434,10 @@ public function unpublish(array $form, array &$form_state) {
*/
public function save(array $form, array &$form_state) {
$node = $this->entity;
- $insert = empty($node->nid);
+ $insert = $node->isNew();
$node->save();
- $node_link = l(t('view'), 'node/' . $node->nid);
- $watchdog_args = array('@type' => $node->type, '%title' => $node->label());
+ $node_link = l(t('view'), 'node/' . $node->id());
+ $watchdog_args = array('@type' => $node->bundle(), '%title' => $node->label());
$t_args = array('@type' => node_get_type_label($node), '%title' => $node->label());
if ($insert) {
@@ -449,10 +449,10 @@ public function save(array $form, array &$form_state) {
drupal_set_message(t('@type %title has been updated.', $t_args));
}
- if ($node->nid) {
- $form_state['values']['nid'] = $node->nid;
- $form_state['nid'] = $node->nid;
- $form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->nid : '
';
+ if ($node->id()) {
+ $form_state['values']['nid'] = $node->id();
+ $form_state['nid'] = $node->id();
+ $form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->id() : '';
}
else {
// In the unlikely case something went wrong on save, the node will be
@@ -476,7 +476,7 @@ public function delete(array $form, array &$form_state) {
$query->remove('destination');
}
$node = $this->entity;
- $form_state['redirect'] = array('node/' . $node->nid . '/delete', array('query' => $destination));
+ $form_state['redirect'] = array('node/' . $node->id() . '/delete', array('query' => $destination));
}
}
diff --git a/core/modules/node/lib/Drupal/node/NodeRenderController.php b/core/modules/node/lib/Drupal/node/NodeRenderController.php
index a58a96f..e5101b9 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 about @title', array(
'@title' => $node_title_stripped,
)),
- 'href' => 'node/' . $entity->nid,
+ 'href' => 'node/' . $entity->id(),
'html' => TRUE,
'attributes' => array(
'rel' => 'tag',
@@ -82,8 +82,8 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $entity, $display, $view_mode, $langcode);
- if (!empty($entity->nid)) {
- $build['#contextual_links']['node'] = array('node', array($entity->nid));
+ if ($entity->id()) {
+ $build['#contextual_links']['node'] = array('node', array($entity->id()));
}
}
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 7676a76..2ea28b7 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(TRUE);
$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 56f8658..0b87b38 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 2d0f4ed..669e97b 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 4f30bb7..417bdd7 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->bundle(), $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 b8451b8..0d7ed4b 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
@@ -262,7 +262,12 @@ public function setRevisionCreationTime($timestamp) {
* {@inheritdoc}
*/
public function getRevisionAuthor() {
- return $this->get('revision_uid')->entity;
+ $entity = $this->get('revision_uid')->entity;
+ // If no user is given, default to the anonymous user.
+ if (!$entity) {
+ return user_load(0)->getBCentity();
+ }
+ return $entity->getBCEntity();
}
/**
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/argument_default/Node.php b/core/modules/node/lib/Drupal/node/Plugin/views/argument_default/Node.php
index f35eb9e..6886332 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/argument_default/Node.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/argument_default/Node.php
@@ -28,7 +28,7 @@ public function getArgument() {
foreach (range(1, 3) as $i) {
$node = menu_get_object('node', $i);
if (!empty($node)) {
- return $node->nid;
+ return $node->id();
}
}
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 0234629..12b43ce 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->bundle()]);
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->bundle()])) {
return FALSE;
}
@@ -132,7 +132,7 @@ public function validateArgument($argument) {
}
$titles[] = check_plain($node->label());
- unset($test[$node->nid]);
+ unset($test[$node->id()]);
}
$this->argument->validated_title = implode($nids->operator == 'or' ? ' + ' : ', ', $titles);
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php
index 8327bcf..dedf3b1 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php
@@ -54,7 +54,7 @@ function render($values) {
function render_link($node, $values) {
if (node_access('view', $node)) {
$this->options['alter']['make_link'] = TRUE;
- $this->options['alter']['path'] = "node/$node->nid";
+ $this->options['alter']['path'] = 'node/' . $node->id();
$text = !empty($this->options['text']) ? $this->options['text'] : t('view');
return $text;
}
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php
index 51cc3fe..57000a0 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php
@@ -29,7 +29,7 @@ function render_link($node, $values) {
}
$this->options['alter']['make_link'] = TRUE;
- $this->options['alter']['path'] = "node/$node->nid/delete";
+ $this->options['alter']['path'] = 'node/' . $node->id() . '/delete';
$this->options['alter']['query'] = drupal_get_destination();
$text = !empty($this->options['text']) ? $this->options['text'] : t('delete');
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 2a69d13..e7d7240 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
@@ -29,7 +29,7 @@ function render_link($node, $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 5df4452..4c5a3c1 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
@@ -69,7 +69,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/field/RevisionLinkDelete.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkDelete.php
index 2ffb49c..1d68115 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkDelete.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkDelete.php
@@ -35,7 +35,7 @@ function render_link($data, $values) {
}
$this->options['alter']['make_link'] = TRUE;
- $this->options['alter']['path'] = 'node/' . $node->nid . "/revisions/$vid/delete";
+ $this->options['alter']['path'] = 'node/' . $node->id() . "/revisions/$vid/delete";
$this->options['alter']['query'] = drupal_get_destination();
return !empty($this->options['text']) ? $this->options['text'] : t('Delete');
diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php
index 8f9671c..19f93ad 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php
@@ -35,7 +35,7 @@ function render_link($data, $values) {
}
$this->options['alter']['make_link'] = TRUE;
- $this->options['alter']['path'] = 'node/' . $node->nid . "/revisions/$vid/revert";
+ $this->options['alter']['path'] = 'node/' . $node->id() . "/revisions/$vid/revert";
$this->options['alter']['query'] = drupal_get_destination();
return !empty($this->options['text']) ? $this->options['text'] : t('Revert');
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 49cc52a..b60860c 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 @@ function render($row) {
$node->rss_elements = array(
array(
'key' => 'pubDate',
- 'value' => gmdate('r', $node->created),
+ 'value' => gmdate('r', $node->getCreatedTime()),
),
array(
'key' => 'dc:creator',
@@ -125,7 +125,7 @@ function render($row) {
),
array(
'key' => 'guid',
- 'value' => $node->nid . ' at ' . $base_url,
+ 'value' => $node->id() . ' at ' . $base_url,
'attributes' => array('isPermaLink' => 'false'),
),
);
@@ -167,7 +167,7 @@ function render($row) {
$item->title = $node->label();
$item->link = $node->link;
$item->elements = $node->rss_elements;
- $item->nid = $node->nid;
+ $item->id = $node->nid;
$theme_function = array(
'#theme' => $this->themeFunctions(),
'#view' => $this->view,
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
index e1a33aa..de2bb99 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessFieldTest.php
@@ -90,7 +90,7 @@ function testNodeAccessAdministerField() {
// Log in as the administrator and confirm that the field value is present.
$this->drupalLogin($this->admin_user);
- $this->drupalGet("node/{$node->nid}");
+ $this->drupalGet("node/" . $node->id());
$this->assertText($value, 'The saved field value is visible to an administrator.');
// Log in as the content admin and try to view the node.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php
index d613cc4..56f29f2 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php
@@ -259,10 +259,10 @@ function testNodeAccessLanguageAwareCombination() {
// Four nodes should be returned with public Hungarian translations or the
// no language public node.
$this->assertEqual(count($nids), 4, 'db_select() returns 4 nodes when no langcode is specified.');
- $this->assertTrue(array_key_exists($this->nodes['public_both_public']->nid, $nids), 'Returned node ID is full public node.');
- $this->assertTrue(array_key_exists($this->nodes['public_ca_private']->nid, $nids), 'Returned node ID is Hungarian public only node.');
- $this->assertTrue(array_key_exists($this->nodes['private_both_public']->nid, $nids), 'Returned node ID is both public non-language-aware private only node.');
- $this->assertTrue(array_key_exists($this->nodes['public_no_language_public']->nid, $nids), 'Returned node ID is no language public node.');
+ $this->assertTrue(array_key_exists($this->nodes['public_both_public']->id(), $nids), 'Returned node ID is full public node.');
+ $this->assertTrue(array_key_exists($this->nodes['public_ca_private']->id(), $nids), 'Returned node ID is Hungarian public only node.');
+ $this->assertTrue(array_key_exists($this->nodes['private_both_public']->id(), $nids), 'Returned node ID is both public non-language-aware private only node.');
+ $this->assertTrue(array_key_exists($this->nodes['public_no_language_public']->id(), $nids), 'Returned node ID is no language public node.');
// Query with Hungarian (hu) specified.
$select = db_select('node', 'n')
@@ -274,9 +274,9 @@ function testNodeAccessLanguageAwareCombination() {
// Three nodes should be returned (with public Hungarian translations).
$this->assertEqual(count($nids), 3, 'db_select() returns 3 nodes.');
- $this->assertTrue(array_key_exists($this->nodes['public_both_public']->nid, $nids), 'Returned node ID is both public node.');
- $this->assertTrue(array_key_exists($this->nodes['public_ca_private']->nid, $nids), 'Returned node ID is Hungarian public only node.');
- $this->assertTrue(array_key_exists($this->nodes['private_both_public']->nid, $nids), 'Returned node ID is both public non-language-aware private only node.');
+ $this->assertTrue(array_key_exists($this->nodes['public_both_public']->id(), $nids), 'Returned node ID is both public node.');
+ $this->assertTrue(array_key_exists($this->nodes['public_ca_private']->id(), $nids), 'Returned node ID is Hungarian public only node.');
+ $this->assertTrue(array_key_exists($this->nodes['private_both_public']->id(), $nids), 'Returned node ID is both public non-language-aware private only node.');
// Query with Catalan (ca) specified.
$select = db_select('node', 'n')
@@ -288,9 +288,9 @@ function testNodeAccessLanguageAwareCombination() {
// Three nodes should be returned (with public Catalan translations).
$this->assertEqual(count($nids), 3, 'db_select() returns 3 nodes.');
- $this->assertTrue(array_key_exists($this->nodes['public_both_public']->nid, $nids), 'Returned node ID is both public node.');
- $this->assertTrue(array_key_exists($this->nodes['public_hu_private']->nid, $nids), 'Returned node ID is Catalan public only node.');
- $this->assertTrue(array_key_exists($this->nodes['private_both_public']->nid, $nids), 'Returned node ID is both public non-language-aware private only node.');
+ $this->assertTrue(array_key_exists($this->nodes['public_both_public']->id(), $nids), 'Returned node ID is both public node.');
+ $this->assertTrue(array_key_exists($this->nodes['public_hu_private']->id(), $nids), 'Returned node ID is Catalan public only node.');
+ $this->assertTrue(array_key_exists($this->nodes['private_both_public']->id(), $nids), 'Returned node ID is both public non-language-aware private only node.');
// Query with German (de) specified.
$select = db_select('node', 'n')
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php
index be89d79..e794eb1 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php
@@ -200,9 +200,9 @@ function testNodeAccessLanguageAware() {
// - Node with only the Catalan translation marked as private.
// - No language node marked as public.
$this->assertEqual(count($nids), 3, 'db_select() returns 3 nodes when no langcode is specified.');
- $this->assertTrue(array_key_exists($this->nodes['both_public']->nid, $nids), 'The node with both translations public is returned.');
- $this->assertTrue(array_key_exists($this->nodes['ca_private']->nid, $nids), 'The node with only the Catalan translation private is returned.');
- $this->assertTrue(array_key_exists($this->nodes['no_language_public']->nid, $nids), 'The node with no language is returned.');
+ $this->assertTrue(array_key_exists($this->nodes['both_public']->id(), $nids), 'The node with both translations public is returned.');
+ $this->assertTrue(array_key_exists($this->nodes['ca_private']->id(), $nids), 'The node with only the Catalan translation private is returned.');
+ $this->assertTrue(array_key_exists($this->nodes['no_language_public']->id(), $nids), 'The node with no language is returned.');
// Query with Hungarian (hu) specified.
$select = db_select('node', 'n')
@@ -215,8 +215,8 @@ function testNodeAccessLanguageAware() {
// Two nodes should be returned: the node with both translations public, and
// the node with only the Catalan translation marked as private.
$this->assertEqual(count($nids), 2, 'db_select() returns 2 nodes when the hu langcode is specified.');
- $this->assertTrue(array_key_exists($this->nodes['both_public']->nid, $nids), 'The node with both translations public is returned.');
- $this->assertTrue(array_key_exists($this->nodes['ca_private']->nid, $nids), 'The node with only the Catalan translation private is returned.');
+ $this->assertTrue(array_key_exists($this->nodes['both_public']->id(), $nids), 'The node with both translations public is returned.');
+ $this->assertTrue(array_key_exists($this->nodes['ca_private']->id(), $nids), 'The node with only the Catalan translation private is returned.');
// Query with Catalan (ca) specified.
$select = db_select('node', 'n')
@@ -229,8 +229,8 @@ function testNodeAccessLanguageAware() {
// Two nodes should be returned: the node with both translations public, and
// the node with only the Hungarian translation marked as private.
$this->assertEqual(count($nids), 2, 'db_select() returns 2 nodes when the hu langcode is specified.');
- $this->assertTrue(array_key_exists($this->nodes['both_public']->nid, $nids), 'The node with both translations public is returned.');
- $this->assertTrue(array_key_exists($this->nodes['hu_private']->nid, $nids), 'The node with only the Hungarian translation private is returned.');
+ $this->assertTrue(array_key_exists($this->nodes['both_public']->id(), $nids), 'The node with both translations public is returned.');
+ $this->assertTrue(array_key_exists($this->nodes['hu_private']->id(), $nids), 'The node with only the Hungarian translation private is returned.');
// Query with German (de) specified.
$select = db_select('node', 'n')
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
index 7e7c70a..f347927 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php
@@ -113,7 +113,7 @@ 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()->langcode == '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);
@@ -202,8 +202,8 @@ function testNodeAccessQueryTag() {
// The public node and no language node should be returned. Because no
// langcode is given it will use the fallback node.
$this->assertEqual(count($nids), 2, 'db_select() returns 2 node');
- $this->assertTrue(array_key_exists($node_public->nid, $nids), 'Returned node ID is public node.');
- $this->assertTrue(array_key_exists($node_no_language->nid, $nids), 'Returned node ID is no language node.');
+ $this->assertTrue(array_key_exists($node_public->id(), $nids), 'Returned node ID is public node.');
+ $this->assertTrue(array_key_exists($node_no_language->id(), $nids), 'Returned node ID is no language node.');
// Query the nodes table as the web user with the node access tag and
// langcode de.
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
index 6063677..7b2cfe3 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php
@@ -47,7 +47,7 @@ public function testCommentPager() {
// Create 60 comments.
for ($i = 0; $i < 60; $i++) {
$comment = entity_create('comment', array(
- 'nid' => $node->nid,
+ 'nid' => $node->id(),
'node_type' => 'node_type_' . $node->bundle(),
'subject' => $this->randomName(),
'comment_body' => array(
@@ -61,7 +61,7 @@ public function testCommentPager() {
// View the node page. With the default 50 comments per page there should
// be two pages (0, 1) but no third (2) page.
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$this->assertText($node->label());
$this->assertText(t('Comments'));
$this->assertRaw('page=1');
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
index e2b4c07..0cd54af 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessRecordsTest.php
@@ -33,41 +33,41 @@ public static function getInfo() {
function testNodeAccessRecords() {
// Create an article node.
$node1 = $this->drupalCreateNode(array('type' => 'article'));
- $this->assertTrue(node_load($node1->nid), 'Article node created.');
+ $this->assertTrue(node_load($node1->id()), 'Article node created.');
// Check to see if grants added by node_test_node_access_records made it in.
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node1->nid))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node1->id()))->fetchAll();
$this->assertEqual(count($records), 1, 'Returned the correct number of rows.');
$this->assertEqual($records[0]->realm, 'test_article_realm', 'Grant with article_realm acquired for node without alteration.');
$this->assertEqual($records[0]->gid, 1, 'Grant with gid = 1 acquired for node without alteration.');
// Create an unpromoted "Basic page" node.
$node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 0));
- $this->assertTrue(node_load($node2->nid), 'Unpromoted basic page node created.');
+ $this->assertTrue(node_load($node2->id()), 'Unpromoted basic page node created.');
// Check to see if grants added by node_test_node_access_records made it in.
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node2->nid))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node2->id()))->fetchAll();
$this->assertEqual(count($records), 1, 'Returned the correct number of rows.');
$this->assertEqual($records[0]->realm, 'test_page_realm', 'Grant with page_realm acquired for node without alteration.');
$this->assertEqual($records[0]->gid, 1, 'Grant with gid = 1 acquired for node without alteration.');
// Create an unpromoted, unpublished "Basic page" node.
$node3 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 0, 'status' => 0));
- $this->assertTrue(node_load($node3->nid), 'Unpromoted, unpublished basic page node created.');
+ $this->assertTrue(node_load($node3->id()), 'Unpromoted, unpublished basic page node created.');
// Check to see if grants added by node_test_node_access_records made it in.
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node3->nid))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node3->id()))->fetchAll();
$this->assertEqual(count($records), 1, 'Returned the correct number of rows.');
$this->assertEqual($records[0]->realm, 'test_page_realm', 'Grant with page_realm acquired for node without alteration.');
$this->assertEqual($records[0]->gid, 1, 'Grant with gid = 1 acquired for node without alteration.');
// Create a promoted "Basic page" node.
$node4 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
- $this->assertTrue(node_load($node4->nid), 'Promoted basic page node created.');
+ $this->assertTrue(node_load($node4->id()), 'Promoted basic page node created.');
// Check to see if grant added by node_test_node_access_records was altered
// by node_test_node_access_records_alter.
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node4->nid))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node4->id()))->fetchAll();
$this->assertEqual(count($records), 1, 'Returned the correct number of rows.');
$this->assertEqual($records[0]->realm, 'test_alter_realm', 'Altered grant with alter_realm acquired for node.');
$this->assertEqual($records[0]->gid, 2, 'Altered grant with gid = 2 acquired for node.');
@@ -86,7 +86,7 @@ function testNodeAccessRecords() {
// Check that core does not grant access to an unpublished node when an
// empty $grants array is returned.
$node6 = $this->drupalCreateNode(array('status' => 0, 'disable_node_access' => TRUE));
- $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node6->nid))->fetchAll();
+ $records = db_query('SELECT realm, gid FROM {node_access} WHERE nid = :nid', array(':nid' => $node6->id()))->fetchAll();
$this->assertEqual(count($records), 0, 'Returned no records for unpublished node.');
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
index 6ad8a19..2413c23 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php
@@ -103,61 +103,61 @@ function testContentAdminPages() {
$this->drupalGet('admin/content');
$this->assertResponse(200);
foreach ($nodes as $node) {
- $this->assertLinkByHref('node/' . $node->nid);
- $this->assertLinkByHref('node/' . $node->nid . '/edit');
- $this->assertLinkByHref('node/' . $node->nid . '/delete');
+ $this->assertLinkByHref('node/' . $node->id());
+ $this->assertLinkByHref('node/' . $node->id() . '/edit');
+ $this->assertLinkByHref('node/' . $node->id() . '/delete');
}
// Verify filtering by publishing status.
$this->drupalGet('admin/content', array('query' => array('status' => TRUE)));
- $this->assertLinkByHref('node/' . $nodes['published_page']->nid . '/edit');
- $this->assertLinkByHref('node/' . $nodes['published_article']->nid . '/edit');
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->nid . '/edit');
+ $this->assertLinkByHref('node/' . $nodes['published_page']->id() . '/edit');
+ $this->assertLinkByHref('node/' . $nodes['published_article']->id() . '/edit');
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/edit');
// Verify filtering by status and content type.
$this->drupalGet('admin/content', array('query' => array('status' => TRUE, 'type' => 'page')));
- $this->assertLinkByHref('node/' . $nodes['published_page']->nid . '/edit');
- $this->assertNoLinkByHref('node/' . $nodes['published_article']->nid . '/edit');
+ $this->assertLinkByHref('node/' . $nodes['published_page']->id() . '/edit');
+ $this->assertNoLinkByHref('node/' . $nodes['published_article']->id() . '/edit');
// Verify no operation links are displayed for regular users.
$this->drupalLogout();
$this->drupalLogin($this->base_user_1);
$this->drupalGet('admin/content');
$this->assertResponse(200);
- $this->assertLinkByHref('node/' . $nodes['published_page']->nid);
- $this->assertLinkByHref('node/' . $nodes['published_article']->nid);
- $this->assertNoLinkByHref('node/' . $nodes['published_page']->nid . '/edit');
- $this->assertNoLinkByHref('node/' . $nodes['published_page']->nid . '/delete');
- $this->assertNoLinkByHref('node/' . $nodes['published_article']->nid . '/edit');
- $this->assertNoLinkByHref('node/' . $nodes['published_article']->nid . '/delete');
+ $this->assertLinkByHref('node/' . $nodes['published_page']->id());
+ $this->assertLinkByHref('node/' . $nodes['published_article']->id());
+ $this->assertNoLinkByHref('node/' . $nodes['published_page']->id() . '/edit');
+ $this->assertNoLinkByHref('node/' . $nodes['published_page']->id() . '/delete');
+ $this->assertNoLinkByHref('node/' . $nodes['published_article']->id() . '/edit');
+ $this->assertNoLinkByHref('node/' . $nodes['published_article']->id() . '/delete');
// Verify no unpublished content is displayed without permission.
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->nid);
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->nid . '/edit');
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->nid . '/delete');
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id());
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/edit');
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/delete');
// Verify no tableselect.
- $this->assertNoFieldByName('nodes[' . $nodes['published_page']->nid . ']', '', 'No tableselect found.');
+ $this->assertNoFieldByName('nodes[' . $nodes['published_page']->id() . ']', '', 'No tableselect found.');
// Verify unpublished content is displayed with permission.
$this->drupalLogout();
$this->drupalLogin($this->base_user_2);
$this->drupalGet('admin/content');
$this->assertResponse(200);
- $this->assertLinkByHref('node/' . $nodes['unpublished_page_2']->nid);
+ $this->assertLinkByHref('node/' . $nodes['unpublished_page_2']->id());
// Verify no operation links are displayed.
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_2']->nid . '/edit');
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_2']->nid . '/delete');
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_2']->id() . '/edit');
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_2']->id() . '/delete');
// Verify user cannot see unpublished content of other users.
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->nid);
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->nid . '/edit');
- $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->nid . '/delete');
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id());
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/edit');
+ $this->assertNoLinkByHref('node/' . $nodes['unpublished_page_1']->id() . '/delete');
// Verify no tableselect.
- $this->assertNoFieldByName('nodes[' . $nodes['unpublished_page_2']->nid . ']', '', 'No tableselect found.');
+ $this->assertNoFieldByName('nodes[' . $nodes['unpublished_page_2']->id() . ']', '', 'No tableselect found.');
// Verify node access can be bypassed.
$this->drupalLogout();
@@ -165,9 +165,9 @@ function testContentAdminPages() {
$this->drupalGet('admin/content');
$this->assertResponse(200);
foreach ($nodes as $node) {
- $this->assertLinkByHref('node/' . $node->nid);
- $this->assertLinkByHref('node/' . $node->nid . '/edit');
- $this->assertLinkByHref('node/' . $node->nid . '/delete');
+ $this->assertLinkByHref('node/' . $node->id());
+ $this->assertLinkByHref('node/' . $node->id() . '/edit');
+ $this->assertLinkByHref('node/' . $node->id() . '/delete');
}
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
index 8d95c06..3f6d336 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php
@@ -78,13 +78,13 @@ public function testRecentNodeBlock() {
->fields(array(
'changed' => $node1->changed + 100,
))
- ->condition('nid', $node2->nid)
+ ->condition('nid', $node2->id())
->execute();
db_update('node_field_data')
->fields(array(
'changed' => $node1->changed + 200,
))
- ->condition('nid', $node3->nid)
+ ->condition('nid', $node3->id())
->execute();
// Test that a user without the 'access content' permission cannot
@@ -144,9 +144,9 @@ public function testRecentNodeBlock() {
$this->assertNoText($label, 'Block was not displayed on the front page.');
$this->drupalGet('node/add/article');
$this->assertText($label, 'Block was displayed on the node/add/article page.');
- $this->drupalGet('node/' . $node1->nid);
+ $this->drupalGet('node/' . $node1->id());
$this->assertText($label, 'Block was displayed on the node/N when node is of type article.');
- $this->drupalGet('node/' . $node5->nid);
+ $this->drupalGet('node/' . $node5->id());
$this->assertNoText($label, 'Block was not displayed on nodes of type page.');
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
index eef7948..6494b40 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeEntityViewModeAlterTest.php
@@ -46,7 +46,7 @@ function testNodeViewModeChange() {
// Set the flag to alter the view mode and view the node.
\Drupal::state()->set('node_test_change_view_mode', 'teaser');
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
// Check that teaser mode is viewed.
$this->assertText('Extra data that should appear only in the teaser for the node.', 'Teaser text present');
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
index e9447ec..f70155d 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php
@@ -131,9 +131,9 @@ function testMultilingualDisplaySettings() {
$this->assertTrue($node, 'Node found in database.');
// Check if node body is showed.
- $this->drupalGet("node/$node->nid");
+ $this->drupalGet('node/' . $node->id());
$body = $this->xpath('//article[@id=:id]//div[@class=:class]/descendant::p', array(
- ':id' => 'node-' . $node->nid,
+ ':id' => 'node-' . $node->id(),
':class' => 'content',
));
$this->assertEqual(current($body), $node->body['en'][0]['value'], 'Node body found.');
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php
index a592c88..b52d825 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeFormButtonsTest.php
@@ -55,7 +55,7 @@ function testNodeFormButtons() {
$this->assertEqual(1, $node_1->status, 'Node is published');
// Verify the buttons on a node edit form.
- $this->drupalGet('node/' . $node_1->nid . '/edit');
+ $this->drupalGet('node/' . $node_1->id() . '/edit');
$this->assertButtons(array(t('Save and keep published'), t('Save and unpublish')));
// Save the node and verify it's still published after clicking
@@ -66,12 +66,12 @@ function testNodeFormButtons() {
// Save the node and verify it's unpublished after clicking
// 'Save and unpublish'.
- $this->drupalPost('node/' . $node_1->nid . '/edit', $edit, t('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');
// Verify the buttons on an unpublished node edit screen.
- $this->drupalGet('node/' . $node_1->nid . '/edit');
+ $this->drupalGet('node/' . $node_1->id() . '/edit');
$this->assertButtons(array(t('Save and keep unpublished'), t('Save and publish')));
// Create a node as a normal user.
@@ -92,7 +92,7 @@ function testNodeFormButtons() {
// was created by the normal user.
$this->drupalLogout();
$this->drupalLogin($this->admin_user);
- $this->drupalPost('node/' . $node_2->nid . '/edit', array(), t('Save and unpublish'));
+ $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');
@@ -100,7 +100,7 @@ function testNodeFormButtons() {
// it's still unpublished.
$this->drupalLogout();
$this->drupalLogin($this->web_user);
- $this->drupalPost('node/' . $node_2->nid . '/edit', array(), t('Save'));
+ $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->drupalLogout();
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeLoadHooksTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeLoadHooksTest.php
index 51dad74..113eeed 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeLoadHooksTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeLoadHooksTest.php
@@ -42,7 +42,7 @@ function testHookNodeLoad() {
// reflect the expected values.
$nodes = entity_load_multiple_by_properties('node', array('status' => NODE_PUBLISHED));
$loaded_node = end($nodes);
- $this->assertEqual($loaded_node->node_test_loaded_nids, array($node1->nid, $node2->nid), 'hook_node_load() received the correct list of node IDs the first time it was called.');
+ $this->assertEqual($loaded_node->node_test_loaded_nids, array($node1->nid, $node2->id()), 'hook_node_load() received the correct list of node IDs the first time it was called.');
$this->assertEqual($loaded_node->node_test_loaded_types, array('article'), 'hook_node_load() received the correct list of node types the first time it was called.');
// Now, as part of the same page request, load a set of nodes that contain
@@ -50,7 +50,7 @@ function testHookNodeLoad() {
// node_test_node_load() are correctly updated.
$nodes = entity_load_multiple_by_properties('node', array('status' => NODE_NOT_PUBLISHED));
$loaded_node = end($nodes);
- $this->assertEqual($loaded_node->node_test_loaded_nids, array($node3->nid, $node4->nid), 'hook_node_load() received the correct list of node IDs the second time it was called.');
+ $this->assertEqual($loaded_node->node_test_loaded_nids, array($node3->nid, $node4->id()), 'hook_node_load() received the correct list of node IDs the second time it was called.');
$this->assertEqual($loaded_node->node_test_loaded_types, array('article', 'page'), 'hook_node_load() received the correct list of node types the second time it was called.');
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRSSContentTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRSSContentTest.php
index 34b35ae..5357899 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeRSSContentTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeRSSContentTest.php
@@ -51,18 +51,18 @@ function testNodeRSSContent() {
$this->drupalGet('rss.xml');
// Check that content added in 'rss' view mode appear in RSS feed.
- $rss_only_content = t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->nid));
+ $rss_only_content = t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->id()));
$this->assertText($rss_only_content, 'Node content designated for RSS appear in RSS feed.');
// Check that content added in view modes other than 'rss' doesn't
// appear in RSS feed.
- $non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->nid));
+ $non_rss_content = t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->id()));
$this->assertNoText($non_rss_content, 'Node content not designed for RSS does not appear in RSS feed.');
// Check that extra RSS elements and namespaces are added to RSS feed.
$test_element = array(
'key' => 'testElement',
- 'value' => t('Value of testElement RSS element for node !nid.', array('!nid' => $node->nid)),
+ 'value' => t('Value of testElement RSS element for node !nid.', array('!nid' => $node->id())),
);
$test_ns = 'xmlns:drupaltest="http://example.com/test-namespace"';
$this->assertRaw(format_xml_elements(array($test_element)), 'Extra RSS elements appear in RSS feed.');
@@ -70,7 +70,7 @@ function testNodeRSSContent() {
// Check that content added in 'rss' view mode doesn't appear when
// viewing node.
- $this->drupalGet("node/$node->nid");
+ $this->drupalGet('node/' . $node->id());
$this->assertNoText($rss_only_content, 'Node content designed for RSS does not appear when viewing node.');
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php
index e0db862..3bcf362 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionPermissionsTest.php
@@ -98,7 +98,7 @@ function testNodeRevisionAccessAnyType() {
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
- if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $revision->nid))->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
+ if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $revision->id()))->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || user_access($this->map[$case['op']], $case['account'])) {
$this->assertTrue(_node_revision_access($revision, $case['op'], $case['account']), "{$this->map[$case['op']]} granted.");
}
@@ -144,7 +144,7 @@ function testNodeRevisionAccessPerType() {
$permutations = $this->generatePermutations($parameters);
foreach ($permutations as $case) {
// Skip this test if there are no revisions for the node.
- if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $revision->nid))->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
+ if (!($revision->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $revision->id()))->fetchField() == 1 || $case['op'] == 'update' || $case['op'] == 'delete'))) {
if (!empty($case['account']->is_admin) || user_access($this->type_map[$case['op']], $case['account'])) {
$this->assertTrue(_node_revision_access($revision, $case['op'], $case['account']), "{$this->type_map[$case['op']]} granted.");
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php
index 67cf0b5..e1aa05d 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsAllTestCase.php
@@ -66,7 +66,7 @@ function setUp() {
$node->setNewRevision();
$node->save();
- $node = node_load($node->nid, TRUE); // Make sure we get revision information.
+ $node = node_load($node->id(), TRUE); // Make sure we get revision information.
$nodes[] = clone $node;
}
@@ -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'], t('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, t('Log message found.'));
}
@@ -110,7 +110,7 @@ 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]->id() . "/revert", array(), t('Revert'));
$this->assertRaw(t('@type %title has been reverted back to the revision from %revision-date.',
array(
'@type' => 'Basic page',
@@ -118,15 +118,15 @@ function testRevisions() {
'%revision-date' => format_date($nodes[1]->revision_timestamp)
)),
'Revision reverted.');
- $reverted_node = node_load($node->nid, TRUE);
+ $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']), t('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),
@@ -135,19 +135,19 @@ function testRevisions() {
)),
'Revision deleted.');
$this->assertTrue(db_query('SELECT COUNT(vid) FROM {node_field_revision} WHERE nid = :nid and vid = :vid',
- array(':nid' => $node->nid, ':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,
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
index 640175a..1e47592 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php
@@ -66,7 +66,7 @@ function setUp() {
$node->setNewRevision();
$node->save();
- $node = node_load($node->nid); // Make sure we get revision information.
+ $node = node_load($node->id()); // Make sure we get revision information.
$nodes[] = clone $node;
}
@@ -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.');
- $reverted_node = node_load($node->nid, TRUE);
+ $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),
'@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->nid, ':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(),
@@ -142,22 +142,22 @@ function testRevisions() {
$new_node_revision->isDefaultRevision = FALSE;
$new_node_revision->save();
- $this->drupalGet("node/$node->nid");
+ $this->drupalGet('node/' . $node->id());
$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
// revision vid.
$default_revision = db_select('node', 'n')
->fields('n', array('vid'))
- ->condition('nid', $node->nid)
+ ->condition('nid', $node->id())
->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.');
}
/**
@@ -180,9 +180,9 @@ function testNodeRevisionWithoutLogMessage() {
$node->setNewRevision(FALSE);
$node->save();
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$this->assertText($new_title, 'New node title appears on the page.');
- $node_revision = node_load($node->nid, TRUE);
+ $node_revision = node_load($node->id(), TRUE);
$this->assertEqual($node_revision->log, $log, 'After an existing node revision is re-saved without a log message, the original log message is preserved.');
// Create another node with an initial log message.
@@ -198,9 +198,9 @@ function testNodeRevisionWithoutLogMessage() {
$node->log = NULL;
$node->save();
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$this->assertText($new_title, 'New node title appears on the page.');
- $node_revision = node_load($node->nid, TRUE);
+ $node_revision = node_load($node->id(), TRUE);
$this->assertTrue(empty($node_revision->log), 'After a new node revision is saved with an empty log message, the log message for the node is empty.');
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeSaveTest.php
index 6157fb0..9b4401a 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->uid, '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.');
}
/**
@@ -155,7 +155,7 @@ function testDeterminingChanges() {
$this->assertEqual($node->label(), 'updated_presave_update', 'Changes have been determined.');
// Test the static node load cache to be cleared.
- $node = node_load($node->nid);
+ $node = node_load($node->id());
$this->assertEqual($node->label(), 'updated_presave', 'Static cache has been cleared.');
}
@@ -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->nid, 'Node saved on node insert.');
+ $this->assertEqual($node->label(), 'Node ' . $node->id(), 'Node saved on node insert.');
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
index e03e4b0..e2b550b 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
@@ -49,7 +49,7 @@ function testNodeTitle() {
$node = $this->drupalCreateNode($settings);
// Test tag.
- $this->drupalGet("node/$node->nid");
+ $this->drupalGet('node/' . $node->id());
$xpath = '//title';
$this->assertEqual(current($this->xpath($xpath)), $node->label() .' | Drupal', 'Page title is equal to node title.', 'Node');
@@ -59,7 +59,7 @@ function testNodeTitle() {
$this->assertEqual(current($this->xpath($xpath)), $node->label(), 'Node breadcrumb is equal to node title.', 'Node');
// Test node title in comment preview.
- $this->assertEqual(current($this->xpath('//article[@id=:id]/h2/a', array(':id' => 'node-' . $node->nid))), $node->label(), 'Node preview title is equal to node title.', 'Node');
+ $this->assertEqual(current($this->xpath('//article[@id=:id]/h2/a', array(':id' => 'node-' . $node->id()))), $node->label(), 'Node preview title is equal to node title.', 'Node');
// Test node title is clickable on teaser list (/node).
$this->drupalGet('node');
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTitleXSSTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTitleXSSTest.php
index 8810f79..c173adc 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTitleXSSTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTitleXSSTest.php
@@ -37,12 +37,12 @@ function testNodeTitleXSS() {
$settings = array('title' => $title);
$node = $this->drupalCreateNode($settings);
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
// assertTitle() decodes HTML-entities inside the element.
$this->assertTitle($edit["title"] . ' | Drupal', 'Title is diplayed when viewing a node.');
$this->assertNoRaw($xss, 'Harmful tags are escaped when viewing a node.');
- $this->drupalGet('node/' . $node->nid . '/edit');
+ $this->drupalGet('node/' . $node->id() . '/edit');
$this->assertNoRaw($xss, 'Harmful tags are escaped when editing a node.');
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
index 90b7493..e5eab52 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTokenReplaceTest.php
@@ -43,27 +43,27 @@ function testNodeTokenReplacement() {
$node = $this->drupalCreateNode($settings);
// Load node so that the body and summary fields are structured properly.
- $node = node_load($node->nid);
- $instance = field_info_instance('node', 'body', $node->type);
+ $node = node_load($node->id());
+ $instance = field_info_instance('node', 'body', $node->bundle());
// Generate and test sanitized tokens.
$tests = array();
$tests['[node:nid]'] = $node->nid;
- $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:url]'] = url('node/' . $node->nid, $url_options);
- $tests['[node:edit-url]'] = url('node/' . $node->nid . '/edit', $url_options);
+ $tests['[node:title]'] = check_plain($node->label());
+ $tests['[node:body]'] = text_sanitize($instance['settings']['text_processing'], $node->language()->langcode, $node->body[$node->language()->langcode][0], 'value');
+ $tests['[node:summary]'] = text_sanitize($instance['settings']['text_processing'], $node->language()->langcode, $node->body[$node->language()->langcode][0], 'summary');
+ $tests['[node:langcode]'] = check_plain($node->language()->langcode);
+ $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->langcode);
- $tests['[node:changed:since]'] = format_interval(REQUEST_TIME - $node->changed, 2, $language_interface->langcode);
+ $tests['[node:created:since]'] = format_interval(REQUEST_TIME - $node->getCreatedTime(), 2, $language_interface->langcode);
+ $tests['[node:changed:since]'] = format_interval(REQUEST_TIME - $node->getChangedTime(), 2, $language_interface->langcode);
// 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->label();
+ $tests['[node:body]'] = $node->body[$node->language()->langcode][0]['value'];
+ $tests['[node:summary]'] = $node->body[$node->language()->langcode][0]['summary'];
+ $tests['[node:langcode]'] = $node->language()->langcode;
$tests['[node:author:name]'] = user_format_name($account);
foreach ($tests as $input => $expected) {
@@ -91,12 +91,12 @@ function testNodeTokenReplacement() {
// Load node (without summary) so that the body and summary fields are
// structured properly.
- $node = node_load($node->nid);
- $instance = field_info_instance('node', 'body', $node->type);
+ $node = node_load($node->id());
+ $instance = field_info_instance('node', 'body', $node->bundle());
// 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()->langcode, $node->body[$node->language()->langcode][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()->langcode][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/NodeTranslationUITest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
index bea3245..aef6d86 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTranslationUITest.php
@@ -151,8 +151,8 @@ function testTranslateLinkContentAdminPage() {
// Verify translation links.
$this->drupalGet('admin/content');
$this->assertResponse(200);
- $this->assertLinkByHref('node/' . $article->nid . '/translations');
- $this->assertNoLinkByHref('node/' . $page->nid . '/translations');
+ $this->assertLinkByHref('node/' . $article->id() . '/translations');
+ $this->assertNoLinkByHref('node/' . $page->id() . '/translations');
}
/**
@@ -165,14 +165,14 @@ function testFieldTranslationForm() {
$article = $this->drupalCreateNode(array('type' => 'article', 'langcode' => 'en'));
// Visit translation page.
- $this->drupalGet('node/' . $article->nid . '/translations');
+ $this->drupalGet('node/' . $article->id() . '/translations');
$this->assertRaw('Not translated');
// Delete the only translatable field.
field_info_field('field_test_et_ui_test')->delete();
// Visit translation page.
- $this->drupalGet('node/' . $article->nid . '/translations');
+ $this->drupalGet('node/' . $article->id() . '/translations');
$this->assertRaw('No translatable fields');
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
index 1a0b7ed..b54aef0 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeInitialLanguageTest.php
@@ -113,7 +113,7 @@ function testLanguageFieldVisibility() {
$this->assertTrue($node, 'Node found in database.');
// Loads node page and check if Language field is hidden by default.
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$language_field = $this->xpath('//div[@id=:id]/div', array(
':id' => 'field-language-display',
));
@@ -128,7 +128,7 @@ function testLanguageFieldVisibility() {
$this->assertOptionSelected('edit-fields-language-type', 'visible', 'Language field has been set to visible.');
// Loads node page and check if Language field is shown.
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$language_field = $this->xpath('//div[@id=:id]/div', array(
':id' => 'field-language-display',
));
diff --git a/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php b/core/modules/node/lib/Drupal/node/Tests/PageEditTest.php
index c37a227..68c00dc 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,32 +114,32 @@ 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->uid, '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(
'name' => 'invalid-name',
);
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save and keep published'));
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
$this->assertText('The username invalid-name does not exist.');
// Change the authored by field to an empty string, which should assign
// authorship to the anonymous user (uid 0).
$edit['name'] = '';
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save and keep published'));
- $node = node_load($node->nid, TRUE);
- $this->assertIdentical($node->uid, '0', 'Node authored by anonymous user.');
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
+ $node = node_load($node->id(), TRUE);
+ $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->name;
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save and keep published'));
- $node = node_load($node->nid, TRUE);
- $this->assertIdentical($node->uid, $this->web_user->uid, 'Node authored by normal user.');
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
+ $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);
- $this->drupalGet('node/' . $node->nid . '/edit');
+ $this->drupalGet('node/' . $node->id() . '/edit');
$this->assertNoFieldByName('name');
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
index b485545..0538e00 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PagePreviewTest.php
@@ -138,11 +138,11 @@ function testPagePreview() {
$node = $this->drupalGetNodeByTitle($edit[$title_key]);
// Check the term was displayed on the saved node.
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$this->assertText($edit[$term_key], 'Term displayed.');
// Check the term appears again on the edit form.
- $this->drupalGet('node/' . $node->nid . '/edit');
+ $this->drupalGet('node/' . $node->id() . '/edit');
$this->assertFieldByName($term_key, $edit[$term_key], 'Term field displayed.');
// Check with two new terms on the edit form, additionally to the existing
@@ -151,7 +151,7 @@ function testPagePreview() {
$newterm1 = $this->randomName(8);
$newterm2 = $this->randomName(8);
$edit[$term_key] = $this->term->label() . ', ' . $newterm1 . ', ' . $newterm2;
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Preview'));
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Preview'));
$this->assertRaw('>' . $newterm1 . '<', 'First new term displayed.');
$this->assertRaw('>' . $newterm2 . '<', 'Second new term displayed.');
// The first term should be displayed as link, the others not.
@@ -166,7 +166,7 @@ function testPagePreview() {
$edit = array();
$newterm3 = $this->randomName(8);
$edit[$term_key] = $newterm1 . ', ' . $newterm3 . ', ' . $newterm2;
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Preview'));
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Preview'));
$this->assertRaw('>' . $newterm1 . '<', 'First existing term displayed.');
$this->assertRaw('>' . $newterm2 . '<', 'Second existing term displayed.');
$this->assertRaw('>' . $newterm3 . '<', 'Third new term displayed.');
diff --git a/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php b/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php
index deab20a..d1278d6 100644
--- a/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/PageViewTest.php
@@ -25,10 +25,10 @@ public static function getInfo() {
function testPageView() {
// Create a node to view.
$node = $this->drupalCreateNode();
- $this->assertTrue(node_load($node->nid), 'Node created.');
+ $this->assertTrue(node_load($node->id()), 'Node created.');
// Try to edit with anonymous user.
- $html = $this->drupalGet("node/$node->nid/edit");
+ $html = $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 e627c6e..3ea2371 100644
--- a/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/SummaryLengthTest.php
@@ -29,7 +29,7 @@ function testSummaryLength() {
'promote' => 1,
);
$node = $this->drupalCreateNode($settings);
- $this->assertTrue(node_load($node->nid), 'Node created.');
+ $this->assertTrue(node_load($node->id()), 'Node created.');
// Create user with permission to view the node.
$web_user = $this->drupalCreateUser(array('access content', 'administer content types'));
@@ -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->bundle(), 'teaser');
$display_options = $display->getComponent('body');
$display_options['settings']['trim_length'] = 200;
$display->setComponent('body', $display_options)
diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php
index 838c553..f3617b4 100644
--- a/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/Views/BulkFormTest.php
@@ -41,7 +41,7 @@ public function testBulkForm() {
$this->assertIdentical(count($elements), 8, 'All node operations are found.');
// Block a node using the bulk form.
- $this->assertTrue($node->status);
+ $this->assertTrue($node->isPublished());
$edit = array(
'node_bulk_form[0]' => TRUE,
'action' => 'node_unpublish_action',
@@ -49,7 +49,7 @@ public function testBulkForm() {
$this->drupalPost(NULL, $edit, t('Apply'));
// Re-load the node and check their status.
$node = entity_load('node', $node->id());
- $this->assertFalse($node->status);
+ $this->assertFalse($node->isPublished());
}
}
diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/RevisionRelationships.php b/core/modules/node/lib/Drupal/node/Tests/Views/RevisionRelationships.php
index 9ffc781..edb40d0 100644
--- a/core/modules/node/lib/Drupal/node/Tests/Views/RevisionRelationships.php
+++ b/core/modules/node/lib/Drupal/node/Tests/Views/RevisionRelationships.php
@@ -59,7 +59,7 @@ public function testNodeRevisionRelationship() {
// Here should be two rows.
$view_nid = views_get_view('test_node_revision_nid');
- $this->executeView($view_nid, array($node->nid));
+ $this->executeView($view_nid, array($node->id()));
$resultset_nid = array(
array(
'vid' => '1',
@@ -76,7 +76,7 @@ public function testNodeRevisionRelationship() {
// There should be only one row with active revision 2.
$view_vid = views_get_view('test_node_revision_vid');
- $this->executeView($view_vid, array($node->nid));
+ $this->executeView($view_vid, array($node->id()));
$resultset_vid = array(
array(
'vid' => '2',
diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc
index c2b8524..c4721f5 100644
--- a/core/modules/node/node.admin.inc
+++ b/core/modules/node/node.admin.inc
@@ -141,7 +141,7 @@ function _node_mass_update_batch_process(array $nodes, array $updates, $load, ar
$node = _node_mass_update_helper($node, $updates);
// Store result for post-processing in the finished callback.
- $context['results'][] = l($node->label(), 'node/' . $node->nid);
+ $context['results'][] = l($node->label(), 'node/' . $node->id());
// Update our progress information.
$context['sandbox']['progress']++;
@@ -259,15 +259,15 @@ 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()->langcode != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$node->language()->langcode]) ? array('language' => $languages[$node->language()->langcode]) : array();
$mark = array(
'#theme' => 'mark',
- '#status' => node_mark($node->nid, $node->changed),
+ '#status' => node_mark($node->id(), $node->getChangedTime()),
);
$form['nodes'][$node->nid]['title'] = array(
'#type' => 'link',
'#title' => $node->label(),
- '#href' => 'node/' . $node->nid,
+ '#href' => 'node/' . $node->id(),
'#options' => $l_options,
'#suffix' => ' ' . drupal_render($mark),
);
@@ -276,17 +276,17 @@ function node_admin_nodes() {
);
$form['nodes'][$node->nid]['author'] = array(
'#theme' => 'username',
- '#account' => $node,
+ '#account' => $node->getAuthor(),
);
$form['nodes'][$node->nid]['status'] = array(
- '#markup' => $node->status ? t('published') : t('not published'),
+ '#markup' => $node->isPublished() ? t('published') : t('not published'),
);
$form['nodes'][$node->nid]['changed'] = array(
- '#markup' => format_date($node->changed, 'short'),
+ '#markup' => format_date($node->getChangedTime(), 'short'),
);
if ($multilingual) {
$form['nodes'][$node->nid]['language_name'] = array(
- '#markup' => language_name($node->langcode),
+ '#markup' => $node->language()->name,
);
}
@@ -295,21 +295,21 @@ function node_admin_nodes() {
if (node_access('update', $node)) {
$operations['edit'] = array(
'title' => t('Edit'),
- 'href' => 'node/' . $node->nid . '/edit',
+ 'href' => 'node/' . $node->id() . '/edit',
'query' => $destination,
);
}
if (node_access('delete', $node)) {
$operations['delete'] = array(
'title' => t('Delete'),
- 'href' => 'node/' . $node->nid . '/delete',
+ 'href' => 'node/' . $node->id() . '/delete',
'query' => $destination,
);
}
if ($node->isTranslatable()) {
$operations['translate'] = array(
'title' => t('Translate'),
- 'href' => 'node/' . $node->nid . '/translations',
+ 'href' => 'node/' . $node->id() . '/translations',
'query' => $destination,
);
}
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index 51abca3..0f317bb 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,
@@ -403,7 +403,7 @@ function hook_node_grants_alter(&$grants, $account, $op) {
*/
function hook_node_predelete(\Drupal\Core\Entity\EntityInterface $node) {
db_delete('mytable')
- ->condition('nid', $node->nid)
+ ->condition('nid', $node->id())
->execute();
}
@@ -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();
}
@@ -465,7 +465,7 @@ function hook_node_revision_delete(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_insert(\Drupal\Core\Entity\EntityInterface $node) {
db_insert('mytable')
->fields(array(
- 'nid' => $node->nid,
+ 'nid' => $node->id(),
'extra' => $node->extra,
))
->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->bundle();
$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->uid == $node->uid))) {
+ if (user_access('edit any ' . $type . ' content', $account) || (user_access('edit own ' . $type . ' content', $account) && ($account->uid == $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->uid == $node->uid))) {
+ if (user_access('delete any ' . $type . ' content', $account) || (user_access('delete own ' . $type . ' content', $account) && ($account->uid == $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->bundle(), COMMENT_NODE_OPEN);
}
}
@@ -639,7 +639,7 @@ function hook_node_prepare_form(\Drupal\node\NodeInterface $node, $form_display,
* @ingroup node_api_hooks
*/
function hook_node_search_result(\Drupal\Core\Entity\EntityInterface $node, $langcode) {
- $comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->nid))->fetchField();
+ $comments = db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = :nid', array('nid' => $node->id()))->fetchField();
return array('comment' => format_plural($comments, '1 comment', '@count comments'));
}
@@ -655,7 +655,7 @@ function hook_node_search_result(\Drupal\Core\Entity\EntityInterface $node, $lan
* @ingroup node_api_hooks
*/
function hook_node_presave(\Drupal\Core\Entity\EntityInterface $node) {
- if ($node->nid && $node->moderate) {
+ if ($node->id() && $node->moderate) {
// Reset votes when node is updated:
$node->score = 0;
$node->users = '';
@@ -686,7 +686,7 @@ function hook_node_presave(\Drupal\Core\Entity\EntityInterface $node) {
function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) {
db_update('mytable')
->fields(array('extra' => $node->extra))
- ->condition('nid', $node->nid)
+ ->condition('nid', $node->id())
->execute();
}
@@ -708,7 +708,7 @@ function hook_node_update(\Drupal\Core\Entity\EntityInterface $node) {
*/
function hook_node_update_index(\Drupal\Core\Entity\EntityInterface $node, $langcode) {
$text = '';
- $comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(':nid' => $node->nid, ':status' => COMMENT_PUBLISHED));
+ $comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(':nid' => $node->id(), ':status' => COMMENT_PUBLISHED));
foreach ($comments as $comment) {
$text .= '' . check_plain($comment->subject->value) . '
' . $comment->comment_body->processed;
}
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 7057db2..a723dbf 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -584,7 +584,7 @@ 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|false
+ * @return \Drupal\node\NodeInterface|false
* A fully-populated node entity, or FALSE if the node is not found.
*/
function node_load($nid = NULL, $reset = FALSE) {
@@ -598,7 +598,7 @@ function node_load($nid = NULL, $reset = FALSE) {
* @param int $nid
* The node revision id.
*
- * @return Drupal\node\Node|false
+ * @return \Drupal\node\NodeInterface|false
* A fully-populated node entity, or FALSE if the node is not found.
*/
function node_revision_load($vid = NULL) {
@@ -740,7 +740,7 @@ function template_preprocess_node(&$variables) {
// http://drupal.org/node/1941286.
$username = array(
'#theme' => 'username',
- '#account' => $node,
+ '#account' => $node->getAuthor(),
'#link_options' => array('attributes' => array('rel' => 'author')),
);
$variables['name'] = drupal_render($username);
@@ -998,7 +998,7 @@ function node_search_execute($keys = NULL, $conditions = NULL) {
$uri = $node->uri();
$username = array(
'#theme' => 'username',
- '#account' => $node,
+ '#account' => $node->getAuthor(),
);
$results[] = array(
'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))),
@@ -1449,7 +1449,7 @@ function node_revision_list(EntityInterface $node) {
$revisions = array();
$result = db_query('SELECT nfr.vid, nfr.title, nfr.log, nfr.revision_uid AS uid, n.vid AS current_vid, nfr.revision_timestamp, u.name FROM {node_field_revision} nfr LEFT JOIN {node} n ON n.vid = nfr.vid INNER JOIN {users} u ON u.uid = nfr.revision_uid WHERE nfr.nid = :nid AND nfr.default_langcode = 1 ORDER BY nfr.vid DESC', array(':nid' => $node->id()));
foreach ($result as $revision) {
- $revisions[$revision->vid] = $revision;
+ $revisions[$revision->getRevisionId()] = $revision;
}
return $revisions;
@@ -2164,7 +2164,7 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) {
// If no language code was provided, default to the node's langcode.
if (empty($langcode)) {
- $langcode = $node->langcode;
+ $langcode = $node->language()->langcode;
// If the Language module is enabled, try to use the language from content
// negotiation.
if (module_exists('language')) {
@@ -2588,7 +2588,7 @@ function _node_access_write_grants(EntityInterface $node, $grants, $realm = NULL
$grant['nid'] = $node->id();
$grant['langcode'] = $grant_langcode;
// The record with the original langcode is used as the fallback.
- if ($grant['langcode'] == $node->langcode) {
+ if ($grant['langcode'] == $node->language()->langcode) {
$grant['fallback'] = 1;
}
else {
diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc
index 155f595..1d8128b 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.
@@ -107,21 +108,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->uid;
+ $node->setAuthorId($user->uid);
}
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->name;
}
@@ -194,10 +195,10 @@ function theme_node_preview($variables) {
*/
function node_delete_confirm($form, &$form_state, $node) {
// Always provide entity id in the same form key as in the entity edit form.
- $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
+ $form['nid'] = array('#type' => 'value', '#value' => $node->id());
return confirm_form($form,
t('Are you sure you want to delete %title?', array('%title' => $node->label())),
- 'node/' . $node->nid,
+ 'node/' . $node->id(),
t('This action cannot be undone.'),
t('Delete'),
t('Cancel')
@@ -211,7 +212,7 @@ function node_delete_confirm_submit($form, &$form_state) {
if ($form_state['values']['confirm']) {
$node = node_load($form_state['values']['nid']);
$node->delete();
- watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->label()));
+ watchdog('content', '@type: deleted %title.', array('@type' => $node->bundle(), '%title' => $node->label()));
drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_type_label($node), '%title' => $node->label())));
}
@@ -237,7 +238,7 @@ function node_revision_overview($node) {
$revisions = node_revision_list($node);
$rows = array();
- $type = $node->type;
+ $type = $node->bundle();
$revert_permission = FALSE;
if ((user_access("revert $type revisions") || user_access('revert all revisions') || user_access('administer nodes')) && node_access('update', $node)) {
@@ -249,13 +250,12 @@ function node_revision_overview($node) {
}
foreach ($revisions as $revision) {
$row = array();
- $type = $node->type;
if ($revision->current_vid > 0) {
$username = array(
'#theme' => 'username',
- '#account' => $revision,
+ '#account' => $revision->getAuthor(),
);
- $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), "node/$node->nid"), '!username' => drupal_render($username)))
+ $row[] = array('data' => t('!date by !username', array('!date' => l(format_date($revision->revision_timestamp, 'short'), 'node/' . $node->id()), '!username' => drupal_render($username)))
. (($revision->log != '') ? '' . filter_xss($revision->log) . '
' : ''),
'class' => array('revision-current'));
$row[] = array('data' => drupal_placeholder(t('current revision')), 'class' => array('revision-current'));
@@ -263,20 +263,20 @@ function node_revision_overview($node) {
else {
$username = array(
'#theme' => 'username',
- '#account' => $revision,
+ '#account' => $revision->getAuthor(),
);
- $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->getRevisionId() . "/view"), '!username' => drupal_render($username)))
. (($revision->log != '') ? '' . filter_xss($revision->log) . '
' : '');
if ($revert_permission) {
$links['revert'] = array(
'title' => t('Revert'),
- 'href' => "node/$node->nid/revisions/$revision->vid/revert",
+ 'href' => "node/" . $node->id() . "/revisions/" . $revision->getRevisionId() . "/revert",
);
}
if ($delete_permission) {
$links['delete'] = array(
'title' => t('Delete'),
- 'href' => "node/$node->nid/revisions/$revision->vid/delete",
+ 'href' => "node/" . $node->id() . "/revisions/" . $revision->getRevisionId() . "/delete",
);
}
$row[] = array(
@@ -318,7 +318,7 @@ function node_revision_overview($node) {
*/
function node_revision_revert_confirm($form, $form_state, $node_revision) {
$form['#node_revision'] = $node_revision;
- return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', '', t('Revert'), t('Cancel'));
+ return confirm_form($form, t('Are you sure you want to revert to the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->id() . '/revisions', '', t('Revert'), t('Cancel'));
}
/**
@@ -338,9 +338,9 @@ function node_revision_revert_confirm_submit($form, &$form_state) {
$node_revision->save();
- watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->label(), '%revision' => $node_revision->vid));
+ watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->label(), '%revision' => $node_revision->getRevisionId()));
drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_get_type_label($node_revision), '%title' => $node_revision->label(), '%revision-date' => format_date($original_revision_timestamp))));
- $form_state['redirect'] = 'node/' . $node_revision->nid . '/revisions';
+ $form_state['redirect'] = 'node/' . $node_revision->id() . '/revisions';
}
/**
@@ -360,7 +360,7 @@ function node_revision_revert_confirm_submit($form, &$form_state) {
*/
function node_revision_delete_confirm($form, $form_state, $node_revision) {
$form['#node_revision'] = $node_revision;
- return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->nid . '/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
+ return confirm_form($form, t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($node_revision->revision_timestamp))), 'node/' . $node_revision->id() . '/revisions', t('This action cannot be undone.'), t('Delete'), t('Cancel'));
}
/**
@@ -368,12 +368,12 @@ function node_revision_delete_confirm($form, $form_state, $node_revision) {
*/
function node_revision_delete_confirm_submit($form, &$form_state) {
$node_revision = $form['#node_revision'];
- node_revision_delete($node_revision->vid);
+ node_revision_delete($node_revision->getRevisionId());
- watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->label(), '%revision' => $node_revision->vid));
+ watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->label(), '%revision' => $node_revision->getRevisionId()));
drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_get_type_label($node_revision), '%title' => $node_revision->label())));
$form_state['redirect'] = 'node/' . $node_revision->nid;
- if (db_query('SELECT COUNT(DISTINCT vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $node_revision->nid))->fetchField() > 1) {
+ if (db_query('SELECT COUNT(DISTINCT vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $node_revision->id()))->fetchField() > 1) {
$form_state['redirect'] .= '/revisions';
}
}
diff --git a/core/modules/node/node.tokens.inc b/core/modules/node/node.tokens.inc
index 241b83b..8211f55 100644
--- a/core/modules/node/node.tokens.inc
+++ b/core/modules/node/node.tokens.inc
@@ -111,11 +111,11 @@ function node_tokens($type, $tokens, array $data = array(), array $options = arr
switch ($name) {
// Simple key values on the node.
case 'nid':
- $replacements[$original] = $node->nid;
+ $replacements[$original] = $node->id();
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->bundle()) : $node->bundle();
break;
case 'type-name':
@@ -132,13 +132,13 @@ 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->label()) : $node->label();
break;
case 'body':
case 'summary':
if ($items = field_get_items($node, 'body', $langcode)) {
- $instance = field_info_instance('node', 'body', $node->type);
+ $instance = field_info_instance('node', 'body', $node->bundle());
$field_langcode = field_language($node, 'body', $langcode);
// If the summary was requested and is not empty, use it.
@@ -154,7 +154,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->bundle(), 'teaser')->getComponent('body');
if (isset($display_options['settings']['trim_length'])) {
$length = $display_options['settings']['trim_length'];
}
@@ -171,45 +171,43 @@ 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()->langcode) : $node->language()->langcode;
break;
case 'url':
- $replacements[$original] = url('node/' . $node->nid, $url_options);
+ $replacements[$original] = url('node/' . $node->id(), $url_options);
break;
case 'edit-url':
- $replacements[$original] = url('node/' . $node->nid . '/edit', $url_options);
+ $replacements[$original] = url('node/' . $node->id() . '/edit', $url_options);
break;
// 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 ad12811..daf308a 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
*/
#}
-
+
{{ 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 ac25cb2..71b640b 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,
@@ -122,7 +123,7 @@ function node_access_test_page() {
$output .= 'Yes, ' . count($result) . ' nodes
';
$output .= '';
foreach ($result as $item) {
- $output .= '- ' . $item->nid . '
';
+ $output .= '- ' . $item->id() . '
';
}
$output .= '
';
}
@@ -208,7 +209,7 @@ function node_access_test_node_load($nodes, $types) {
*/
function node_access_test_node_predelete(EntityInterface $node) {
- db_delete('node_access_test')->condition('nid', $node->nid)->execute();
+ db_delete('node_access_test')->condition('nid', $node->id())->execute();
}
/**
@@ -231,7 +232,7 @@ function node_access_test_node_update(EntityInterface $node) {
function _node_access_test_node_write(EntityInterface $node) {
if (isset($node->private)) {
db_merge('node_access_test')
- ->key(array('nid' => $node->nid))
+ ->key(array('nid' => $node->id()))
->fields(array('private' => (int) $node->private))
->execute();
}
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 12e0eed..c9b6a32 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().
@@ -35,13 +36,13 @@ function node_test_node_view(EntityInterface $node, EntityDisplay $display, $vie
// Add RSS elements and namespaces when building the RSS feed.
$node->rss_elements[] = array(
'key' => 'testElement',
- 'value' => t('Value of testElement RSS element for node !nid.', array('!nid' => $node->nid)),
+ 'value' => t('Value of testElement RSS element for node !nid.', array('!nid' => $node->id())),
);
$node->rss_namespaces['xmlns:drupaltest'] = 'http://example.com/test-namespace';
// Add content that should be displayed only in the RSS feed.
$node->content['extra_feed_content'] = array(
- '#markup' => '' . t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->nid)) . '
',
+ '#markup' => '' . t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->id())) . '
',
'#weight' => 10,
);
}
@@ -49,7 +50,7 @@ function node_test_node_view(EntityInterface $node, EntityDisplay $display, $vie
if ($view_mode != 'rss') {
// Add content that should NOT be displayed in the RSS feed.
$node->content['extra_non_feed_content'] = array(
- '#markup' => '' . t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->nid)) . '
',
+ '#markup' => '' . t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->id())) . '
',
);
}
}
@@ -77,7 +78,7 @@ function node_test_node_access_records(EntityInterface $node) {
return;
}
$grants = array();
- if ($node->type == 'article') {
+ if ($node->bundle() == '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->bundle() == '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->label() == '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->label() == 'test_changes') {
+ if ($node->original->label() != $node->label()) {
$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->label() == 'test_changes') {
+ if ($node->original->label() != $node->label()) {
$node->title .= '_update';
}
}
@@ -175,8 +176,8 @@ 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') {
- $node->title = 'Node '. $node->nid;
+ if ($node->label() == '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 9eaa4f1..fbfc816 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->label() == 'testing_transaction_exception') {
throw new Exception('Test exception for rollback.');
}
}
diff --git a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
index d34f178..2b45acd 100644
--- a/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
+++ b/core/modules/options/lib/Drupal/options/Tests/OptionsFieldUITest.php
@@ -322,7 +322,7 @@ function testNodeDisplay() {
$edit = array(
$this->field_name . '[und]' => '1',
);
- $this->drupalPost('node/' . $node->nid . '/edit', $edit, t('Save and keep published'));
+ $this->drupalPost('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
// Check the node page and see if the values are correct.
$file_formatters = array('list_default', 'list_key');
@@ -331,7 +331,7 @@ function testNodeDisplay() {
"fields[$this->field_name][type]" => $formatter,
);
$this->drupalPost('admin/structure/types/manage/' . $this->type_name . '/display', $edit, t('Save'));
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
if ($formatter == 'list_default') {
$output = $on;
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
index 5626d3a..51b1f8e 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathAliasTest.php
@@ -147,7 +147,7 @@ function testNodeAlias() {
// Create alias.
$edit = array();
$edit['path[alias]'] = $this->randomName(8);
- $this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node1->id() . '/edit', $edit, t('Save'));
// Confirm that the alias works.
$this->drupalGet($edit['path[alias]']);
@@ -159,7 +159,7 @@ function testNodeAlias() {
$edit['path[alias]'] = "- ._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
- $this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node1->id() . '/edit', $edit, t('Save'));
// Confirm that the alias works.
$this->drupalGet($edit['path[alias]']);
@@ -176,13 +176,13 @@ function testNodeAlias() {
// Set alias to second test node.
// Leave $edit['path[alias]'] the same.
- $this->drupalPost('node/' . $node2->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node2->id() . '/edit', $edit, t('Save'));
// Confirm that the alias didn't make a duplicate.
$this->assertText(t('The alias is already in use.'), 'Attempt to moved alias was rejected.');
// Delete alias.
- $this->drupalPost('node/' . $node1->nid . '/edit', array('path[alias]' => ''), t('Save'));
+ $this->drupalPost('node/' . $node1->id() . '/edit', array('path[alias]' => ''), t('Save'));
// Confirm that the alias no longer works.
$this->drupalGet($edit['path[alias]']);
@@ -211,11 +211,11 @@ function testDuplicateNodeAlias() {
$node_one = $this->drupalCreateNode();
$edit = array();
$edit['path[alias]'] = $this->randomName();
- $this->drupalPost('node/' . $node_one->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node_one->id() . '/edit', $edit, t('Save'));
// Now create another node and try to set the same alias.
$node_two = $this->drupalCreateNode();
- $this->drupalPost('node/' . $node_two->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $node_two->id() . '/edit', $edit, t('Save'));
$this->assertText(t('The alias is already in use.'));
$this->assertFieldByXPath("//input[@name='path[alias]' and contains(@class, 'error')]", $edit['path[alias]'], 'Textfield exists and has the error class.');
}
diff --git a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
index 291b633..b591720 100644
--- a/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
+++ b/core/modules/path/lib/Drupal/path/Tests/PathLanguageTest.php
@@ -66,14 +66,14 @@ function testAliasTranslation() {
$edit = array();
$edit['langcode'] = 'en';
$edit['path[alias]'] = $english_alias;
- $this->drupalPost('node/' . $english_node->nid . '/edit', $edit, t('Save'));
+ $this->drupalPost('node/' . $english_node->id() . '/edit', $edit, t('Save'));
// Confirm that the alias works.
$this->drupalGet($english_alias);
$this->assertText($english_node->label(), 'Alias works.');
// Translate the node into French.
- $this->drupalGet('node/' . $english_node->nid . '/translate');
+ $this->drupalGet('node/' . $english_node->id() . '/translate');
$this->clickLink(t('Add translation'));
$edit = array();
$langcode = Language::LANGCODE_NOT_SPECIFIED;
@@ -99,7 +99,7 @@ function testAliasTranslation() {
drupal_static_reset('language_list');
$this->rebuildContainer();
$languages = language_list();
- $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->nid, array('language' => $languages[$french_node->langcode]));
+ $url = $this->container->get('url_generator')->generateFromPath('node/' . $french_node->id(), array('language' => $languages[$french_node->language()->langcode]));
$this->assertTrue(strpos($url, $edit['path[alias]']), 'URL contains the path alias.');
@@ -150,17 +150,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);
- $this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path works.');
+ $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->language()->langcode);
+ $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);
- $this->assertEqual($french_node_path, 'node/' . $french_node->nid, 'Normal path is the same.');
+ $french_node_path = $this->container->get('path.alias_manager')->getSystemPath($french_alias, $french_node->language()->langcode);
+ $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->nid, $french_node->langcode);
+ $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), $french_node->language()->langcode);
$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->nid, $french_node->langcode);
+ $french_node_alias = $this->container->get('path.alias_manager')->getPathAlias('node/' . $french_node->id(), $french_node->language()->langcode);
$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 efc59a8..0efae2c 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;
/**
@@ -99,10 +98,10 @@ function path_menu() {
function path_form_node_form_alter(&$form, $form_state) {
$node = $form_state['controller']->getEntity();
$path = array();
- if (!empty($node->nid)) {
- $conditions = array('source' => 'node/' . $node->nid);
- if ($node->langcode != Language::LANGCODE_NOT_SPECIFIED) {
- $conditions['langcode'] = $node->langcode;
+ if (!$node->isNew()) {
+ $conditions = array('source' => 'node/' . $node->id());
+ if ($node->language()->langcode != Language::LANGCODE_NOT_SPECIFIED) {
+ $conditions['langcode'] = $node->language()->langcode;
}
$path = Drupal::service('path.crud')->load($conditions);
if ($path === FALSE) {
@@ -111,9 +110,9 @@ function path_form_node_form_alter(&$form, $form_state) {
}
$path += array(
'pid' => NULL,
- 'source' => isset($node->nid) ? 'node/' . $node->nid : NULL,
+ 'source' => $node->id() ? 'node/' . $node->id() : NULL,
'alias' => '',
- 'langcode' => isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED,
+ 'langcode' => $node->language()->langcode,
);
$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->nid;
- $langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED;
+ $source = 'node/' . $node->id();
+ $langcode = $node->language()->langcode;
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']);
@@ -211,8 +210,8 @@ function path_node_update(EntityInterface $node) {
// Only save a non-empty alias.
if (!empty($path['alias'])) {
// Ensure fields for programmatic executions.
- $source = 'node/' . $node->nid;
- $langcode = isset($node->langcode) ? $node->langcode : Language::LANGCODE_NOT_SPECIFIED;
+ $source = 'node/' . $node->id();
+ $langcode = $node->language()->langcode;
Drupal::service('path.crud')->save($source, $alias, $langcode, $path['pid']);
}
}
@@ -221,9 +220,9 @@ 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->nid));
+ Drupal::service('path.crud')->delete(array('source' => 'node/' . $node->id()));
}
/**
diff --git a/core/modules/php/lib/Drupal/php/Tests/PhpAccessTest.php b/core/modules/php/lib/Drupal/php/Tests/PhpAccessTest.php
index f85c9f1..10d2b75 100644
--- a/core/modules/php/lib/Drupal/php/Tests/PhpAccessTest.php
+++ b/core/modules/php/lib/Drupal/php/Tests/PhpAccessTest.php
@@ -29,11 +29,11 @@ function testNoPrivileges() {
$node = $this->createNodeWithCode();
// Make sure that the PHP code shows up as text.
- $this->drupalGet('node/' . $node->nid);
+ $this->drupalGet('node/' . $node->id());
$this->assertText('print', 'PHP code was not evaluated.');
// Make sure that user doesn't have access to filter.
- $this->drupalGet('node/' . $node->nid . '/edit');
+ $this->drupalGet('node/' . $node->id() . '/edit');
$this->assertNoRaw('