diff --git a/core/modules/forum/lib/Drupal/forum/ForumManager.php b/core/modules/forum/lib/Drupal/forum/ForumManager.php index 6d67a74..92b439f 100644 --- a/core/modules/forum/lib/Drupal/forum/ForumManager.php +++ b/core/modules/forum/lib/Drupal/forum/ForumManager.php @@ -346,7 +346,7 @@ protected function lastVisit($nid) { if (isset($this->historyManager)) { // History manager service could not be available. - $this->history[$nid] = $this->historyManager->getLastViewed('node', array($nid)); + $this->history += $this->historyManager->getLastViewed('node', array($nid)); } if (empty($this->history[$nid])) { $this->history[$nid] = HISTORY_READ_LIMIT; diff --git a/core/modules/history/history.install b/core/modules/history/history.install index 482ac9f..67cacd6 100644 --- a/core/modules/history/history.install +++ b/core/modules/history/history.install @@ -39,14 +39,14 @@ function history_schema() { ), ), 'primary key' => array( + array('entity_type', 32), 'uid', 'entity_id', - array('entity_type', 32), ), 'indexes' => array( 'history_entity' => array( - 'entity_id', array('entity_type', 32), + 'entity_id', ), ), ); diff --git a/core/modules/history/lib/Drupal/history/HistoryManager.php b/core/modules/history/lib/Drupal/history/HistoryManager.php index 124b985..5a0d335 100644 --- a/core/modules/history/lib/Drupal/history/HistoryManager.php +++ b/core/modules/history/lib/Drupal/history/HistoryManager.php @@ -81,7 +81,7 @@ public function getLastViewed($entity_type, $entity_ids) { /** * {@inheritdoc} */ - public function updateLastViewed($entity_type, $entity_id, AccountInterface $account = NULL) { + public function updateLastViewed(EntityInterface $entity, AccountInterface $account = NULL) { if (!isset($account)) { $account = \Drupal::currentUser(); } @@ -90,13 +90,13 @@ public function updateLastViewed($entity_type, $entity_id, AccountInterface $acc $this->connection->merge('history') ->key(array( 'uid' => $account->id(), - 'entity_id' => $entity_id, - 'entity_type' => $entity_type, + 'entity_id' => $entity->id(), + 'entity_type' => $entity->entityType(), )) ->fields(array('timestamp' => REQUEST_TIME)) ->execute(); // Update cached value. - $this->history[$entity_type][$entity_id] = REQUEST_TIME; + $this->history[$entity->entityType()][$entity->id()] = REQUEST_TIME; } } diff --git a/core/modules/history/lib/Drupal/history/HistoryManagerInterface.php b/core/modules/history/lib/Drupal/history/HistoryManagerInterface.php index b9868c3..6094aef 100644 --- a/core/modules/history/lib/Drupal/history/HistoryManagerInterface.php +++ b/core/modules/history/lib/Drupal/history/HistoryManagerInterface.php @@ -33,15 +33,13 @@ public function getLastViewed($entity_type, $entity_ids); /** * Updates 'last viewed' timestamp of the entity for the current user. * - * @param string $entity_type - * The entity type. - * @param int $entity_id - * The entity ID that has been read. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity that history should be updated. * @param \Drupal\Core\Session\AccountInterface $account * (optional) The user account to update the history for. Defaults to the * current user. */ - public function updateLastViewed($entity_type, $entity_id, AccountInterface $account = NULL); + public function updateLastViewed(EntityInterface $entity, AccountInterface $account = NULL); /** * Purges outdated history. diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 2a8b104..58e43cc 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -744,13 +744,13 @@ function node_update_8012() { )); // Create new indexes. db_add_primary_key('history', array( + array('entity_type', 32), 'uid', 'entity_id', - array('entity_type', 32), )); db_add_index('history', 'history_entity', array( - 'entity_id', array('entity_type', 32), + 'entity_id', )); // Enable the history module without re-installing the schema.