diff --git a/core/includes/database.inc b/core/includes/database.inc index fc76b6f..7f1f278 100644 --- a/core/includes/database.inc +++ b/core/includes/database.inc @@ -34,20 +34,20 @@ * results that need to be presented on multiple pages, and the Tablesort * Extender for generating appropriate queries for sortable tables. * - * For example, one might wish to return a list of the most recent 10 nodes + * For example, one might wish to return a list of the most recent 10 rows * authored by a given user. Instead of directly issuing the SQL query * @code - * SELECT n.nid, n.title, n.created FROM node n WHERE n.uid = $uid LIMIT 0, 10; + * SELECT e.id, e.title, e.created FROM example e WHERE e.uid = $uid LIMIT 0, 10; * @endcode * one would instead call the Drupal functions: * @code - * $result = db_query_range('SELECT n.nid, n.title, n.created - * FROM {node} n WHERE n.uid = :uid', 0, 10, array(':uid' => $uid)); + * $result = db_query_range('SELECT e.id, e.title, e.created + * FROM {example} e WHERE e.uid = :uid', 0, 10, array(':uid' => $uid)); * foreach ($result as $record) { * // Perform operations on $record->title, etc. here. * } * @endcode - * Curly braces are used around "node" to provide table prefixing via + * Curly braces are used around "example" to provide table prefixing via * DatabaseConnection::prefixTables(). The explicit use of a user ID is pulled * out into an argument passed to db_query() so that SQL injection attacks * from user input can be caught and nullified. The LIMIT syntax varies between @@ -69,7 +69,7 @@ * * Named placeholders begin with a colon followed by a unique string. Example: * @code - * SELECT nid, title FROM {node} WHERE uid=:uid; + * SELECT id, title FROM {example} WHERE uid=:uid; * @endcode * * ":uid" is a placeholder that will be replaced with a literal value when @@ -81,7 +81,7 @@ * * Unnamed placeholders are simply a question mark. Example: * @code - * SELECT nid, title FROM {node} WHERE uid=?; + * SELECT id, title FROM {example} WHERE uid=?; * @endcode * * In this case, the array of arguments must be an indexed array of values to @@ -91,11 +91,11 @@ * running a LIKE query the SQL wildcard character, %, should be part of the * value, not the query itself. Thus, the following is incorrect: * @code - * SELECT nid, title FROM {node} WHERE title LIKE :title%; + * SELECT id, title FROM {example} WHERE title LIKE :title%; * @endcode * It should instead read: * @code - * SELECT nid, title FROM {node} WHERE title LIKE :title; + * SELECT id, title FROM {example} WHERE title LIKE :title; * @endcode * and the value for :title should include a % as appropriate. Again, note the * lack of quotation marks around :title. Because the value is not inserted @@ -109,7 +109,7 @@ * object-oriented API for defining a query structurally. For example, rather * than: * @code - * INSERT INTO node (nid, title, body) VALUES (1, 'my title', 'my body'); + * INSERT INTO {example} (id, uid, path, name) VALUES (1, 2, 'home', 'Home path'); * @endcode * one would instead write: * @code diff --git a/core/includes/form.inc b/core/includes/form.inc index 6956f04..8b7a446 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -4684,26 +4684,25 @@ function _form_set_attributes(&$element, $class = array()) { * $context['message'] = check_plain($node->label()); * } * - * // More advanced example: multi-step operation - load all nodes, five by five + * // More advanced example: multi-step operation - load all rows, five by five * function my_function_2(&$context) { * if (empty($context['sandbox'])) { * $context['sandbox']['progress'] = 0; - * $context['sandbox']['current_node'] = 0; - * $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField(); + * $context['sandbox']['current_id'] = 0; + * $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT id) FROM {example}')->fetchField(); * } * $limit = 5; - * $result = db_select('node') - * ->fields('node', array('nid')) - * ->condition('nid', $context['sandbox']['current_node'], '>') - * ->orderBy('nid') + * $result = db_select('example') + * ->fields('example', array('id')) + * ->condition('id', $context['sandbox']['current_id'], '>') + * ->orderBy('id') * ->range(0, $limit) * ->execute(); * foreach ($result as $row) { - * $node = node_load($row->nid, TRUE); - * $context['results'][] = $node->nid . ' : ' . check_plain($node->label()); + * $context['results'][] = $row->id . ' : ' . check_plain($row->title); * $context['sandbox']['progress']++; - * $context['sandbox']['current_node'] = $node->nid; - * $context['message'] = check_plain($node->label()); + * $context['sandbox']['current_id'] = $row->id; + * $context['message'] = check_plain($row->title); * } * if ($context['sandbox']['progress'] != $context['sandbox']['max']) { * $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; diff --git a/core/includes/menu.inc b/core/includes/menu.inc index d28316b..54de96d 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1463,10 +1463,10 @@ function menu_tree_collect_node_links(&$tree, &$node_links) { function menu_tree_check_access(&$tree, $node_links = array()) { if ($node_links) { $nids = array_keys($node_links); - $select = db_select('node', 'n'); - $select->addField('n', 'nid'); - $select->condition('n.status', 1); - $select->condition('n.nid', $nids, 'IN'); + $select = db_select('node_property_data', 'npd'); + $select->addField('npd', 'nid'); + $select->condition('npd.status', 1); + $select->condition('npd.nid', $nids, 'IN'); $select->addTag('node_access'); $nids = $select->execute()->fetchCol(); foreach ($nids as $nid) { diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php index c2a5a05..d5509a6 100644 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php @@ -32,11 +32,11 @@ public function orderRandom() { * yet selected. * * @code - * $query = db_select('node', 'n'); - * $query->join('node_revision', 'nr', 'n.vid = nr.vid'); + * $query = db_select('example', 'e'); + * $query->join('example_revision', 'er', 'e.vid = er.vid'); * $query * ->distinct() - * ->fields('n') + * ->fields('e') * ->orderBy('timestamp'); * @endcode * diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php index 267e10c..cc27e23 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php @@ -90,6 +90,13 @@ class DatabaseStorageController implements EntityStorageControllerInterface { protected $revisionKey; /** + * The table that stores properties, if the entity has multilingual support. + * + * @var string + */ + protected $dataTable; + + /** * The table that stores revisions, if the entity supports revisions. * * @var string @@ -127,6 +134,11 @@ public function __construct($entityType) { $this->uuidKey = FALSE; } + // Check if the entity type has a dedicated table for properties. + if (!empty($this->entityInfo['data_table'])) { + $this->dataTable = $this->entityInfo['data_table']; + } + // Check if the entity type supports revisions. if (!empty($this->entityInfo['entity_keys']['revision'])) { $this->revisionKey = $this->entityInfo['entity_keys']['revision']; @@ -321,6 +333,10 @@ protected function buildQuery($ids, $revision_id = FALSE) { $query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey}"); } + if (!empty($this->dataTable)) { + $query->join($this->dataTable, 'data', "data.{$this->idKey} = base.{$this->idKey}"); + } + // Add fields from the {entity} table. $entity_fields = $this->entityInfo['schema_fields_sql']['base_table']; @@ -345,6 +361,22 @@ protected function buildQuery($ids, $revision_id = FALSE) { $query->addExpression('base.' . $this->revisionKey . ' = revision.' . $this->revisionKey, 'isDefaultRevision'); } + // Add fields from the entity data_table. + if (!empty($this->dataTable)) { + // Add all fields from the {entity_data} table. + $entity_data_fields = drupal_map_assoc($this->entityInfo['schema_fields_sql']['data_table']); + // The id field is provided by entity, so remove it. + unset($entity_data_fields[$this->idKey]); + + if (!isset($entity_revision_fields)) { + $entity_revision_fields = array(); + } + + // Only add fields not covered by the base or the revision. + $entity_data_fields = array_diff($entity_data_fields, $entity_fields, $entity_revision_fields); + $query->fields('data', $entity_data_fields); + } + $query->fields('base', $entity_fields); if ($ids) { @@ -498,6 +530,14 @@ public function save(EntityInterface $entity) { $this->preSave($entity); $this->invokeHook('presave', $entity); + // Ensure the default langcode is stored in the base table. + // @todo clarify if it wouldn't be better to rename the column in the base + // table default_langcode as well. + if ($this->dataTable) { + $langcode = $entity->langcode; + $entity->langcode = $entity->default_langcode; + } + if (!$entity->isNew()) { if ($entity->isDefaultRevision()) { $return = drupal_write_record($this->entityInfo['base_table'], $entity, $this->idKey); @@ -507,6 +547,11 @@ public function save(EntityInterface $entity) { // with $isDefaultRevision = FALSE? $return = FALSE; } + // Ensure the appropriate langcodes are stored in the property data. + if ($this->dataTable) { + $entity->default_langcode = $entity->langcode; + $entity->langcode = $langcode; + } if ($this->revisionKey) { $this->saveRevision($entity); } @@ -516,6 +561,13 @@ public function save(EntityInterface $entity) { } else { $return = drupal_write_record($this->entityInfo['base_table'], $entity); + // Ensure the appropriate langcodes are stored in the property data. + // @todo clarify if it wouldn't be better to rename the column in the base + // table default_langcode as well. + if ($this->dataTable) { + $entity->default_langcode = $entity->langcode; + $entity->langcode = $langcode; + } if ($this->revisionKey) { $this->saveRevision($entity); } @@ -547,6 +599,18 @@ public function save(EntityInterface $entity) { * The entity object. */ protected function saveRevision(EntityInterface $entity) { + // Ensure when saving properties in a new language a new revision is created. + // @todo try to find a nicer/unified way to do this. + if ($this->dataTable && !$entity->isNewRevision()) { + $query = db_select($this->revisionTable) + ->condition($this->idKey, $entity->id()) + ->condition('langcode', $entity->langcode); + $query->addExpression('1'); + if (!$query->execute()->fetchField()) { + $entity->setNewRevision(); + } + } + // Convert the entity into an array as it might not have the same properties // as the entity, it is just a raw structure. $record = (array) $entity; @@ -590,11 +654,32 @@ protected function preSave(EntityInterface $entity) { } * Used after the entity is saved, but before invoking the insert or update * hook. * - * @param $update + * @param boolean $update * (bool) TRUE if the entity has been updated, or FALSE if it has been * inserted. */ - protected function postSave(EntityInterface $entity, $update) { } + protected function postSave(EntityInterface $entity, $update) { + // Write the data into the property data table if one is available. + if ($this->dataTable) { + // @todo try to find a better way to deal with updates. + $query = db_select($this->entityInfo['data_table']) + ->condition($this->idKey, $entity->id()) + ->condition('langcode', $entity->langcode); + $query->addExpression('1'); + if ($update && $query->execute()->fetchField()) { + // Update existing property data row. + $primary_keys = array( + $this->idKey, + 'langcode', + ); + drupal_write_record($this->entityInfo['data_table'], $entity, $primary_keys); + } + else { + // Insert new property data row. + drupal_write_record($this->entityInfo['data_table'], $entity); + } + } + } /** * Acts on entities before they are deleted. diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index b8c38ce..6fa7ae9 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -270,6 +270,9 @@ protected function processDefinition(&$definition, $plugin_id) { // Drupal\Core\Entity\DatabaseStorageControllerInterface::buildQuery(). if (isset($definition['base_table'])) { $definition['schema_fields_sql']['base_table'] = drupal_schema_fields_sql($definition['base_table']); + if (isset($definition['data_table'])) { + $definition['schema_fields_sql']['data_table'] = drupal_schema_fields_sql($definition['data_table']); + } if (isset($definition['revision_table'])) { $definition['schema_fields_sql']['revision_table'] = drupal_schema_fields_sql($definition['revision_table']); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php index f46c2c4..003d99c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php @@ -96,7 +96,7 @@ function getFeedEditArray($feed_url = NULL) { */ function getDefaultFeedItemCount() { // Our tests are based off of rss.xml, so let's find out how many elements should be related. - $feed_count = db_query_range('SELECT COUNT(*) FROM {node} n WHERE n.promote = 1 AND n.status = 1', 0, config('system.rss')->get('items.limit'))->fetchField(); + $feed_count = db_query_range('SELECT COUNT(DISTINCT nid) FROM {node_property_data} npd WHERE npd.promote = 1 AND npd.status = 1', 0, config('system.rss')->get('items.limit'))->fetchField(); return $feed_count > 10 ? 10 : $feed_count; } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 0187bda..a2b42f7 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -311,12 +311,12 @@ function book_block_view($delta = '') { elseif ($current_bid) { // Only display this block when the user is browsing a book. $select = db_select('node', 'n') - ->fields('n', array('title')) + ->fields('n', array('nid')) ->condition('n.nid', $node->book['bid']) ->addTag('node_access'); - $title = $select->execute()->fetchField(); + $nid = $select->execute()->fetchField(); // Only show the block if the user has view access for the top-level node. - if ($title) { + if ($nid) { $tree = menu_tree_all_data($node->book['menu_name'], $node->book); // There should only be one element at the top level. $data = array_shift($tree); @@ -392,20 +392,22 @@ function book_get_books() { if ($nids) { $query = db_select('book', 'b', array('fetch' => PDO::FETCH_ASSOC)); $query->join('node', 'n', 'b.nid = n.nid'); + $query->join('node_property_data', 'npd', 'n.nid = npd.nid'); $query->join('menu_links', 'ml', 'b.mlid = ml.mlid'); $query->addField('n', 'type', 'type'); - $query->addField('n', 'title', 'title'); $query->fields('b'); $query->fields('ml'); - $query->condition('n.nid', $nids, 'IN'); - $query->condition('n.status', 1); + $query->condition('npd.nid', $nids, 'IN'); + $query->condition('npd.status', 1); $query->orderBy('ml.weight'); $query->orderBy('ml.link_title'); $query->addTag('node_access'); $result2 = $query->execute(); foreach ($result2 as $link) { + $node = node_load($link['nid']); $link['href'] = $link['link_path']; $link['options'] = unserialize($link['options']); + $link['title'] = $node->label(); $all_books[$link['bid']] = $link; } } diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 26e9c8b..8645b66 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -82,11 +82,10 @@ function comment_admin_overview($form, &$form_state, $arg) { $query = db_select('comment', 'c') ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->extend('Drupal\Core\Database\Query\TableSortExtender'); - $query->join('node', 'n', 'n.nid = c.nid'); - $query->addField('n', 'title', 'node_title'); + $query->join('node_property_data', 'npd', 'npd.nid = c.nid'); $query->addTag('node_access'); $result = $query - ->fields('c', array('cid', 'subject', 'name', 'changed')) + ->fields('c', array('cid', 'nid', 'subject', 'name', 'changed')) ->condition('c.status', $status) ->limit(50) ->orderByHeader($header) @@ -97,8 +96,9 @@ function comment_admin_overview($form, &$form_state, $arg) { // We collect a sorted list of node_titles during the query to attach to the // comments later. foreach ($result as $row) { + $node = node_load($row->nid); $cids[] = $row->cid; - $node_titles[] = $row->node_title; + $node_titles[] = $node->label(); } $comments = comment_load_multiple($cids); diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index f47151f..615e74c 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -34,14 +34,16 @@ function comment_uninstall() { */ function comment_enable() { // Insert records into the node_comment_statistics for nodes that are missing. - $query = db_select('node', 'n'); - $query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = n.nid'); - $query->addField('n', 'created', 'last_comment_timestamp'); - $query->addField('n', 'uid', 'last_comment_uid'); - $query->addField('n', 'nid'); + $query = db_select('node_property_data', 'npd'); + $query->leftJoin('node_comment_statistics', 'ncs', 'ncs.nid = npd.nid'); + $query->addField('npd', 'created', 'last_comment_timestamp'); + $query->addField('npd', 'uid', 'last_comment_uid'); + $query->addField('npd', 'nid'); $query->addExpression('0', 'comment_count'); $query->addExpression('NULL', 'last_comment_name'); $query->isNull('ncs.comment_count'); + // @todo Replace by proper language handling. + $query->groupBy('npd.nid'); db_insert('node_comment_statistics') ->from($query) diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index c174293..2e1635b 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -502,13 +502,13 @@ function comment_permalink($cid) { */ function comment_get_recent($number = 10) { $query = db_select('comment', 'c'); - $query->innerJoin('node', 'n', 'n.nid = c.nid'); + $query->innerJoin('node_property_data', 'npd', 'npd.nid = c.nid'); $query->addTag('node_access'); $query->addMetaData('base_table', 'comment'); $comments = $query ->fields('c') ->condition('c.status', COMMENT_PUBLISHED) - ->condition('n.status', NODE_PUBLISHED) + ->condition('npd.status', NODE_PUBLISHED) ->orderBy('c.created', 'DESC') // Additionally order by cid to ensure that comments with the same timestamp // are returned in the exact order posted. diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index 79c3bc3..3253cb7 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -531,7 +531,7 @@ function comment_views_data_alter(&$data) { ); // Comment status of the node - $data['node']['comment'] = array( + $data['node_property_data']['comment'] = array( 'title' => t('Comment status'), 'help' => t('Whether comments are enabled or disabled on the node.'), 'field' => array( @@ -546,7 +546,7 @@ function comment_views_data_alter(&$data) { ), ); - $data['node']['uid_touch'] = array( + $data['node_property_data']['uid_touch'] = array( 'title' => t('User posted or commented'), 'help' => t('Display nodes only if a user posted the node or commented on the node.'), 'argument' => array( diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php index 4d447a5..6b50964 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -223,7 +223,7 @@ protected function updateNodeStatistics($nid) { } else { // Comments do not exist. - $node = db_query('SELECT uid, created FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject(); + $node = db_query('SELECT uid, created FROM {node_property_data} WHERE nid = :nid LIMIT 1', array(':nid' => $nid))->fetchObject(); db_update('node_comment_statistics') ->fields(array( 'cid' => 0, diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/wizard/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/wizard/Comment.php index d079af4..172aa6b 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/wizard/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/wizard/Comment.php @@ -58,7 +58,7 @@ class Comment extends WizardPluginBase { ), 'status_node' => array( 'value' => TRUE, - 'table' => 'node', + 'table' => 'node_property_data', 'field' => 'status', 'relationship' => 'nid' ) diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module index 459cbeb..c2f86b3 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -806,14 +806,14 @@ function forum_forum_load($tid = NULL) { $_forums = taxonomy_get_tree($vid, $tid, NULL, TRUE); if (count($_forums)) { - $query = db_select('node', 'n'); - $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid'); - $query->join('forum', 'f', 'n.vid = f.vid'); - $query->addExpression('COUNT(n.nid)', 'topic_count'); + $query = db_select('node_property_data', 'npd'); + $query->join('node_comment_statistics', 'ncs', 'npd.nid = ncs.nid'); + $query->join('forum', 'f', 'npd.vid = f.vid'); + $query->addExpression('COUNT(npd.nid)', 'topic_count'); $query->addExpression('SUM(ncs.comment_count)', 'comment_count'); $counts = $query ->fields('f', array('tid')) - ->condition('n.status', 1) + ->condition('npd.status', 1) ->groupBy('tid') ->addTag('node_access') ->execute() @@ -837,15 +837,15 @@ function forum_forum_load($tid = NULL) { } // Query "Last Post" information for this forum. - $query = db_select('node', 'n'); - $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', array(':tid' => $forum->tid)); - $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid'); + $query = db_select('node_property_data', 'npd'); + $query->join('forum', 'f', 'npd.vid = f.vid AND f.tid = :tid', array(':tid' => $forum->tid)); + $query->join('node_comment_statistics', 'ncs', 'npd.nid = ncs.nid'); $query->join('users', 'u', 'ncs.last_comment_uid = u.uid'); $query->addExpression('CASE ncs.last_comment_uid WHEN 0 THEN ncs.last_comment_name ELSE u.name END', 'last_comment_name'); $topic = $query ->fields('ncs', array('last_comment_timestamp', 'last_comment_uid')) - ->condition('n.status', 1) + ->condition('npd.status', 1) ->orderBy('last_comment_timestamp', 'DESC') ->range(0, 1) ->addTag('node_access') @@ -884,13 +884,13 @@ function forum_forum_load($tid = NULL) { * The number of new posts in the forum that have not been read by the user. */ function _forum_topics_unread($term, $uid) { - $query = db_select('node', 'n'); - $query->join('forum', 'f', 'n.vid = f.vid AND f.tid = :tid', array(':tid' => $term)); - $query->leftJoin('history', 'h', 'n.nid = h.nid AND h.uid = :uid', array(':uid' => $uid)); - $query->addExpression('COUNT(n.nid)', 'count'); + $query = db_select('node_property_data', 'npd'); + $query->join('forum', 'f', 'npd.vid = f.vid AND f.tid = :tid', array(':tid' => $term)); + $query->leftJoin('history', 'h', 'npd.nid = h.nid AND h.uid = :uid', array(':uid' => $uid)); + $query->addExpression('COUNT(npd.nid)', 'count'); return $query ->condition('status', 1) - ->condition('n.created', NODE_NEW_LIMIT, '>') + ->condition('npd.created', NODE_NEW_LIMIT, '>') ->isNull('h.nid') ->addTag('node_access') ->execute() @@ -958,17 +958,17 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { if ($nids) { $nodes = node_load_multiple($nids); - $query = db_select('node', 'n') + $query = db_select('node_property_data', 'npd') ->extend('Drupal\Core\Database\Query\TableSortExtender'); - $query->fields('n', array('nid')); + $query->fields('npd', array('nid')); - $query->join('node_comment_statistics', 'ncs', 'n.nid = ncs.nid'); + $query->join('node_comment_statistics', 'ncs', 'npd.nid = ncs.nid'); $query->fields('ncs', array('cid', 'last_comment_uid', 'last_comment_timestamp', 'comment_count')); $query->join('forum_index', 'f', 'f.nid = ncs.nid'); $query->addField('f', 'tid', 'forum_tid'); - $query->join('users', 'u', 'n.uid = u.uid'); + $query->join('users', 'u', 'npd.uid = u.uid'); $query->addField('u', 'name'); $query->join('users', 'u2', 'ncs.last_comment_uid = u2.uid'); @@ -978,7 +978,8 @@ function forum_get_topics($tid, $sortby, $forum_per_page) { $query ->orderBy('f.sticky', 'DESC') ->orderByHeader($forum_topic_list_header) - ->condition('n.nid', $nids); + ->condition('npd.nid', $nids) + ->groupBy('npd.nid'); $result = array(); foreach ($query->execute() as $row) { @@ -1386,7 +1387,7 @@ function _forum_update_forum_index($nid) { } else { // Comments do not exist. - $node = db_query('SELECT uid, created FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject(); + $node = db_query('SELECT uid, created FROM {node_property_data} WHERE nid = :nid LIMIT 1', array(':nid' => $nid))->fetchObject(); db_update('forum_index') ->fields( array( 'comment_count' => 0, diff --git a/core/modules/language/language.api.php b/core/modules/language/language.api.php index 6f19835..2ec0c4c 100644 --- a/core/modules/language/language.api.php +++ b/core/modules/language/language.api.php @@ -52,8 +52,8 @@ function hook_language_update($language) { function hook_language_delete($language) { // On nodes with this language, unset the language db_update('node') - ->fields(array('language' => '')) - ->condition('language', $language->langcode) + ->fields(array('langcode' => '')) + ->condition('langcode', $language->langcode) ->execute(); } diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index 5add3df..06ebea4 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -369,9 +369,9 @@ protected function submitNodeLanguage(array $form, array &$form_state) { /** * Form submission handler for the 'preview' action. * - * @param $form + * @param array $form * An associative array containing the structure of the form. - * @param $form_state + * @param array $form_state * A reference to a keyed array containing the current state of the form. */ public function preview(array $form, array &$form_state) { diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php index 3993d24..1d999c3 100644 --- a/core/modules/node/lib/Drupal/node/NodeStorageController.php +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php @@ -66,9 +66,8 @@ protected function buildQuery($ids, $revision_id = FALSE) { // alias timestamp to revision_timestamp and add revision_uid. $query = parent::buildQuery($ids, $revision_id); $fields =& $query->getFields(); - unset($fields['timestamp']); $query->addField('revision', 'timestamp', 'revision_timestamp'); - $fields['uid']['table'] = 'base'; + $fields['uid']['table'] = 'data'; $query->addField('revision', 'uid', 'revision_uid'); return $query; } @@ -80,7 +79,7 @@ protected function invokeHook($hook, EntityInterface $node) { if ($hook == 'insert' || $hook == 'update') { node_invoke($node, $hook); } - else if ($hook == 'predelete') { + elseif ($hook == 'predelete') { // 'delete' is triggered in 'predelete' is here to preserve hook ordering // from Drupal 7. node_invoke($node, 'delete'); @@ -95,32 +94,19 @@ protected function invokeHook($hook, EntityInterface $node) { protected function preSave(EntityInterface $node) { // Before saving the node, set changed and revision times. $node->changed = REQUEST_TIME; + + // Make sure the default language is set. + if (empty($node->default_langcode)) { + $node->default_langcode = $node->langcode; + } } /** * Overrides Drupal\Core\Entity\DatabaseStorageController::preSaveRevision(). */ protected function preSaveRevision(array &$record, EntityInterface $entity) { - if ($entity->isNewRevision()) { - // When inserting either a new node or a new node revision, $node->log - // must be set because {node_revision}.log is a text column and therefore - // cannot have a default value. However, it might not be set at this - // point (for example, if the user submitting a node form does not have - // permission to create revisions), so we ensure that it is at least an - // empty string in that case. - // @todo: Make the {node_revision}.log column nullable so that we can - // remove this check. - if (!isset($record['log'])) { - $record['log'] = ''; - } - } - elseif (!isset($record['log']) || $record['log'] === '') { - // If we are updating an existing node without adding a new revision, we - // need to make sure $node->log is unset whenever it is empty. As long as - // $node->log is unset, drupal_write_record() will not attempt to update - // the existing database column when re-saving the revision; therefore, - // this code allows us to avoid clobbering an existing log entry with an - // empty one. + // Make sure an existing log entry isn't overwritten unnecessarily. + if (empty($record['log'])) { unset($record['log']); } @@ -133,7 +119,9 @@ protected function preSaveRevision(array &$record, EntityInterface $entity) { /** * Overrides Drupal\Core\Entity\DatabaseStorageController::postSave(). */ - function postSave(EntityInterface $node, $update) { + protected function postSave(EntityInterface $node, $update) { + parent::postSave($node, $update); + // Update the node access table for this node, but only if it is the // default revision. There's no need to delete existing records if the node // is new. @@ -144,7 +132,7 @@ function postSave(EntityInterface $node, $update) { /** * Overrides Drupal\Core\Entity\DatabaseStorageController::preDelete(). */ - function preDelete($entities) { + protected function preDelete($entities) { if (module_exists('search')) { foreach ($entities as $id => $entity) { search_reindex($entity->nid, 'node'); 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 f161d81..24e80a9 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 @@ -25,7 +25,8 @@ * "default" = "Drupal\node\NodeFormController" * }, * base_table = "node", - * revision_table = "node_revision", + * data_table = "node_property_data", + * revision_table = "node_property_revision", * uri_callback = "node_uri", * fieldable = TRUE, * entity_keys = { @@ -102,6 +103,13 @@ class Node extends Entity implements ContentEntityInterface { public $langcode = LANGUAGE_NOT_SPECIFIED; /** + * The node default language code. + * + * @var string + */ + public $default_langcode; + + /** * The node title. * * @var string diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/argument/UidRevision.php b/core/modules/node/lib/Drupal/node/Plugin/views/argument/UidRevision.php index d93611e..6d117e4 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/argument/UidRevision.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/argument/UidRevision.php @@ -24,7 +24,7 @@ class UidRevision extends Uid { public function query($group_by = FALSE) { $this->ensureMyTable(); $placeholder = $this->placeholder(); - $this->query->add_where_expression(0, "$this->tableAlias.uid = $placeholder OR ((SELECT COUNT(*) FROM {node_revision} nr WHERE nr.uid = $placeholder AND nr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $this->argument)); + $this->query->add_where_expression(0, "$this->tableAlias.uid = $placeholder OR ((SELECT COUNT(*) FROM {node_property_revision} npr WHERE npr.uid = $placeholder AND npr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $this->argument)); } } diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/argument/Vid.php b/core/modules/node/lib/Drupal/node/Plugin/views/argument/Vid.php index d24c314..0466180 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/argument/Vid.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/argument/Vid.php @@ -28,9 +28,9 @@ class Vid extends Numeric { function title_query() { $titles = array(); - $results = db_select('node_revision', 'nr') - ->fields('nr', array('vid', 'nid', 'title')) - ->condition('nr.vid', $this->value) + $results = db_select('node_property_revision', 'npr') + ->fields('npr', array('vid', 'nid', 'title')) + ->condition('npr.vid', $this->value) ->execute() ->fetchAllAssoc('vid', PDO::FETCH_ASSOC); $nids = array(); diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/HistoryUserTimestamp.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/HistoryUserTimestamp.php index 3617bc6..dabf788 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/HistoryUserTimestamp.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/HistoryUserTimestamp.php @@ -30,8 +30,8 @@ public function init(ViewExecutable $view, &$options) { parent::init($view, $options); global $user; if ($user->uid) { - $this->additional_fields['created'] = array('table' => 'node', 'field' => 'created'); - $this->additional_fields['changed'] = array('table' => 'node', 'field' => 'changed'); + $this->additional_fields['created'] = array('table' => 'node_property_data', 'field' => 'created'); + $this->additional_fields['changed'] = array('table' => 'node_property_data', 'field' => 'changed'); if (module_exists('comment') && !empty($this->options['comments'])) { $this->additional_fields['last_comment'] = array('table' => 'node_comment_statistics', 'field' => 'last_comment_timestamp'); } 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 83c489a..b944ee5 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 @@ -41,7 +41,12 @@ public function buildOptionsForm(&$form, &$form_state) { $form['alter']['external'] = array('#access' => FALSE); } - public function query() {} + /** + * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::query(). + */ + public function query() { + $this->add_additional_fields(); + } function render($values) { if ($entity = $this->get_entity($values)) { 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 0701234..9db4975 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 @@ -29,7 +29,7 @@ class RevisionLink extends Link { public function init(ViewExecutable $view, &$options) { parent::init($view, $options); - $this->additional_fields['node_vid'] = array('table' => 'node_revision', 'field' => 'vid'); + $this->additional_fields['node_vid'] = array('table' => 'node_property_revision', 'field' => 'vid'); } public function access() { @@ -44,7 +44,7 @@ function render_link($data, $values) { // Current revision uses the node view path. $path = 'node/' . $node->nid; - if ($node->vid != $vid) { + if (!$node->isDefaultRevision()) { $path .= "/revisions/$vid/view"; } @@ -69,7 +69,7 @@ function render_link($data, $values) { */ function get_revision_entity($values, $op) { $vid = $this->get_value($values, 'node_vid'); - $node = $this->get_value($values); + $node = $this->get_entity($values); // Unpublished nodes ignore access control. $node->status = 1; // Ensure user has access to perform the operation on this node. 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 2bb53f1..1a315d9 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 @@ -33,7 +33,7 @@ function render_link($data, $values) { } // Current revision cannot be deleted. - if ($node->vid == $vid) { + if ($node->isDefaultRevision()) { return; } 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 11e66ff..ca8a32b 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 @@ -33,7 +33,7 @@ function render_link($data, $values) { } // Current revision cannot be reverted. - if ($node->vid == $vid) { + if ($node->isDefaultRevision()) { return; } diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/filter/UidRevision.php b/core/modules/node/lib/Drupal/node/Plugin/views/filter/UidRevision.php index f435e4d..2d9be91 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/filter/UidRevision.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/filter/UidRevision.php @@ -30,7 +30,7 @@ public function query($group_by = FALSE) { $args = array_values($this->value); $this->query->add_where_expression($this->options['group'], "$this->tableAlias.uid IN($placeholder) OR - ((SELECT COUNT(*) FROM {node_revision} nr WHERE nr.uid IN($placeholder) AND nr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $args), + ((SELECT COUNT(*) FROM {node_property_revision} npr WHERE npr.uid IN($placeholder) AND npr.nid = $this->tableAlias.nid) > 0)", array($placeholder => $args), $args); } diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php b/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php index fec2bfe..aec6007 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/wizard/Node.php @@ -31,7 +31,7 @@ class Node extends WizardPluginBase { /** * Set the created column. */ - protected $createdColumn = 'created'; + protected $createdColumn = 'node_property_data-created'; /** * Set default values for the path field options. @@ -54,7 +54,7 @@ class Node extends WizardPluginBase { protected $filters = array( 'status' => array( 'value' => TRUE, - 'table' => 'node', + 'table' => 'node_property_data', 'field' => 'status' ) ); @@ -67,7 +67,7 @@ class Node extends WizardPluginBase { public function getAvailableSorts() { // You can't execute functions in properties, so override the method return array( - 'title:DESC' => t('Title') + 'node_property_data-title:DESC' => t('Title') ); } @@ -146,7 +146,7 @@ protected function default_display_options() { // to a row style that uses fields. /* Field: Content: Title */ $display_options['fields']['title']['id'] = 'title'; - $display_options['fields']['title']['table'] = 'node'; + $display_options['fields']['title']['table'] = 'node_property_data'; $display_options['fields']['title']['field'] = 'title'; $display_options['fields']['title']['label'] = ''; $display_options['fields']['title']['alter']['alter_text'] = 0; diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/wizard/NodeRevision.php b/core/modules/node/lib/Drupal/node/Plugin/views/wizard/NodeRevision.php index 9c5073f..961d29b 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/wizard/NodeRevision.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/wizard/NodeRevision.php @@ -21,7 +21,7 @@ * @Plugin( * id = "node_revision", * module = "node", - * base_table = "node_revision", + * base_table = "node_property_revision", * title = @Translation("Content revisions") * ) */ @@ -37,7 +37,7 @@ class NodeRevision extends WizardPluginBase { */ protected $pathField = array( 'id' => 'vid', - 'table' => 'node_revision', + 'table' => 'node_property_revision', 'field' => 'vid', 'exclude' => TRUE, 'alter' => array( @@ -65,7 +65,7 @@ class NodeRevision extends WizardPluginBase { protected $filters = array( 'status' => array( 'value' => TRUE, - 'table' => 'node_revision', + 'table' => 'node_property_revision', 'field' => 'status' ) ); @@ -97,7 +97,7 @@ protected function default_display_options() { /* Field: Content revision: Created date */ $display_options['fields']['timestamp']['id'] = 'timestamp'; - $display_options['fields']['timestamp']['table'] = 'node_revision'; + $display_options['fields']['timestamp']['table'] = 'node_property_revision'; $display_options['fields']['timestamp']['field'] = 'timestamp'; $display_options['fields']['timestamp']['alter']['alter_text'] = 0; $display_options['fields']['timestamp']['alter']['make_link'] = 0; @@ -112,7 +112,7 @@ protected function default_display_options() { /* Field: Content revision: Title */ $display_options['fields']['title']['id'] = 'title'; - $display_options['fields']['title']['table'] = 'node_revision'; + $display_options['fields']['title']['table'] = 'node_property_revision'; $display_options['fields']['title']['field'] = 'title'; $display_options['fields']['title']['label'] = ''; $display_options['fields']['title']['alter']['alter_text'] = 0; diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php index a8e36b2..b6aaf1c 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php @@ -82,7 +82,7 @@ function testNodeAccessBasic() { } $this->drupalPost('node/add/article', $edit, t('Save')); - $nid = db_query('SELECT nid FROM {node} WHERE title = :title', array(':title' => $edit['title']))->fetchField(); + $nid = db_query('SELECT nid FROM {node_property_data} WHERE title = :title', array(':title' => $edit['title']))->fetchField(); $private_status = db_query('SELECT private FROM {node_access_test} where nid = :nid', array(':nid' => $nid))->fetchField(); $this->assertTrue($is_private == $private_status, 'The private status of the node was properly set in the node_access_test table.'); if ($is_private) { diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php index 3c02765..ed7e435 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php @@ -43,8 +43,9 @@ function testContentAdminSort() { } // Test that the default sort by node.changed DESC actually fires properly. - $nodes_query = db_select('node', 'n') - ->fields('n', array('nid')) + $nodes_query = db_select('node_property_data', 'npd') + ->distinct(TRUE) + ->fields('npd', array('nid')) ->orderBy('changed', 'DESC') ->execute() ->fetchCol(); @@ -54,12 +55,22 @@ function testContentAdminSort() { foreach ($this->xpath('//table/tbody/tr/td/div/input/@value') as $input) { $nodes_form[] = $input; } + + debug($nodes_form); + + // UGLY TESTBOT DEBUG START + foreach ($nodes_query as $key => $value) { + $this->assert(false, 'DEBUG: ' . $nodes_query[$key] . ' equals ' . $nodes_form[$key]); + } + // UGLY TESTBOT DEBUG END + $this->assertEqual($nodes_query, $nodes_form, 'Nodes are sorted in the form according to the default query.'); // Compare the rendered HTML node list to a query for the nodes ordered by // title to account for possible database-dependent sort order. - $nodes_query = db_select('node', 'n') - ->fields('n', array('nid')) + $nodes_query = db_select('node_property_data', 'npd') + ->distinct(TRUE) + ->fields('npd', array('nid')) ->orderBy('title') ->execute() ->fetchCol(); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index edcb007..30c204b 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -72,13 +72,13 @@ function testRecentNodeBlock() { $node3 = $this->drupalCreateNode($default_settings); // Change the changed time for node so that we can test ordering. - db_update('node') + db_update('node_property_data') ->fields(array( 'changed' => $node1->changed + 100, )) ->condition('nid', $node2->nid) ->execute(); - db_update('node') + db_update('node_property_data') ->fields(array( 'changed' => $node1->changed + 200, )) diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php index 9c3dd06..c512825 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php @@ -141,4 +141,5 @@ function testMultilingualDisplaySettings() { )); $this->assertEqual(current($body), $node->body['en'][0]['value'], 'Node body found.'); } + } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php index 6bb752f..1543f0f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php @@ -97,12 +97,12 @@ function testRevisions() { $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_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_property_revision} WHERE nid = :nid and vid = :vid', array(':nid' => $node->nid, ':vid' => $nodes[1]->vid))->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_revision') + db_update('node_property_revision') ->condition('vid', $nodes[2]->vid) ->fields(array( 'timestamp' => $old_revision_date, diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index 2ca2d3e..ba9f4c4 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -136,12 +136,16 @@ function node_build_filter_query(SelectInterface $query) { foreach ($filter_data as $index => $filter) { list($key, $value) = $filter; switch ($key) { + case 'type': + $query->condition('n.' . $key, $value); + break; + + // Part of node property data table. case 'status': // Note: no exploitable hole as $key/$value have already been checked when submitted list($key, $value) = explode('-', $value, 2); - case 'type': case 'language': - $query->condition('n.' . $key, $value); + $query->condition('npd.' . $key, $value); break; } } @@ -464,7 +468,7 @@ function node_admin_nodes() { $header = array( 'title' => array( 'data' => t('Title'), - 'field' => 'n.title', + 'field' => 'npd.title', ), 'type' => array( 'data' => t('Content type'), @@ -477,42 +481,43 @@ function node_admin_nodes() { ), 'status' => array( 'data' => t('Status'), - 'field' => 'n.status', + 'field' => 'npd.status', ), 'changed' => array( 'data' => t('Updated'), - 'field' => 'n.changed', + 'field' => 'npd.changed', 'sort' => 'desc', 'class' => array(RESPONSIVE_PRIORITY_LOW) ,) ); if ($multilingual) { - $header['language_name'] = array('data' => t('Language'), 'field' => 'n.langcode', 'class' => array(RESPONSIVE_PRIORITY_LOW)); + $header['language_name'] = array('data' => t('Language'), 'field' => 'npd.langcode', 'class' => array(RESPONSIVE_PRIORITY_LOW)); } $header['operations'] = array('data' => t('Operations')); $query = db_select('node', 'n') ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->extend('Drupal\Core\Database\Query\TableSortExtender'); + $query->innerJoin('node_property_data', 'npd', 'npd.nid = n.nid'); node_build_filter_query($query); if (!user_access('bypass node access')) { // If the user is able to view their own unpublished nodes, allow them // to see these in addition to published nodes. Check that they actually // have some unpublished nodes to view before adding the condition. - if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT nid FROM {node} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => 0))->fetchCol()) { + if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_property_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => 0))->fetchCol()) { $query->condition(db_or() - ->condition('n.status', 1) - ->condition('n.nid', $own_unpublished, 'IN') + ->condition('npd.status', 1) + ->condition('npd.nid', $own_unpublished, 'IN') ); } else { // If not, restrict the query to published nodes. - $query->condition('n.status', 1); + $query->condition('npd.status', 1); } } $nids = $query - ->fields('n',array('nid')) + ->fields('npd', array('nid')) ->limit(50) ->orderByHeader($header) ->addTag('node_access') @@ -677,14 +682,14 @@ function node_admin_nodes_submit($form, &$form_state) { */ function node_multiple_delete_confirm($form, &$form_state, $nodes) { $form['nodes'] = array('#prefix' => '', '#tree' => TRUE); + $node_entities = node_load_multiple(array_keys($nodes)); // array_filter returns only elements with TRUE values foreach ($nodes as $nid => $value) { - $title = db_query('SELECT title FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField(); $form['nodes'][$nid] = array( '#type' => 'hidden', '#value' => $nid, '#prefix' => '
  • ', - '#suffix' => check_plain($title) . "
  • \n", + '#suffix' => check_plain($node_entities[$nid]->label()) . "\n", ); } $form['operation'] = array('#type' => 'hidden', '#value' => 'delete'); diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 9e1ee1b..e5e3336 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -27,7 +27,7 @@ function node_schema() { // Defaults to NULL in order to avoid a brief period of potential // deadlocks on the index. 'vid' => array( - 'description' => 'The current {node_revision}.vid version identifier.', + 'description' => 'The current {node_property_revision}.vid version identifier.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, @@ -47,6 +47,68 @@ function node_schema() { 'not null' => TRUE, 'default' => '', ), + 'tnid' => array( + 'description' => 'The translation set id for this node, which equals the node id of the source post in each set.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), + 'translate' => array( + 'description' => 'A boolean indicating whether this translation page needs to be updated.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'indexes' => array( + 'node_type' => array(array('type', 4)), + 'tnid' => array('tnid'), + 'translate' => array('translate'), + ), + 'unique keys' => array( + 'vid' => array('vid'), + 'uuid' => array('uuid'), + ), + 'foreign keys' => array( + 'node_revision' => array( + 'table' => 'node_revision', + 'columns' => array('vid' => 'vid'), + ), + ), + 'primary key' => array('nid'), + ); + + // Node property storage. + $schema['node_property_data'] = array( + 'description' => 'Base table for node properties.', + 'fields' => array( + 'nid' => array( + 'description' => 'The primary identifier for a node.', + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + 'vid' => array( + 'description' => 'The current {node_property_revision}.vid version identifier.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + ), + 'langcode' => array( + 'description' => 'The {language}.langcode of this node.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + 'default_langcode' => array( + 'description' => 'The default {language}.langcode of this node.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), 'title' => array( 'description' => 'The title of this node, always treated as non-markup plain text.', 'type' => 'varchar', @@ -97,187 +159,187 @@ function node_schema() { 'not null' => TRUE, 'default' => 0, ), - 'tnid' => array( - 'description' => 'The translation set id for this node, which equals the node id of the source post in each set.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'translate' => array( - 'description' => 'A boolean indicating whether this translation page needs to be updated.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), ), 'indexes' => array( - 'node_changed' => array('changed'), - 'node_created' => array('created'), - 'node_frontpage' => array('promote', 'status', 'sticky', 'created'), - 'node_status_type' => array('status', 'type', 'nid'), - 'node_title_type' => array('title', array('type', 4)), - 'node_type' => array(array('type', 4)), - 'uid' => array('uid'), - 'tnid' => array('tnid'), - 'translate' => array('translate'), + 'node_created' => array('created'), + 'node_changed' => array('changed'), + 'node_frontpage' => array('promote', 'status', 'sticky', 'changed'), + 'node_status' => array('status', 'nid'), + 'node_title' => array('title'), + 'uid' => array('uid'), ), 'unique keys' => array( 'vid' => array('vid'), - 'uuid' => array('uuid'), ), 'foreign keys' => array( - 'node_revision' => array( - 'table' => 'node_revision', - 'columns' => array('vid' => 'vid'), + 'node_base' => array( + 'table' => 'node', + 'columns' => array('nid' => 'nid'), ), 'node_author' => array( 'table' => 'users', 'columns' => array('uid' => 'uid'), ), ), - 'primary key' => array('nid'), + 'primary key' => array('nid', 'vid', 'langcode'), ); - $schema['node_access'] = array( - 'description' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.', + // Node property revision storage. + $schema['node_property_revision'] = array( + 'description' => 'Stores information about each saved version of a {node}.', 'fields' => array( 'nid' => array( - 'description' => 'The {node}.nid this record affects.', + 'description' => 'The {node} this version belongs to.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, - 'default' => 0, ), - 'gid' => array( - 'description' => "The grant ID a user must possess in the specified realm to gain this row's privileges on the node.", - 'type' => 'int', + 'vid' => array( + 'description' => 'The primary identifier for this version.', + 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, - 'default' => 0, ), - 'realm' => array( - 'description' => 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.', + 'langcode' => array( + 'description' => 'The {language}.langcode of this version.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + 'default_langcode' => array( + 'description' => 'The default {language}.langcode of this version.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + 'title' => array( + 'description' => 'The title of this version, always treated as non-markup plain text.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), - 'grant_view' => array( - 'description' => 'Boolean indicating whether a user with the realm/grant pair can view this node.', + 'uid' => array( + 'description' => 'The {users}.uid that created this version.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'size' => 'tiny', ), - 'grant_update' => array( - 'description' => 'Boolean indicating whether a user with the realm/grant pair can edit this node.', + 'status' => array( + 'description' => 'Boolean indicating whether the node (at the time of this revision) is published (visible to non-administrators).', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 1, + ), + 'comment' => array( + 'description' => 'Whether comments are allowed on this node (at the time of this revision): 0 = no, 1 = closed (read only), 2 = open (read/write).', 'type' => 'int', - 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'size' => 'tiny', ), - 'grant_delete' => array( - 'description' => 'Boolean indicating whether a user with the realm/grant pair can delete this node.', + 'promote' => array( + 'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed on the front page.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'sticky' => array( + 'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed at the top of lists in which it appears.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'log' => array( + 'description' => 'The log entry explaining the changes in this version.', + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), + 'timestamp' => array( + 'description' => 'The Unix timestamp when this revision was saved.', 'type' => 'int', - 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'size' => 'tiny', ), ), - 'primary key' => array('nid', 'gid', 'realm'), + 'indexes' => array( + 'nid' => array('nid'), + 'uid' => array('uid'), + ), + 'unique keys' => array( + 'vid' => array('vid'), + ), 'foreign keys' => array( - 'affected_node' => array( + 'versioned_node' => array( 'table' => 'node', 'columns' => array('nid' => 'nid'), ), - ), + 'version_author' => array( + 'table' => 'users', + 'columns' => array('uid' => 'uid'), + ), + ), + 'primary key' => array('nid', 'vid', 'langcode'), ); - $schema['node_revision'] = array( - 'description' => 'Stores information about each saved version of a {node}.', + $schema['node_access'] = array( + 'description' => 'Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.', 'fields' => array( 'nid' => array( - 'description' => 'The {node} this version belongs to.', + 'description' => 'The {node}.nid this record affects.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), - 'vid' => array( - 'description' => 'The primary identifier for this version.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ), - 'uid' => array( - 'description' => 'The {users}.uid that created this version.', + 'gid' => array( + 'description' => "The grant ID a user must possess in the specified realm to gain this row's privileges on the node.", 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), - 'title' => array( - 'description' => 'The title of this version.', + 'realm' => array( + 'description' => 'The realm in which the user must possess the grant ID. Each node access node can define one or more realms.', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), - 'log' => array( - 'description' => 'The log entry explaining the changes in this version.', - 'type' => 'text', - 'not null' => TRUE, - 'size' => 'big', - ), - 'timestamp' => array( - 'description' => 'A Unix timestamp indicating when this version was created.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'status' => array( - 'description' => 'Boolean indicating whether the node (at the time of this revision) is published (visible to non-administrators).', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 1, - ), - 'comment' => array( - 'description' => 'Whether comments are allowed on this node (at the time of this revision): 0 = no, 1 = closed (read only), 2 = open (read/write).', + 'grant_view' => array( + 'description' => 'Boolean indicating whether a user with the realm/grant pair can view this node.', 'type' => 'int', + 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, + 'size' => 'tiny', ), - 'promote' => array( - 'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed on the front page.', + 'grant_update' => array( + 'description' => 'Boolean indicating whether a user with the realm/grant pair can edit this node.', 'type' => 'int', + 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, + 'size' => 'tiny', ), - 'sticky' => array( - 'description' => 'Boolean indicating whether the node (at the time of this revision) should be displayed at the top of lists in which it appears.', + 'grant_delete' => array( + 'description' => 'Boolean indicating whether a user with the realm/grant pair can delete this node.', 'type' => 'int', + 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, + 'size' => 'tiny', ), ), - 'indexes' => array( - 'nid' => array('nid'), - 'uid' => array('uid'), - ), - 'primary key' => array('vid'), + 'primary key' => array('nid', 'gid', 'realm'), 'foreign keys' => array( - 'versioned_node' => array( + 'affected_node' => array( 'table' => 'node', 'columns' => array('nid' => 'nid'), ), - 'version_author' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), ), ); @@ -365,7 +427,7 @@ function node_schema() { 'type' => 'int', 'not null' => TRUE, 'default' => 0, - 'size' => 'tiny' + 'size' => 'tiny', ), 'orig_type' => array( 'description' => 'The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0.', @@ -729,6 +791,160 @@ function node_update_8010() { } /** + * Add dedicated tables for node properties. + */ +function node_update_8011() { + $schema = node_schema(); + // Create property table if necessary. + if (!db_table_exists('node_property_data')) { + db_create_table('node_property_data', $schema['node_property_data']); + } + + // Create property revision table if necessary. + if (!db_table_exists('node_property_revision')) { + db_create_table('node_property_revision', $schema['node_property_revision']); + } +} + +/** + * Move property data to dedicated table. + */ +function node_update_8012(&$sandbox) { + if (!isset($sandbox['progress'])) { + $sandbox['progress'] = 0; + $sandbox['last'] = (int) db_query('SELECT npd.nid FROM {node_property_data npd} ORDER BY nid DESC')->fetchField(); + $sandbox['max'] = db_query('SELECT COUNT(*) FROM {node} n LEFT JOIN {node_property_data} npd ON npd.nid = n.nid WHERE npd.nid IS NULL')->fetchField(); + } + + // Create initial property data set if necessary. + if (!empty($sandbox['max'])) { + $source_query = db_select('node') + ->fields('node', array( + 'nid', + 'vid', + 'langcode', + 'title', + 'uid', + 'status', + 'created', + 'changed', + 'comment', + 'promote', + 'sticky', + )) + ->range(0, 10) + ->condition('nid', $sandbox['last'], '>') + ->orderBy('nid'); + $source_query->addField('node', 'langcode', 'default_langcode'); + db_insert('node_property_data')->from($source_query)->execute(); + $sandbox['last'] = db_query('SELECT npd.nid FROM {node_property_data} npd ORDER BY nid DESC')->fetchField(); + $sandbox['progress'] += 10; + } + + $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']); +} + +/** + * Move property revisions to dedicated table. + */ +function node_update_8013(&$sandbox) { + if (!isset($sandbox['progress'])) { + $sandbox['progress'] = 0; + $sandbox['last'] = (int) db_query('SELECT npr.vid FROM {node_property_revision} npr ORDER BY vid DESC')->fetchField(); + $sandbox['max'] = db_query('SELECT COUNT(*) FROM {node_revision} nr LEFT JOIN {node_property_revision} npr ON npr.vid = nr.vid WHERE npr.vid IS NULL')->fetchField(); + } + + // Create initial revision set if necessary. + if (!empty($sandbox['max'])) { + $source_query = db_select('node_revision', 'nr') + ->fields('nr', array( + 'nid', + 'vid', + 'uid', + 'title', + 'status', + 'comment', + 'promote', + 'sticky', + 'log', + 'timestamp', + )) + ->range(0, 10) + ->condition('nr.vid', $sandbox['last'], '>') + ->orderBy('nr.vid'); + $source_query->innerJoin('node_property_data', 'npd', 'npd.nid = nr.nid'); + $source_query->addField('npd', 'langcode'); + $source_query->addField('npd', 'default_langcode'); + + db_insert('node_property_revision')->from($source_query)->execute(); + $sandbox['last'] = db_query('SELECT npr.vid FROM {node_property_revision} npr ORDER BY vid DESC')->fetchField(); + $sandbox['progress'] += 10; + } + + $sandbox['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']); +} + +/** + * Cleanup old tables after finishing switch to dedicated property tables. + */ +function node_update_8014() { + $old_base_table_fields = array( + 'title', + 'uid', + 'status', + 'created', + 'changed', + 'comment', + 'promote', + 'sticky', + ); + $old_base_table_indexes = array( + 'node_created', + 'node_changed', + 'node_frontpage', + 'node_status_type', + 'node_title_type', + 'node_type', + 'uid', + ); + + $node_count = db_select('node')->countQuery()->execute()->fetchColumn(); + $node_revision_count = db_select('node_revision')->countQuery()->execute()->fetchColumn(); + $node_property_count = db_select('node_property_data')->countQuery()->execute()->fetchColumn(); + $node_property_revision_count = db_select('node_property_revision')->countQuery()->execute()->fetchColumn(); + + // Modify original tables if possible and necessary. + if ($node_property_count == $node_count) { + // Drop deprecated indexes. + foreach ($old_base_table_indexes as $old_index) { + if (db_index_exists('node', $old_index)) { + db_drop_index('node', $old_index); + } + } + // Recreate index. + if (!db_index_exists('node', 'node_type')) { + db_add_index('node', 'node_type', array(array('type', 4))); + } + // Drop deprecated fields. + foreach ($old_base_table_fields as $deprecated_base_field) { + if (db_field_exists('node', $deprecated_base_field)) { + db_drop_field('node', $deprecated_base_field); + } + } + } + else { + throw new DrupalUpdateException('The data migration from the node to the new node_property_data table seems to be inconsistent.'); + } + + if (db_table_exists('node_revision') && $node_revision_count == $node_property_revision_count) { + db_drop_table('node_revision'); + } + else { + throw new DrupalUpdateException('The data migration from the node_revision to the new node_property_revision table seems to be inconsistent.'); + } +} + +/** * @} End of "addtogroup updates-7.x-to-8.x" * The next series of updates should start at 9000. */ diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 5c11424..7ecc778 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1362,16 +1362,17 @@ function node_search_execute($keys = NULL, $conditions = NULL) { ->extend('Drupal\search\SearchQuery') ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); $query->join('node', 'n', 'n.nid = i.sid'); + $query->join('node_property_data', 'npd', 'npd.nid = n.nid'); $query - ->condition('n.status', 1) + ->condition('npd.status', 1) ->addTag('node_access') ->searchExpression($keys, 'node'); // Insert special keywords. $query->setOption('type', 'n.type'); - $query->setOption('langcode', 'n.langcode'); + $query->setOption('langcode', 'npd.langcode'); if ($query->setOption('term', 'ti.tid')) { - $query->join('taxonomy_index', 'ti', 'n.nid = ti.nid'); + $query->join('taxonomy_index', 'ti', 'npd.nid = ti.nid'); } // Only continue if the first pass query matches. if (!$query->executeFirstPass()) { @@ -1433,12 +1434,12 @@ function node_ranking() { 'sticky' => array( 'title' => t('Content is sticky at top of lists'), // The sticky flag is either 0 or 1, which is automatically normalized. - 'score' => 'n.sticky', + 'score' => 'npd.sticky', ), 'promote' => array( 'title' => t('Content is promoted to the front page'), // The promote flag is either 0 or 1, which is automatically normalized. - 'score' => 'n.promote', + 'score' => 'npd.promote', ), ); @@ -1447,7 +1448,7 @@ function node_ranking() { $ranking['recent'] = array( 'title' => t('Recently posted'), // Exponential decay with half-life of 6 months, starting at last indexed node - 'score' => 'POW(2.0, (GREATEST(n.created, n.changed) - :node_cron_last) * 6.43e-8)', + 'score' => 'POW(2.0, (GREATEST(npd.created, npd.changed) - :node_cron_last) * 6.43e-8)', 'arguments' => array(':node_cron_last' => $node_cron_last), ); } @@ -1462,8 +1463,9 @@ function node_user_cancel($edit, $account, $method) { case 'user_cancel_block_unpublish': // Unpublish nodes (current revisions). module_load_include('inc', 'node', 'node.admin'); - $nodes = db_select('node', 'n') - ->fields('n', array('nid')) + $nodes = db_select('node_property_data', 'npd') + ->distinct(TRUE) + ->fields('npd', array('nid')) ->condition('uid', $account->uid) ->execute() ->fetchCol(); @@ -1473,14 +1475,15 @@ function node_user_cancel($edit, $account, $method) { case 'user_cancel_reassign': // Anonymize nodes (current revisions). module_load_include('inc', 'node', 'node.admin'); - $nodes = db_select('node', 'n') - ->fields('n', array('nid')) + $nodes = db_select('node_property_data', 'npd') + ->distinct(TRUE) + ->fields('npd', array('nid')) ->condition('uid', $account->uid) ->execute() ->fetchCol(); node_mass_update($nodes, array('uid' => 0)); // Anonymize old revisions. - db_update('node_revision') + db_update('node_property_revision') ->fields(array('uid' => 0)) ->condition('uid', $account->uid) ->execute(); @@ -1498,14 +1501,15 @@ function node_user_cancel($edit, $account, $method) { function node_user_predelete($account) { // Delete nodes (current revisions). // @todo Introduce node_mass_delete() or make node_mass_update() more flexible. - $nodes = db_select('node', 'n') - ->fields('n', array('nid')) + $nodes = db_select('node_property_data', 'npd') + ->distinct(TRUE) + ->fields('npd', array('nid')) ->condition('uid', $account->uid) ->execute() ->fetchCol(); node_delete_multiple($nodes); // Delete old revisions. - $revisions = db_query('SELECT vid FROM {node_revision} WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol(); + $revisions = db_query('SELECT vid FROM {node_property_revision} WHERE uid = :uid', array(':uid' => $account->uid))->fetchCol(); foreach ($revisions as $revision) { node_revision_delete($revision); } @@ -1604,7 +1608,7 @@ function _node_revision_access(Node $node, $op = 'view', $account = NULL, $langc // different revisions so there is no need for a separate database check. // Also, if you try to revert to or delete the default revision, that's // not good. - if ($node->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() == 1 || $op == 'update' || $op == 'delete')) { + if ($node->isDefaultRevision() && (db_query('SELECT COUNT(vid) FROM {node_property_revision} WHERE nid = :nid', array(':nid' => $node->nid))->fetchField() == 1 || $op == 'update' || $op == 'delete')) { $access[$cid] = FALSE; } elseif (user_access('administer nodes', $account)) { @@ -1875,7 +1879,7 @@ function node_page_title(Node $node) { * A unix timestamp indicating the last time the node was changed. */ function node_last_changed($nid) { - return db_query('SELECT changed FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetch()->changed; + return db_query('SELECT changed FROM {node_property_data} WHERE nid = :nid ORDER BY changed DESC LIMIT 1', array(':nid' => $nid))->fetch()->changed; } /** @@ -1889,7 +1893,15 @@ function node_last_changed($nid) { */ function node_revision_list(Node $node) { $revisions = array(); - $result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revision} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = :nid ORDER BY r.vid DESC', array(':nid' => $node->nid)); + $result = db_query('SELECT npr.vid, npr.title, npr.log, npr.uid, n.vid AS current_vid, npr.timestamp, u.name ' . + 'FROM {node_property_revision} npr ' . + 'LEFT JOIN {node} n ON n.vid = npr.vid ' . + 'LEFT JOIN {node_property_data} npd ON npd.nid = n.nid ' . + 'INNER JOIN {users} u ON u.uid = npr.uid ' . + 'WHERE npr.nid = :nid ' . + 'ORDER BY npr.vid DESC', + array(':nid' => $node->nid) + ); foreach ($result as $revision) { $revisions[$revision->vid] = $revision; } @@ -1980,26 +1992,26 @@ function node_block_save($delta = '', $edit = array()) { * nodes visible to the current user. */ function node_get_recent($number = 10) { - $query = db_select('node', 'n'); + $query = db_select('node_property_data', 'npd'); if (!user_access('bypass node access')) { // If the user is able to view their own unpublished nodes, allow them // to see these in addition to published nodes. Check that they actually // have some unpublished nodes to view before adding the condition. - if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT nid FROM {node} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => NODE_NOT_PUBLISHED))->fetchCol()) { + if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_property_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => NODE_NOT_PUBLISHED))->fetchCol()) { $query->condition(db_or() - ->condition('n.status', NODE_PUBLISHED) - ->condition('n.nid', $own_unpublished, 'IN') + ->condition('npd.status', NODE_PUBLISHED) + ->condition('npd.nid', $own_unpublished, 'IN') ); } else { // If not, restrict the query to published nodes. - $query->condition('n.status', NODE_PUBLISHED); + $query->condition('npd.status', NODE_PUBLISHED); } } $nids = $query - ->fields('n', array('nid')) - ->orderBy('n.changed', 'DESC') + ->fields('npd', array('nid')) + ->orderBy('npd.changed', 'DESC') ->range(0, $number) ->addTag('node_access') ->execute() @@ -2251,11 +2263,12 @@ function node_feed($nids = FALSE, $channel = array()) { $rss_config = config('system.rss'); if ($nids === FALSE) { - $nids = db_select('node', 'n') - ->fields('n', array('nid', 'created')) - ->condition('n.promote', 1) - ->condition('n.status', 1) - ->orderBy('n.created', 'DESC') + $nids = db_select('node_property_data', 'npd') + ->fields('npd', array('nid', 'created')) + ->condition('npd.promote', 1) + ->condition('npd.status', 1) + ->groupBy('npd.nid') + ->orderBy('npd.created', 'DESC') ->range(0, $rss_config->get('items.limit')) ->addTag('node_access') ->execute() @@ -2362,12 +2375,12 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) { */ function node_page_default() { $site_config = config('system.site'); - $select = db_select('node', 'n') - ->fields('n', array('nid', 'sticky', 'created')) - ->condition('n.promote', 1) - ->condition('n.status', 1) - ->orderBy('n.sticky', 'DESC') - ->orderBy('n.created', 'DESC') + $select = db_select('node_property_data', 'npd') + ->fields('npd', array('nid', 'sticky', 'created')) + ->condition('npd.promote', 1) + ->condition('npd.status', 1) + ->orderBy('npd.sticky', 'DESC') + ->orderBy('npd.created', 'DESC') ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->limit(config('node.settings')->get('items_per_page')) ->addTag('node_access'); @@ -3069,7 +3082,7 @@ function node_query_node_access_alter(AlterableInterface $query) { if (!($table_info instanceof SelectInterface)) { $table = $table_info['table']; // If the node table is in the query, it wins immediately. - if ($table == 'node') { + if ($table == 'node' || $table == 'node_property_data') { $base_table = $table; break; } diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index eef3d42..5c4c12d 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -381,7 +381,7 @@ function node_revision_delete_confirm_submit($form, &$form_state) { watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->label(), '%revision' => $node_revision->vid)); 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(vid) FROM {node_revision} WHERE nid = :nid', array(':nid' => $node_revision->nid))->fetchField() > 1) { + if (db_query('SELECT COUNT(vid) FROM {node_property_revision} WHERE nid = :nid', array(':nid' => $node_revision->nid))->fetchField() > 1) { $form_state['redirect'] .= '/revisions'; } } diff --git a/core/modules/node/node.views.inc b/core/modules/node/node.views.inc index bf30614..937e0d5 100644 --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -31,6 +31,14 @@ function node_views_data() { ); $data['node']['table']['entity type'] = 'node'; + $data['node_property_data']['table']['group'] = t('Content'); + $data['node_property_data']['table']['entity type'] = 'node'; + $data['node_property_data']['table']['join']['node'] = array( + 'type' => 'INNER', + 'left_field' => 'nid', + 'field' => 'nid', + ); + // node table -- fields // nid @@ -61,7 +69,7 @@ function node_views_data() { // title // This definition has more items in it than it needs to as an example. - $data['node']['title'] = array( + $data['node_property_data']['title'] = array( 'title' => t('Title'), // The item it appears as on the UI, 'help' => t('The content title.'), // The help that appears on the UI, // Information for displaying a title as a field @@ -85,7 +93,7 @@ function node_views_data() { ); // created field - $data['node']['created'] = array( + $data['node_property_data']['created'] = array( 'title' => t('Post date'), // The item it appears as on the UI, 'help' => t('The date the content was posted.'), // The help that appears on the UI, 'field' => array( @@ -101,7 +109,7 @@ function node_views_data() { ); // changed field - $data['node']['changed'] = array( + $data['node_property_data']['changed'] = array( 'title' => t('Updated date'), // The item it appears as on the UI, 'help' => t('The date the content was last updated.'), // The help that appears on the UI, 'field' => array( @@ -135,8 +143,29 @@ function node_views_data() { ), ); + // Language field + if (module_exists('language')) { + $data['node']['langcode'] = array( + 'title' => t('Language'), + 'help' => t('The language the content is in.'), + 'field' => array( + 'id' => 'node_language', + 'click sortable' => TRUE, + ), + 'filter' => array( + 'id' => 'language', + ), + 'argument' => array( + 'id' => 'language', + ), + 'sort' => array( + 'id' => 'standard', + ), + ); + } + // published status - $data['node']['status'] = array( + $data['node_property_data']['status'] = array( 'title' => t('Published'), 'help' => t('Whether or not the content is published.'), 'field' => array( @@ -158,7 +187,7 @@ function node_views_data() { ); // published status + extra - $data['node']['status_extra'] = array( + $data['node_property_data']['status_extra'] = array( 'title' => t('Published or admin'), 'help' => t('Filters out unpublished content if the current user cannot view it.'), 'filter' => array( @@ -169,7 +198,7 @@ function node_views_data() { ); // promote status - $data['node']['promote'] = array( + $data['node_property_data']['promote'] = array( 'title' => t('Promoted to front page'), 'help' => t('Whether or not the content is promoted to the front page.'), 'field' => array( @@ -190,7 +219,7 @@ function node_views_data() { ); // sticky - $data['node']['sticky'] = array( + $data['node_property_data']['sticky'] = array( 'title' => t('Sticky'), // The item it appears as on the UI, 'help' => t('Whether or not the content is sticky.'), // The help that appears on the UI, // Information for displaying a title as a field @@ -212,27 +241,6 @@ function node_views_data() { ), ); - // Language field - if (module_exists('language')) { - $data['node']['langcode'] = array( - 'title' => t('Language'), - 'help' => t('The language the content is in.'), - 'field' => array( - 'id' => 'node_language', - 'click sortable' => TRUE, - ), - 'filter' => array( - 'id' => 'language', - ), - 'argument' => array( - 'id' => 'language', - ), - 'sort' => array( - 'id' => 'standard', - ), - ); - } - // Define some fields based upon views_handler_field_entity in the entity // table so they can be re-used with other query backends. // @see views_handler_field_entity @@ -273,7 +281,7 @@ function node_views_data() { // Bogus fields for aliasing purposes. - $data['node']['created_fulldate'] = array( + $data['node_property_data']['created_fulldate'] = array( 'title' => t('Created date'), 'help' => t('Date in the form of CCYYMMDD.'), 'argument' => array( @@ -282,7 +290,7 @@ function node_views_data() { ), ); - $data['node']['created_year_month'] = array( + $data['node_property_data']['created_year_month'] = array( 'title' => t('Created year + month'), 'help' => t('Date in the form of YYYYMM.'), 'argument' => array( @@ -291,7 +299,7 @@ function node_views_data() { ), ); - $data['node']['created_year'] = array( + $data['node_property_data']['created_year'] = array( 'title' => t('Created year'), 'help' => t('Date in the form of YYYY.'), 'argument' => array( @@ -300,7 +308,7 @@ function node_views_data() { ), ); - $data['node']['created_month'] = array( + $data['node_property_data']['created_month'] = array( 'title' => t('Created month'), 'help' => t('Date in the form of MM (01 - 12).'), 'argument' => array( @@ -309,7 +317,7 @@ function node_views_data() { ), ); - $data['node']['created_day'] = array( + $data['node_property_data']['created_day'] = array( 'title' => t('Created day'), 'help' => t('Date in the form of DD (01 - 31).'), 'argument' => array( @@ -318,7 +326,7 @@ function node_views_data() { ), ); - $data['node']['created_week'] = array( + $data['node_property_data']['created_week'] = array( 'title' => t('Created week'), 'help' => t('Date in the form of WW (01 - 53).'), 'argument' => array( @@ -327,7 +335,7 @@ function node_views_data() { ), ); - $data['node']['changed_fulldate'] = array( + $data['node_property_data']['changed_fulldate'] = array( 'title' => t('Updated date'), 'help' => t('Date in the form of CCYYMMDD.'), 'argument' => array( @@ -336,7 +344,7 @@ function node_views_data() { ), ); - $data['node']['changed_year_month'] = array( + $data['node_property_data']['changed_year_month'] = array( 'title' => t('Updated year + month'), 'help' => t('Date in the form of YYYYMM.'), 'argument' => array( @@ -345,7 +353,7 @@ function node_views_data() { ), ); - $data['node']['changed_year'] = array( + $data['node_property_data']['changed_year'] = array( 'title' => t('Updated year'), 'help' => t('Date in the form of YYYY.'), 'argument' => array( @@ -354,7 +362,7 @@ function node_views_data() { ), ); - $data['node']['changed_month'] = array( + $data['node_property_data']['changed_month'] = array( 'title' => t('Updated month'), 'help' => t('Date in the form of MM (01 - 12).'), 'argument' => array( @@ -363,7 +371,7 @@ function node_views_data() { ), ); - $data['node']['changed_day'] = array( + $data['node_property_data']['changed_day'] = array( 'title' => t('Updated day'), 'help' => t('Date in the form of DD (01 - 31).'), 'argument' => array( @@ -372,7 +380,7 @@ function node_views_data() { ), ); - $data['node']['changed_week'] = array( + $data['node_property_data']['changed_week'] = array( 'title' => t('Updated week'), 'help' => t('Date in the form of WW (01 - 53).'), 'argument' => array( @@ -382,7 +390,7 @@ function node_views_data() { ); // uid field - $data['node']['uid'] = array( + $data['node_property_data']['uid'] = array( 'title' => t('Author uid'), 'help' => t('The user authoring the content. If you need more fields than the uid add the content: author relationship'), 'relationship' => array( @@ -404,7 +412,7 @@ function node_views_data() { ), ); - $data['node']['uid_revision'] = array( + $data['node_property_data']['uid_revision'] = array( 'title' => t('User has a revision'), 'help' => t('All nodes where a certain user has a revision'), 'real field' => 'nid', @@ -420,11 +428,11 @@ function node_views_data() { // Define the base group of this table. Fields that don't // have a group defined will go into this field by default. - $data['node_revision']['table']['entity type'] = 'node'; - $data['node_revision']['table']['group'] = t('Content revision'); + $data['node_property_revision']['table']['entity type'] = 'node'; + $data['node_property_revision']['table']['group'] = t('Content revision'); // Advertise this table as a possible base table - $data['node_revision']['table']['base'] = array( + $data['node_property_revision']['table']['base'] = array( 'field' => 'vid', 'title' => t('Content revision'), 'help' => t('Content revision is a history of changes to content.'), @@ -434,7 +442,7 @@ function node_views_data() { ); // For other base tables, explain how we join - $data['node_revision']['table']['join'] = array( + $data['node_property_revision']['table']['join'] = array( // Directly links to node table. 'node' => array( 'left_field' => 'vid', @@ -443,7 +451,7 @@ function node_views_data() { ); // uid field for node revision - $data['node_revision']['uid'] = array( + $data['node_property_revision']['uid'] = array( 'title' => t('User'), 'help' => t('Relate a content revision to the user who created the revision.'), 'relationship' => array( @@ -455,7 +463,7 @@ function node_views_data() { ); // nid - $data['node_revision']['nid'] = array( + $data['node_property_revision']['nid'] = array( 'title' => t('Nid'), // The help that appears on the UI. 'help' => t('The revision NID of the content revision.'), @@ -488,7 +496,7 @@ function node_views_data() { ); // vid - $data['node_revision']['vid'] = array( + $data['node_property_revision']['vid'] = array( 'title' => t('Vid'), 'help' => t('The revision ID of the content revision.'), // Information for displaying the vid @@ -520,7 +528,7 @@ function node_views_data() { ); // published status - $data['node_revision']['status'] = array( + $data['node_property_revision']['status'] = array( 'title' => t('Published'), 'help' => t('Whether or not the content is published.'), 'field' => array( @@ -542,7 +550,7 @@ function node_views_data() { ); // title - $data['node_revision']['title'] = array( + $data['node_property_revision']['title'] = array( 'title' => t('Title'), // The item it appears as on the UI, 'help' => t('The content title.'), // The help that appears on the UI, // Information for displaying a title as a field @@ -563,7 +571,7 @@ function node_views_data() { ); // log field - $data['node_revision']['log'] = array( + $data['node_property_revision']['log'] = array( 'title' => t('Log message'), // The item it appears as on the UI, 'help' => t('The log message entered when the revision was created.'), // The help that appears on the UI, // Information for displaying a title as a field @@ -577,7 +585,7 @@ function node_views_data() { // revision timestamp // changed field - $data['node_revision']['timestamp'] = array( + $data['node_property_revision']['timestamp'] = array( 'title' => t('Updated date'), // The item it appears as on the UI, 'help' => t('The date the node was last updated.'), // The help that appears on the UI, 'field' => array( @@ -592,7 +600,7 @@ function node_views_data() { ), ); - $data['node_revision']['link_to_revision'] = array( + $data['node_property_revision']['link_to_revision'] = array( 'field' => array( 'title' => t('Link'), 'help' => t('Provide a simple link to the revision.'), @@ -600,7 +608,7 @@ function node_views_data() { ), ); - $data['node_revision']['revert_revision'] = array( + $data['node_property_revision']['revert_revision'] = array( 'field' => array( 'title' => t('Revert link'), 'help' => t('Provide a simple link to revert to the revision.'), @@ -608,7 +616,7 @@ function node_views_data() { ), ); - $data['node_revision']['delete_revision'] = array( + $data['node_property_revision']['delete_revision'] = array( 'field' => array( 'title' => t('Delete link'), 'help' => t('Provide a simple link to delete the content revision.'), @@ -650,7 +658,7 @@ function node_views_data() { // Explain how this table joins to others. $data['history']['table']['join'] = array( // Directly links to node table. - 'node' => array( + 'node_property_data' => array( 'table' => 'history', 'left_field' => 'nid', 'field' => 'nid', diff --git a/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php b/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php index 2cfe9e5..385d993 100644 --- a/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php +++ b/core/modules/poll/lib/Drupal/poll/Tests/PollExpirationTest.php @@ -58,8 +58,8 @@ function testAutoExpire() { // Test expiration. Since REQUEST_TIME is a constant and we don't // want to keep SimpleTest waiting until the moment of expiration arrives, // we forcibly change the expiration date in the database. - $created = db_query('SELECT created FROM {node} WHERE nid = :nid', array(':nid' => $poll_nid))->fetchField(); - db_update('node') + $created = db_query('SELECT created FROM {node_property_data} WHERE nid = :nid', array(':nid' => $poll_nid))->fetchField(); + db_update('node_property_data') ->fields(array('created' => $created - ($poll_expiration * 1.01))) ->condition('nid', $poll_nid) ->execute(); diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module index d3f8d3a..10280f7 100644 --- a/core/modules/poll/poll.module +++ b/core/modules/poll/poll.module @@ -137,12 +137,13 @@ function poll_block_info() { function poll_block_view($delta = '') { if (user_access('access content')) { // Retrieve the latest poll. - $select = db_select('node', 'n'); - $select->join('poll', 'p', 'p.nid = n.nid'); - $select->fields('n', array('nid')) - ->condition('n.status', 1) + $select = db_select('node_property_data', 'npd'); + $select->join('poll', 'p', 'p.nid = npd.nid'); + $select->fields('npd', array('nid')) + ->distinct(TRUE) + ->condition('npd.status', 1) ->condition('p.active', 1) - ->orderBy('n.created', 'DESC') + ->orderBy('npd.created', 'DESC') ->range(0, 1) ->addTag('node_access'); @@ -165,7 +166,7 @@ function poll_block_view($delta = '') { * Closes polls that have exceeded their allowed runtime. */ function poll_cron() { - $nids = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < :request_time AND p.active = :active AND p.runtime <> :runtime', array(':request_time' => REQUEST_TIME, ':active' => 1, ':runtime' => 0))->fetchCol(); + $nids = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node_property_data} npd ON p.nid = npd.nid WHERE (npd.created + p.runtime) < :request_time AND p.active = :active AND p.runtime <> :runtime', array(':request_time' => REQUEST_TIME, ':active' => 1, ':runtime' => 0))->fetchCol(); if (!empty($nids)) { db_update('poll') ->fields(array('active' => 0)) diff --git a/core/modules/poll/poll.pages.inc b/core/modules/poll/poll.pages.inc index b67d8f9..da1138c 100644 --- a/core/modules/poll/poll.pages.inc +++ b/core/modules/poll/poll.pages.inc @@ -16,24 +16,24 @@ function poll_page() { $polls_per_page = 15; - $count_select = db_select('node', 'n'); + $count_select = db_select('node_property_data', 'npd'); $count_select->addExpression('COUNT(*)', 'expression'); - $count_select->join('poll', 'p', 'p.nid = n.nid'); - $count_select->condition('n.status', 1); + $count_select->join('poll', 'p', 'p.nid = npd.nid'); + $count_select->condition('npd.status', 1); + $count_select->groupBy('npd.nid'); // List all polls. - $select = db_select('node', 'n'); - $select->join('poll', 'p', 'p.nid = n.nid'); - $select->join('poll_choice', 'c', 'c.nid = n.nid'); + $select = db_select('node_property_data', 'npd'); + $select->join('poll', 'p', 'p.nid = npd.nid'); + $select->join('poll_choice', 'c', 'c.nid = npd.nid'); $select->addExpression('SUM(c.chvotes)', 'votes'); - $select = $select->fields('n', array('nid', 'title', 'created')) + $select = $select->fields('npd', array('nid', 'title', 'created')) ->fields('p', array('active')) - ->condition('n.status', 1) - ->orderBy('n.created', 'DESC') - ->groupBy('n.nid') - ->groupBy('n.title') + ->condition('npd.status', 1) + ->orderBy('npd.created', 'DESC') + ->groupBy('npd.nid') ->groupBy('p.active') - ->groupBy('n.created') + ->groupBy('npd.created') ->extend('Drupal\Core\Database\Query\PagerSelectExtender') ->limit($polls_per_page) ->addTag('node_access'); @@ -41,10 +41,11 @@ function poll_page() { $queried_nodes = $select->execute() ->fetchAllAssoc('nid'); + $node_entities = node_load_multiple(array_keys($queried_nodes)); + $output = ''; $output .= theme('pager'); diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index 0dd0a84..a643b03 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -117,8 +117,8 @@ function hook_search_reset() { * @ingroup search */ function hook_search_status() { - $total = db_query('SELECT COUNT(*) FROM {node} WHERE status = 1')->fetchField(); - $remaining = db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0")->fetchField(); + $total = db_query('SELECT COUNT(*) FROM {example} WHERE status = 1')->fetchField(); + $remaining = db_query("SELECT COUNT(*) FROM {example} e LEFT JOIN {search_dataset} d ON d.type = 'example' AND d.sid = e.id WHERE e.status = 1 AND d.sid IS NULL OR d.reindex <> 0")->fetchField(); return array('remaining' => $remaining, 'total' => $total); } @@ -198,17 +198,17 @@ function hook_search_execute($keys = NULL, $conditions = NULL) { $query = db_select('search_index', 'i', array('target' => 'slave')) ->extend('Drupal\search\SearchQuery') ->extend('Drupal\Core\Database\Query\PagerSelectExtender'); - $query->join('node', 'n', 'n.nid = i.sid'); + $query->join('example', 'e', 'e.id = i.sid'); $query - ->condition('n.status', 1) - ->addTag('node_access') - ->searchExpression($keys, 'node'); + ->condition('e.status', 1) + ->addTag('example_access') + ->searchExpression($keys, 'example'); // Insert special keywords. - $query->setOption('type', 'n.type'); - $query->setOption('langcode', 'n.langcode'); + $query->setOption('type', 'e.type'); + $query->setOption('langcode', 'e.langcode'); if ($query->setOption('term', 'ti.tid')) { - $query->join('taxonomy_index', 'ti', 'n.nid = ti.nid'); + $query->join('taxonomy_index', 'ti', 'e.id = ti.id'); } // Only continue if the first pass query matches. if (!$query->executeFirstPass()) { @@ -225,29 +225,29 @@ function hook_search_execute($keys = NULL, $conditions = NULL) { $results = array(); foreach ($find as $item) { // Render the node. - $node = node_load($item->sid); - $build = node_view($node, 'search_result', $item->langcode); + $example = example_load($item->sid); + $build = example_view($example, 'search_result', $item->langcode); unset($build['#theme']); - $node->rendered = drupal_render($build); + $example->rendered = drupal_render($build); // Fetch comments for snippet. - $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node, $item->langcode); + $example->rendered .= ' ' . module_invoke('comment', 'node_update_index', $example, $item->langcode); - $extra = module_invoke_all('node_search_result', $node, $item->langcode); + $extra = module_invoke_all('node_search_result', $example, $item->langcode); $language = language_load($item->langcode); - $uri = $node->uri(); + $uri = $example->uri(); $results[] = array( 'link' => url($uri['path'], array_merge($uri['options'], array('absolute' => TRUE, 'language' => $language))), - 'type' => check_plain(node_get_type_label($node)), - 'title' => $node->label($item->langcode), - 'user' => theme('username', array('account' => $node)), - 'date' => $node->get('changed', $item->langcode), - 'node' => $node, + 'type' => check_plain(node_get_type_label($example)), + 'title' => $example->label($item->langcode), + 'user' => theme('username', array('account' => $example)), + 'date' => $example->get('changed', $item->langcode), + 'node' => $example, 'extra' => $extra, 'score' => $item->calculated_score, - 'snippet' => search_excerpt($keys, $node->rendered, $item->langcode), - 'langcode' => $node->langcode, + 'snippet' => search_excerpt($keys, $example->rendered, $item->langcode), + 'langcode' => $example->langcode, ); } return $results; diff --git a/core/modules/search/search.module b/core/modules/search/search.module index a32b5c3..71b795b 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -647,10 +647,9 @@ function search_index($sid, $module, $text, $langcode) { if (preg_match('!(?:node|book)/(?:view/)?([0-9]+)!i', $path, $match)) { $linknid = $match[1]; if ($linknid > 0) { - $node = db_query('SELECT title, nid, vid FROM {node} WHERE nid = :nid', array(':nid' => $linknid), array('target' => 'slave'))->fetchObject(); $link = TRUE; - // Do not use $node->label(), $node comes from the database. - $linktitle = $node->title; + $node = node_load($linknid); + $linktitle = $node->label(); } } } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php index ebadf43..818d9f2 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -279,7 +279,7 @@ protected function drupalCreateNode(array $settings = array()) { $node->save(); // Small hack to link revisions to our test user. - db_update('node_revision') + db_update('node_property_revision') ->fields(array('uid' => $node->uid)) ->condition('vid', $node->vid) ->execute(); diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index f11f3ed..ee8c3ca 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -263,17 +263,18 @@ function statistics_cron() { */ function statistics_title_list($dbfield, $dbrows) { if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) { - $query = db_select('node', 'n'); + $query = db_select('node_property_data', 'npd'); $query->addTag('node_access'); - $query->join('node_counter', 's', 'n.nid = s.nid'); - $query->join('users', 'u', 'n.uid = u.uid'); + $query->join('node_counter', 's', 'npd.nid = s.nid'); + $query->join('users', 'u', 'npd.uid = u.uid'); return $query - ->fields('n', array('nid', 'title')) + ->fields('npd', array('nid', 'title')) ->fields('u', array('uid', 'name')) ->condition($dbfield, 0, '<>') - ->condition('n.status', 1) + ->condition('npd.status', 1) ->orderBy($dbfield, 'DESC') + ->groupBy('npd.nid') ->range(0, $dbrows) ->execute(); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Database/RegressionTest.php b/core/modules/system/lib/Drupal/system/Tests/Database/RegressionTest.php index 4e4f364..df0e530 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Database/RegressionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Database/RegressionTest.php @@ -64,7 +64,7 @@ function testDBFieldExists() { * Tests the db_index_exists() function. */ function testDBIndexExists() { - $this->assertIdentical(TRUE, db_index_exists('node', 'node_created'), 'Returns true for existent index.'); + $this->assertIdentical(TRUE, db_index_exists('node', 'node_type'), 'Returns true for existent index.'); $this->assertIdentical(FALSE, db_index_exists('node', 'nosuchindex'), 'Returns false for nonexistent index.'); } } diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index 92f5701..d0a700e 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -83,7 +83,7 @@ function tracker_cron() { $batch_size = config('tracker.settings')->get('cron_index_limit'); if ($max_nid > 0) { $last_nid = FALSE; - $result = db_query_range('SELECT nid, uid, status FROM {node} WHERE nid <= :max_nid ORDER BY nid DESC', 0, $batch_size, array(':max_nid' => $max_nid), array('target' => 'slave')); + $result = db_query_range('SELECT nid, uid, status FROM {node_property_data} WHERE nid <= :max_nid GROUP BY nid ORDER BY nid DESC', 0, $batch_size, array(':max_nid' => $max_nid), array('target' => 'slave')); $count = 0; @@ -268,7 +268,7 @@ function tracker_comment_delete($comment) { * The node updated timestamp or comment timestamp. */ function _tracker_add($nid, $uid, $changed) { - $node = db_query('SELECT nid, status, uid, changed FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject(); + $node = db_query('SELECT nid, status, uid, changed FROM {node_property_data} WHERE nid = :nid ORDER BY changed DESC, status DESC LIMIT 1', array(':nid' => $nid))->fetchObject(); // Adding a comment can only increase the changed timestamp, so our // calculation here is simple. @@ -307,7 +307,7 @@ function _tracker_add($nid, $uid, $changed) { * is the greatest. */ function _tracker_calculate_changed($nid) { - $changed = db_query('SELECT changed FROM {node} WHERE nid = :nid', array(':nid' => $nid), array('target' => 'slave'))->fetchField(); + $changed = db_query('SELECT changed FROM {node_property_data} WHERE nid = :nid ORDER BY changed DESC LIMIT 1', array(':nid' => $nid), array('target' => 'slave'))->fetchField(); $latest_comment = db_query_range('SELECT cid, changed FROM {comment} WHERE nid = :nid AND status = :status ORDER BY changed DESC', 0, 1, array( ':nid' => $nid, ':status' => COMMENT_PUBLISHED, @@ -329,7 +329,7 @@ function _tracker_calculate_changed($nid) { * The last changed timestamp of the node. */ function _tracker_remove($nid, $uid = NULL, $changed = NULL) { - $node = db_query('SELECT nid, status, uid, changed FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchObject(); + $node = db_query('SELECT nid, status, uid, changed FROM {node_property_data} WHERE nid = :nid ORDER BY changed DESC, status DESC LIMIT 1', array(':nid' => $nid))->fetchObject(); // The user only keeps his or her subscription if both of the following are true: // (1) The node exists. diff --git a/core/modules/tracker/tracker.pages.inc b/core/modules/tracker/tracker.pages.inc index 853f50d..131eba7 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -50,9 +50,20 @@ function tracker_page($account = NULL, $set_title = FALSE) { $rows = array(); if (!empty($nodes)) { // Now, get the data and put into the placeholder array. - $result = db_query('SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid WHERE n.nid IN (:nids)', array(':nids' => array_keys($nodes)), array('target' => 'slave')); + $result = db_query('SELECT npd.nid, npd.title, n.type, npd.changed, npd.uid, u.name, l.comment_count ' . + 'FROM {node_property_data} npd ' . + 'INNER JOIN {node} n ON n.nid = npd.nid ' . + 'INNER JOIN {node_comment_statistics} l ON npd.nid = l.nid ' . + 'INNER JOIN {users} u ON npd.uid = u.uid ' . + 'WHERE npd.nid IN (:nids) ' . + 'GROUP BY npd.nid ' . + 'ORDER BY npd.changed DESC ', + array(':nids' => array_keys($nodes)), array('target' => 'slave') + ); + $node_entities = node_load_multiple(array_keys($nodes)); foreach ($result as $node) { $node->last_activity = $nodes[$node->nid]->changed; + $node->title = $node_entities[$node->nid]->label(); $nodes[$node->nid] = $node; } diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index 5a67213..1d5f547 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -486,11 +486,13 @@ function translation_node_get_translations($tnid) { if (!isset($translations[$tnid])) { $translations[$tnid] = array(); - $result = db_select('node', 'n') - ->fields('n', array('nid', 'type', 'uid', 'status', 'title', 'langcode')) + $query = db_select('node_property_data', 'npd'); + $query->innerJoin('node', 'n', 'n.nid = npd.nid AND n.langcode = npd.langcode'); + $query->fields('npd', array('nid', 'uid', 'status', 'title', 'langcode')) + ->fields('n', array('type')) ->condition('n.tnid', $tnid) - ->addTag('node_access') - ->execute(); + ->addTag('node_access'); + $result = $query->execute(); foreach ($result as $node) { $translations[$tnid][$node->langcode] = $node; diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php index 0c3002c..ec4bdea 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -104,8 +104,8 @@ function hook_user_cancel($edit, $account, $method) { case 'user_cancel_block_unpublish': // Unpublish nodes (current revisions). module_load_include('inc', 'node', 'node.admin'); - $nodes = db_select('node', 'n') - ->fields('n', array('nid')) + $nodes = db_select('node_property_data', 'npd') + ->fields('npd', array('nid')) ->condition('uid', $account->uid) ->execute() ->fetchCol(); @@ -115,14 +115,14 @@ function hook_user_cancel($edit, $account, $method) { case 'user_cancel_reassign': // Anonymize nodes (current revisions). module_load_include('inc', 'node', 'node.admin'); - $nodes = db_select('node', 'n') - ->fields('n', array('nid')) + $nodes = db_select('node_property_data', 'npd') + ->fields('npd', array('nid')) ->condition('uid', $account->uid) ->execute() ->fetchCol(); node_mass_update($nodes, array('uid' => 0)); // Anonymize old revisions. - db_update('node_revision') + db_update('node_property_revision') ->fields(array('uid' => 0)) ->condition('uid', $account->uid) ->execute(); diff --git a/core/modules/user/user.views.inc b/core/modules/user/user.views.inc index 295278a..6af694b 100644 --- a/core/modules/user/user.views.inc +++ b/core/modules/user/user.views.inc @@ -48,7 +48,7 @@ function user_views_data() { 'title' => t('Content authored'), 'help' => t('Relate content to the user who created it. This relationship will create one record for each content item created by the user.'), 'id' => 'standard', - 'base' => 'node', + 'base' => 'node_property_data', 'base field' => 'uid', 'field' => 'uid', 'label' => t('nodes'), @@ -78,7 +78,7 @@ function user_views_data() { 'argument field' => 'uid', 'base' => 'node', 'field' => 'nid', - 'relationship' => 'node:uid' + 'relationship' => 'node_property_data:uid' ), ); diff --git a/core/modules/views/config/views.view.archive.yml b/core/modules/views/config/views.view.archive.yml index f2b3a62..db2151d 100644 --- a/core/modules/views/config/views.view.archive.yml +++ b/core/modules/views/config/views.view.archive.yml @@ -30,13 +30,13 @@ display: sorts: created: id: created - table: node + table: node_property_data field: created order: DESC arguments: created_year_month: id: created_year_month - table: node + table: node_property_data field: created_year_month default_action: summary exception: @@ -54,7 +54,7 @@ display: filters: status: id: status - table: node + table: node_property_data field: status value: 1 group: 0 @@ -88,7 +88,7 @@ display: arguments: created_year_month: id: created_year_month - table: node + table: node_property_data field: created_year_month default_action: summary exception: diff --git a/core/modules/views/config/views.view.backlinks.yml b/core/modules/views/config/views.view.backlinks.yml index 8c1f2a7..3c19752 100644 --- a/core/modules/views/config/views.view.backlinks.yml +++ b/core/modules/views/config/views.view.backlinks.yml @@ -39,7 +39,7 @@ display: fields: title: id: title - table: node + table: node_property_data field: title label: '' link_to_node: 1 @@ -60,7 +60,7 @@ display: filters: status: id: status - table: node + table: node_property_data field: status value: 1 group: 0 diff --git a/core/modules/views/config/views.view.comments_recent.yml b/core/modules/views/config/views.view.comments_recent.yml index 6e86a0c..5a019f5 100644 --- a/core/modules/views/config/views.view.comments_recent.yml +++ b/core/modules/views/config/views.view.comments_recent.yml @@ -49,15 +49,15 @@ display: label: '' date_format: 'time ago' sorts: - timestamp: - id: timestamp + changed: + id: changed table: comment field: changed order: DESC filters: status_extra: id: status_extra - table: node + table: node_property_data field: status_extra relationship: nid group: 0 @@ -83,7 +83,7 @@ display: fields: title: id: title - table: node + table: node_property_data field: title relationship: nid label: 'Reply to' diff --git a/core/modules/views/config/views.view.frontpage.yml b/core/modules/views/config/views.view.frontpage.yml index a635a0e..2706232 100644 --- a/core/modules/views/config/views.view.frontpage.yml +++ b/core/modules/views/config/views.view.frontpage.yml @@ -35,18 +35,18 @@ display: sorts: sticky: id: sticky - table: node + table: node_property_data field: sticky order: DESC created: id: created - table: node + table: node_property_data field: created order: DESC filters: promote: id: promote - table: node + table: node_property_data field: promote value: '1' group: 0 @@ -54,7 +54,7 @@ display: operator: false status: id: status - table: node + table: node_property_data field: status value: '1' group: 0 diff --git a/core/modules/views/config/views.view.glossary.yml b/core/modules/views/config/views.view.glossary.yml index 966da7c..dec6051 100644 --- a/core/modules/views/config/views.view.glossary.yml +++ b/core/modules/views/config/views.view.glossary.yml @@ -32,7 +32,7 @@ display: fields: title: id: title - table: node + table: node_property_data field: title link_to_node: 1 name: @@ -44,14 +44,14 @@ display: relationship: uid changed: id: changed - table: node + table: node_property_data field: changed label: 'Last update' date_format: large arguments: title: id: title - table: node + table: node_property_data field: title default_action: default exception: @@ -70,7 +70,7 @@ display: relationships: uid: id: uid - table: node + table: node_property_data field: uid style: type: table @@ -124,7 +124,7 @@ display: arguments: title: id: title - table: node + table: node_property_data field: title default_action: summary exception: diff --git a/core/modules/views/config/views.view.taxonomy_term.yml b/core/modules/views/config/views.view.taxonomy_term.yml index 742c5d7..0305f30 100644 --- a/core/modules/views/config/views.view.taxonomy_term.yml +++ b/core/modules/views/config/views.view.taxonomy_term.yml @@ -29,12 +29,12 @@ display: sorts: sticky: id: sticky - table: node + table: node_property_data field: sticky order: DESC created: id: created - table: node + table: node_property_data field: created order: DESC arguments: @@ -68,7 +68,7 @@ display: filters: status_extra: id: status_extra - table: node + table: node_property_data field: status_extra group: 0 expose: diff --git a/core/modules/views/config/views.view.tracker.yml b/core/modules/views/config/views.view.tracker.yml index 5d31e2f..f043d79 100644 --- a/core/modules/views/config/views.view.tracker.yml +++ b/core/modules/views/config/views.view.tracker.yml @@ -32,7 +32,7 @@ display: relationships: uid: id: uid - table: node + table: node_property_data field: uid fields: type: @@ -41,7 +41,7 @@ display: field: type title: id: title - table: node + table: node_property_data field: title name: id: name @@ -59,13 +59,6 @@ display: table: node_comment_statistics field: last_comment_timestamp label: 'Last Post' - timestamp: - id: timestamp - table: history - field: timestamp - label: '' - link_to_node: 0 - comments: 1 new_comments: id: new_comments table: node @@ -82,7 +75,7 @@ display: arguments: uid_touch: id: uid_touch - table: node + table: node_property_data field: uid_touch exception: title_enable: 1 @@ -95,7 +88,7 @@ display: filters: status: id: status - table: node + table: node_property_data field: status value: '1' group: 0 diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/join/JoinPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/join/JoinPluginBase.php index f4efc69..f0aa660 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/join/JoinPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/join/JoinPluginBase.php @@ -158,6 +158,7 @@ public function __construct(array $configuration, $plugin_id, DiscoveryInterface $this->leftTable = $configuration['left_table']; $this->leftField = $configuration['left_field']; + $this->field = $configuration['field']; if (!empty($configuration['extra'])) { diff --git a/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php b/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php index 73ddfe0..866079c 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php +++ b/core/modules/views/lib/Drupal/views/Tests/Comment/DefaultViewRecentComments.php @@ -84,6 +84,8 @@ public function setUp() { $comment->node_type = 'comment_node_' . $this->node->type; $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['value'] = 'Test body ' . $i; $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['format'] = 'full_html'; + // Sets a descending changed time, so the order works as expected. + $comment->changed = REQUEST_TIME - $i; comment_save($comment); } @@ -135,7 +137,6 @@ public function testPageDisplay() { 'comment_nid' => 'nid', 'comment_subject' => 'subject', 'comment_changed' => 'changed', - 'comment_changed' => 'created', 'cid' => 'cid' ); $expected_result = array(); @@ -143,7 +144,6 @@ public function testPageDisplay() { $expected_result[$key]['nid'] = $comment->nid; $expected_result[$key]['subject'] = $comment->subject; $expected_result[$key]['changed'] = $comment->changed; - $expected_result[$key]['created'] = $comment->created; $expected_result[$key]['cid'] = $comment->cid; } $this->assertIdenticalResultset($view, $expected_result, $map); diff --git a/core/modules/views/lib/Drupal/views/Tests/Comment/FilterUserUIDTest.php b/core/modules/views/lib/Drupal/views/Tests/Comment/FilterUserUIDTest.php index 00ba08c..2c2c81c 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Comment/FilterUserUIDTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Comment/FilterUserUIDTest.php @@ -27,11 +27,11 @@ function testCommentUserUIDTest() { $options = array( 'id' => 'uid_touch', - 'table' => 'node', + 'table' => 'node_property_data', 'field' => 'uid_touch', 'value' => array($this->loggedInUser->uid), ); - $this->view->addItem('default', 'filter', 'node', 'uid_touch', $options); + $this->view->addItem('default', 'filter', 'node_property_data', 'uid_touch', $options); $this->executeView($this->view, array($this->account->uid)); $result_set = array( array( diff --git a/core/modules/views/lib/Drupal/views/Tests/Comment/WizardTest.php b/core/modules/views/lib/Drupal/views/Tests/Comment/WizardTest.php index 834bd5b..17c4ff9 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Comment/WizardTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Comment/WizardTest.php @@ -79,7 +79,7 @@ public function testCommentWizard() { $this->assertEqual($view->filter['status']->table, 'comment'); $this->assertEqual($view->filter['status']->field, 'status'); $this->assertTrue($view->filter['status']->value); - $this->assertEqual($view->filter['status_node']->table, 'node'); + $this->assertEqual($view->filter['status_node']->table, 'node_property_data'); $this->assertEqual($view->filter['status_node']->field, 'status'); $this->assertTrue($view->filter['status_node']->value); diff --git a/core/modules/views/lib/Drupal/views/Tests/Field/ApiDataTest.php b/core/modules/views/lib/Drupal/views/Tests/Field/ApiDataTest.php index abb1ad4..1fbe899 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Field/ApiDataTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Field/ApiDataTest.php @@ -94,7 +94,7 @@ function testViewsData() { $this->assertTrue(isset($data[$revision_table])); // The node field should join against node. $this->assertTrue(isset($data[$current_table]['table']['join']['node'])); - $this->assertTrue(isset($data[$revision_table]['table']['join']['node_revision'])); + $this->assertTrue(isset($data[$revision_table]['table']['join']['node_property_revision'])); $expected_join = array( 'left_field' => 'nid', @@ -113,7 +113,7 @@ function testViewsData() { array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), ), ); - $this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_revision']); + $this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_property_revision']); // Check the table and the joins of the second field. // Attached to both node and user. @@ -125,7 +125,7 @@ function testViewsData() { $this->assertTrue(isset($data[$revision_table_2])); // The second field should join against both node and users. $this->assertTrue(isset($data[$current_table_2]['table']['join']['node'])); - $this->assertTrue(isset($data[$revision_table_2]['table']['join']['node_revision'])); + $this->assertTrue(isset($data[$revision_table_2]['table']['join']['node_property_revision'])); $this->assertTrue(isset($data[$current_table_2]['table']['join']['users'])); $expected_join = array( @@ -145,7 +145,7 @@ function testViewsData() { array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), ) ); - $this->assertEqual($expected_join, $data[$revision_table_2]['table']['join']['node_revision']); + $this->assertEqual($expected_join, $data[$revision_table_2]['table']['join']['node_property_revision']); $expected_join = array( 'left_field' => 'uid', 'field' => 'entity_id', diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php index d2a2e55..38cc673 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php @@ -40,13 +40,13 @@ function testGlossary() { $count_field = 'nid'; foreach ($view->result as &$row) { - if (strpos($row->node_title, 'a') === 0) { + if (strpos($view->field['title']->get_value($row), 'a') === 0) { $this->assertEqual(1, $row->{$count_field}); } - if (strpos($row->node_title, 'b') === 0) { + if (strpos($view->field['title']->get_value($row), 'b') === 0) { $this->assertEqual(2, $row->{$count_field}); } - if (strpos($row->node_title, 'c') === 0) { + if (strpos($view->field['title']->get_value($row), 'c') === 0) { $this->assertEqual(3, $row->{$count_field}); } } diff --git a/core/modules/views/lib/Drupal/views/Tests/Node/RevisionRelationships.php b/core/modules/views/lib/Drupal/views/Tests/Node/RevisionRelationships.php index c501bd5..7e8e832 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Node/RevisionRelationships.php +++ b/core/modules/views/lib/Drupal/views/Tests/Node/RevisionRelationships.php @@ -32,8 +32,8 @@ public function testNodeRevisionRelationship() { $node_revision->save(); $column_map = array( 'vid' => 'vid', - 'node_revision_nid' => 'node_revision_nid', - 'node_node_revision_nid' => 'node_node_revision_nid', + 'node_property_revision_nid' => 'node_property_revision_nid', + 'node_node_property_revision_nid' => 'node_node_property_revision_nid', ); // Here should be two rows. @@ -42,13 +42,13 @@ public function testNodeRevisionRelationship() { $resultset_nid = array( array( 'vid' => '1', - 'node_revision_nid' => '1', - 'node_node_revision_nid' => '1', + 'node_property_revision_nid' => '1', + 'node_node_property_revision_nid' => '1', ), array( 'vid' => '2', - 'node_revision_nid' => '1', - 'node_node_revision_nid' => '1', + 'node_property_revision_nid' => '1', + 'node_node_property_revision_nid' => '1', ), ); $this->assertIdenticalResultset($view_nid, $resultset_nid, $column_map); @@ -59,8 +59,8 @@ public function testNodeRevisionRelationship() { $resultset_vid = array( array( 'vid' => '2', - 'node_revision_nid' => '1', - 'node_node_revision_nid' => '1', + 'node_property_revision_nid' => '1', + 'node_node_property_revision_nid' => '1', ), ); $this->assertIdenticalResultset($view_vid, $resultset_vid, $column_map); diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php index 3e69105..6a146e0 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/ItemsPerPageTest.php @@ -45,7 +45,7 @@ function testItemsPerPage() { $view['description'] = $this->randomName(16); $view['show[wizard_key]'] = 'node'; $view['show[type]'] = 'article'; - $view['show[sort]'] = 'created:DESC'; + $view['show[sort]'] = 'node_property_data-created:DESC'; $view['page[create]'] = 1; $view['page[title]'] = $this->randomName(16); $view['page[path]'] = $this->randomName(16); diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/SortingTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/SortingTest.php index 888d60c..7595065 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Wizard/SortingTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/SortingTest.php @@ -35,7 +35,7 @@ function testSorting() { $view1['human_name'] = $this->randomName(16); $view1['name'] = strtolower($this->randomName(16)); $view1['description'] = $this->randomName(16); - $view1['show[sort]'] = 'created:ASC'; + $view1['show[sort]'] = 'node_property_data-created:ASC'; $view1['page[create]'] = 1; $view1['page[title]'] = $this->randomName(16); $view1['page[path]'] = $this->randomName(16); @@ -59,7 +59,7 @@ function testSorting() { $view2['human_name'] = $this->randomName(16); $view2['name'] = strtolower($this->randomName(16)); $view2['description'] = $this->randomName(16); - $view2['show[sort]'] = 'created:DESC'; + $view2['show[sort]'] = 'node_property_data-created:DESC'; $view2['page[create]'] = 1; $view2['page[title]'] = $this->randomName(16); $view2['page[path]'] = $this->randomName(16); diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_argument_default_fixed.yml b/core/modules/views/tests/views_test_config/config/views.view.test_argument_default_fixed.yml index 061b209..29080f9 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_argument_default_fixed.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_argument_default_fixed.yml @@ -36,7 +36,7 @@ display: hide_empty: '0' id: title link_to_node: '0' - table: node + table: node_property_data pager: options: id: '0' diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_comment_user_uid.yml b/core/modules/views/tests/views_test_config/config/views.view.test_comment_user_uid.yml index 4dca1cd..1f1db7d 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_comment_user_uid.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_comment_user_uid.yml @@ -19,7 +19,7 @@ display: number_of_records: '0' summary_options: items_per_page: '25' - table: node + table: node_property_data cache: type: none exposed_form: diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_destroy.yml b/core/modules/views/tests/views_test_config/config/views.view.test_destroy.yml index a28c6b1..95ab36a 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_destroy.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_destroy.yml @@ -36,19 +36,19 @@ display: field: created_day id: created_day style_plugin: default_summary - table: node + table: node_property_data created_fulldate: default_argument_type: fixed field: created_fulldate id: created_fulldate style_plugin: default_summary - table: node + table: node_property_data created_month: default_argument_type: fixed field: created_month id: created_month style_plugin: default_summary - table: node + table: node_property_data cache: type: none empty: @@ -68,7 +68,7 @@ display: created: field: created id: created - table: node + table: node_property_data nid: field: nid id: nid @@ -85,11 +85,11 @@ display: status: field: status id: status - table: node + table: node_property_data title: field: title id: title - table: node + table: node_property_data footer: area: empty: '0' diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_display.yml b/core/modules/views/tests/views_test_config/config/views.view.test_display.yml index d9c5430..3ac2ce4 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_display.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_display.yml @@ -44,13 +44,13 @@ display: title: field: title id: title - table: node + table: node_property_data filters: status: field: status group: '1' id: status - table: node + table: node_property_data value: '1' pager: options: @@ -68,7 +68,7 @@ display: field: created id: created order: DESC - table: node + table: node_property_data style_plugin: default title: 'Test Display' display_plugin: default diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_feed_display.yml b/core/modules/views/tests/views_test_config/config/views.view.test_feed_display.yml index 6ba9d11..fa2c99f 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_feed_display.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_feed_display.yml @@ -29,7 +29,7 @@ display: id: title label: '' link_to_node: '1' - table: node + table: node_property_data filters: status: expose: @@ -37,7 +37,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' pager: options: @@ -56,7 +56,7 @@ display: field: created id: created order: DESC - table: node + table: node_property_data style: type: default title: test_feed_display diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_field_get_entity.yml b/core/modules/views/tests/views_test_config/config/views.view.test_field_get_entity.yml index 5ba2fc9..ef1c496 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_field_get_entity.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_field_get_entity.yml @@ -49,7 +49,7 @@ display: label: author relationship: nid required: '0' - table: node + table: node_property_data sorts: { } style: type: default diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_filter_date_between.yml b/core/modules/views/tests/views_test_config/config/views.view.test_filter_date_between.yml index 71f4b2f..2594086 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_filter_date_between.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_filter_date_between.yml @@ -21,7 +21,7 @@ display: created: field: created id: created - table: node + table: node_property_data pager: type: full query: diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_filter_group_override.yml b/core/modules/views/tests/views_test_config/config/views.view.test_filter_group_override.yml index 379eff6..b8bf0dc 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_filter_group_override.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_filter_group_override.yml @@ -20,7 +20,7 @@ display: field: title id: title label: '' - table: node + table: node_property_data filters: status: expose: @@ -28,7 +28,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' pager: type: full diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_filter_groups.yml b/core/modules/views/tests/views_test_config/config/views.view.test_filter_groups.yml index d71c02e..b6ff49b 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_filter_groups.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_filter_groups.yml @@ -20,7 +20,7 @@ display: field: title id: title label: '' - table: node + table: node_property_data filter_groups: groups: 1: AND @@ -46,7 +46,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' pager: options: @@ -59,7 +59,7 @@ display: field: created id: created order: DESC - table: node + table: node_property_data title: test_filter_groups style: type: default @@ -99,7 +99,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' path: test-filter-groups display_plugin: page diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_filter_node_uid_revision.yml b/core/modules/views/tests/views_test_config/config/views.view.test_filter_node_uid_revision.yml index 69000ec..1b12b9d 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_filter_node_uid_revision.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_filter_node_uid_revision.yml @@ -29,7 +29,7 @@ display: is_grouped: '0' operator: in relationship: none - table: node + table: node_property_data value: - '1' sorts: { } diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_glossary.yml b/core/modules/views/tests/views_test_config/config/views.view.test_glossary.yml index 33045e5..b6a1c55 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_glossary.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_glossary.yml @@ -20,7 +20,7 @@ display: number_of_records: '0' summary_options: items_per_page: '25' - table: node + table: node_property_data cache: type: none exposed_form: @@ -30,7 +30,7 @@ display: field: title id: title label: '' - table: node + table: node_property_data pager: type: full query: diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_handler_relationships.yml b/core/modules/views/tests/views_test_config/config/views.view.test_handler_relationships.yml index 409fb2c..d7f7318 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_handler_relationships.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_handler_relationships.yml @@ -9,7 +9,7 @@ display: fields: title: id: title - table: node + table: node_property_data field: title relationships: cid: diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_node_revision_nid.yml b/core/modules/views/tests/views_test_config/config/views.view.test_node_revision_nid.yml index cefedda..1047267 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_node_revision_nid.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_node_revision_nid.yml @@ -1,5 +1,5 @@ name: test_node_revision_nid -base_table: node_revision +base_table: node_property_revision core: 8 api_version: 3 display: @@ -8,17 +8,17 @@ display: relationships: nid: id: nid - table: node_revision + table: node_property_revision field: nid required: TRUE fields: vid: id: vid - table: node_revision + table: node_property_revision field: vid nid_1: id: nid_1 - table: node_revision + table: node_property_revision field: nid nid: id: nid @@ -28,7 +28,7 @@ display: arguments: nid: id: nid: - table: node_revision + table: node_property_revision field: nid display_plugin: default display_title: Master diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_node_revision_vid.yml b/core/modules/views/tests/views_test_config/config/views.view.test_node_revision_vid.yml index b36f549..f32a84a 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_node_revision_vid.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_node_revision_vid.yml @@ -1,5 +1,5 @@ name: test_node_revision_vid -base_table: node_revision +base_table: node_property_revision core: 8 api_version: 3 display: @@ -8,17 +8,17 @@ display: relationships: vid: id: vid - table: node_revision + table: node_property_revision field: vid required: TRUE fields: vid: id: vid - table: node_revision + table: node_property_revision field: vid nid_1: id: nid_1 - table: node_revision + table: node_property_revision field: nid nid: id: nid @@ -28,7 +28,7 @@ display: arguments: nid: id: nid: - table: node_revision + table: node_property_revision field: nid display_plugin: default display_title: Master diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_plugin_argument_default_current_user.yml b/core/modules/views/tests/views_test_config/config/views.view.test_plugin_argument_default_current_user.yml index 54180b6..3f857dc 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_plugin_argument_default_current_user.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_plugin_argument_default_current_user.yml @@ -36,7 +36,7 @@ display: hide_empty: '0' id: title link_to_node: '0' - table: node + table: node_property_data pager: options: id: '0' diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_redirect_view.yml b/core/modules/views/tests/views_test_config/config/views.view.test_redirect_view.yml index 1217693..4b62cfe 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_redirect_view.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_redirect_view.yml @@ -35,7 +35,7 @@ display: fields: title: id: title - table: node + table: node_property_data field: title label: '' alter: @@ -53,7 +53,7 @@ display: filters: status: value: '1' - table: node + table: node_property_data field: status id: status expose: @@ -62,7 +62,7 @@ display: sorts: created: id: created - table: node + table: node_property_data field: created order: DESC title: test_redirect_view diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_user_relationship.yml b/core/modules/views/tests/views_test_config/config/views.view.test_user_relationship.yml index 096fa16..2ca2f56 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_user_relationship.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_user_relationship.yml @@ -53,7 +53,7 @@ display: id: title label: '' link_to_node: '1' - table: node + table: node_property_data uid: alter: absolute: '0' diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_view_pager_full_zero_items_per_page.yml b/core/modules/views/tests/views_test_config/config/views.view.test_view_pager_full_zero_items_per_page.yml index 5b909ea..a9ea217 100644 --- a/core/modules/views/tests/views_test_config/config/views.view.test_view_pager_full_zero_items_per_page.yml +++ b/core/modules/views/tests/views_test_config/config/views.view.test_view_pager_full_zero_items_per_page.yml @@ -27,7 +27,7 @@ display: hide_empty: '0' id: title link_to_node: '0' - table: node + table: node_property_data pager: options: id: '0' diff --git a/core/modules/views/tests/views_test_data/config/views.view.test_argument_default_current_user.yml b/core/modules/views/tests/views_test_data/config/views.view.test_argument_default_current_user.yml index 3cf754d..6ab101a 100644 --- a/core/modules/views/tests/views_test_data/config/views.view.test_argument_default_current_user.yml +++ b/core/modules/views/tests/views_test_data/config/views.view.test_argument_default_current_user.yml @@ -13,7 +13,7 @@ display: default_action: default field: uid id: uid - table: node + table: node_property_data cache: type: none exposed_form: @@ -33,7 +33,7 @@ display: hide_empty: '0' id: title link_to_node: '0' - table: node + table: node_property_data pager: options: id: '0' diff --git a/core/modules/views/tests/views_test_data/config/views.view.test_exposed_admin_ui.yml b/core/modules/views/tests/views_test_data/config/views.view.test_exposed_admin_ui.yml index d73dfb8..f6f070d 100644 --- a/core/modules/views/tests/views_test_data/config/views.view.test_exposed_admin_ui.yml +++ b/core/modules/views/tests/views_test_data/config/views.view.test_exposed_admin_ui.yml @@ -29,7 +29,7 @@ display: created: field: created id: created - table: node + table: node_property_data style: type: default row: