diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 193afb7..9dd3758 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -6,7 +6,7 @@ */ use Drupal\Core\Entity\EntityInterface; -use Drupal\entity\Plugin\Core\Entity\EntityDisplay; +use Drupal\node\NodeInterface; use Drupal\taxonomy\Plugin\Core\Entity\Term; /** @@ -501,18 +501,18 @@ function forum_comment_delete($comment) { * Implements hook_field_storage_pre_insert(). */ function forum_field_storage_pre_insert(EntityInterface $entity, &$skip_fields) { - if ($entity->entityType() == 'node' && $entity->status && _forum_node_check_node_type($entity)) { + if ($entity->entityType() instanceof NodeInterface && $entity->isPublished() && _forum_node_check_node_type($entity)) { $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); foreach ($entity->getTranslationLanguages() as $langcode => $language) { $translation = $entity->getTranslation($langcode); $query->values(array( 'nid' => $entity->id(), - 'title' => $translation->title->value, + 'title' => $translation->label(), 'tid' => $translation->taxonomy_forums->target_id, - 'sticky' => (int)$entity->isSticky(), - 'created' => $entity->created, + 'sticky' => (int) $entity->isSticky(), + 'created' => $entity->getCreatedTime(), 'comment_count' => 0, - 'last_comment_timestamp' => $entity->created, + 'last_comment_timestamp' => $entity->getCreatedTime(), )); } $query->execute(); @@ -525,29 +525,30 @@ function forum_field_storage_pre_insert(EntityInterface $entity, &$skip_fields) function forum_field_storage_pre_update(EntityInterface $entity, &$skip_fields) { $first_call = &drupal_static(__FUNCTION__, array()); - if ($entity->entityType() == 'node' && _forum_node_check_node_type($entity)) { + if ($entity instanceof NodeInterface && _forum_node_check_node_type($entity)) { // If the node is published, update the forum index. - if ($entity->status) { + if ($entity->isPublished()) { // We don't maintain data for old revisions, so clear all previous values // from the table. Since this hook runs once per field, per object, make // sure we only wipe values once. - if (!isset($first_call[$entity->nid])) { - $first_call[$entity->nid] = FALSE; + if (!isset($first_call[$entity->id()])) { + $first_call[$entity->id()] = FALSE; db_delete('forum_index')->condition('nid', $entity->id())->execute(); } $query = db_insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp')); - foreach ($entity->taxonomy_forums as $language) { - foreach ($language as $item) { + foreach ($entity->getTranslationLanguages() as $langcode => $language) { + $translation = $entity->getTranslation($langcode); + foreach ($translation->taxonomy_forums as $item) { $query->values(array( - 'nid' => $entity->nid, - 'title' => $entity->title, - 'tid' => $item['target_id'], - 'sticky' => (int)$entity->isSticky(), - 'created' => $entity->created, + 'nid' => $entity->id(), + 'title' => $translation->label(), + 'tid' => $item->target_id, + 'sticky' => (int) $entity->isSticky(), + 'created' => $entity->getCreatedTime(), 'comment_count' => 0, - 'last_comment_timestamp' => $entity->created, + 'last_comment_timestamp' => $entity->getCreatedTime(), )); } } 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 5ff3c63..d5ec65c 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 @@ -266,9 +266,9 @@ public function getRevisionAuthor() { $entity = $this->get('revision_uid')->entity; // If no user is given, default to the anonymous user. if (!$entity) { - return user_load(0)->getBCentity(); + return user_load(0); } - return $entity->getBCEntity(); + return $entity; } /** diff --git a/core/modules/node/node.module b/core/modules/node/node.module index c5558ee..e4d9a8f 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -537,7 +537,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\NodeInterface|false + * @return \Drupal\node\NodeInterface|null * A fully-populated node entity, or NULL if the node is not found. */ function node_load($nid = NULL, $reset = FALSE) { @@ -548,11 +548,11 @@ function node_load($nid = NULL, $reset = FALSE) { /** * Loads a node revision from the database. * - * @param int $nid + * @param int $vid * The node revision id. * * @return \Drupal\node\NodeInterface|null - * A fully-populated node entity, or FALSE if the node is not found. + * A fully-populated node entity, or NULL if the node is not found. */ function node_revision_load($vid = NULL) { return entity_revision_load('node', $vid); diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 3179464..f44f27a 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -1131,7 +1131,7 @@ function taxonomy_build_node_index($node) { $status = NULL; if (config('taxonomy.settings')->get('maintain_index_table')) { $status = $node->isPublished(); - $sticky = (int)$node->isSticky(); + $sticky = (int) $node->isSticky(); } // We only maintain the taxonomy index for published nodes. if ($status && $node->isDefaultRevision()) { diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index e219abc..5536608 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -303,14 +303,14 @@ function _tracker_add($nid, $uid, $changed) { } /** - * Determines the max timestamp between $node->getChangedTime() and the last comment. + * Picks the most recent timestamp between node changed and the last comment. * * @param $nid * A node ID. * * @return - * The $node->getChangedTime() timestamp, or most recent comment timestamp, whichever - * is the greatest. + * The node changed timestamp, or most recent comment timestamp, whichever is + * the greatest. */ function _tracker_calculate_changed($nid) { // @todo This should be actually filtering on the desired language and just diff --git a/core/themes/bartik/templates/node.html.twig b/core/themes/bartik/templates/node.html.twig index 7f59fbc..d45cc55 100644 --- a/core/themes/bartik/templates/node.html.twig +++ b/core/themes/bartik/templates/node.html.twig @@ -8,8 +8,8 @@ * - 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 + * - createdtime: Formatted creation date. Preprocess functions can reformat + it by calling format_date() with the desired parameters on * $variables['node']->getCreatedTime(). * - promoted: Whether the node is promoted to the front page. * - sticky: Whether the node is 'sticky'. Sticky nodes are ordered above diff --git a/core/themes/seven/seven.theme b/core/themes/seven/seven.theme index 62e19cd..f36a0b7 100644 --- a/core/themes/seven/seven.theme +++ b/core/themes/seven/seven.theme @@ -186,7 +186,7 @@ function seven_form_node_form_alter(&$form, &$form_state) { '#type' => 'item', '#wrapper_attributes' => array('class' => array('author', 'container-inline')), '#title' => t('Author'), - '#markup' => $node->getAuthor()->label(), + '#markup' => $node->getAuthor()->getUsername(), ), ); $form['revision_information']['#type'] = 'container';