diff --git a/core/includes/database.inc b/core/includes/database.inc index 15ffcc3..75f6a96 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 51d9829..2938f6c 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -4912,26 +4912,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 57681a3..54d6398 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -1449,7 +1449,7 @@ 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 = db_select('node_property_data', 'n'); $select->addField('n', 'nid'); $select->condition('n.status', 1); $select->condition('n.nid', $nids, 'IN'); 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 1c7d9fd..2ca1ff3 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php @@ -263,7 +263,7 @@ public function loadRevision($revision_id) { // which attaches fields (if supported by the entity type) and calls the // entity type specific load callback, for example hook_node_load(). if (!empty($queried_entities)) { - $this->attachLoad($queried_entities, TRUE); + $this->attachLoad($queried_entities, $revision_id); } return reset($queried_entities); } diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index e18edbd..67c3ce2 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -148,6 +148,56 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value } /** + * Overrides \Drupal\Core\Entity\DatabaseStorageController::buildQuery(). + */ + protected function buildQuery($ids, $revision_id = FALSE) { + $query = db_select($this->entityInfo['base_table'], 'base'); + + $query->addTag($this->entityType . '_load_multiple'); + + if (!$this->dataTable) { + if ($revision_id) { + $query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", array(':revisionId' => $revision_id)); + } + elseif ($this->revisionKey) { + $query->join($this->revisionTable, 'revision', "revision.{$this->revisionKey} = base.{$this->revisionKey}"); + } + } + + // Add fields from the {entity} table. + $entity_fields = $this->entityInfo['schema_fields_sql']['base_table']; + + if ($this->revisionKey && !$this->dataTable) { + // Add all fields from the {entity_revision} table. + $entity_revision_fields = drupal_map_assoc($this->entityInfo['schema_fields_sql']['revision_table']); + // The id field is provided by entity, so remove it. + unset($entity_revision_fields[$this->idKey]); + + // Remove all fields from the base table that are also fields by the same + // name in the revision table. + $entity_field_keys = array_flip($entity_fields); + foreach ($entity_revision_fields as $key => $name) { + if (isset($entity_field_keys[$name])) { + unset($entity_fields[$entity_field_keys[$name]]); + } + } + $query->fields('revision', $entity_revision_fields); + + // Compare revision id of the base and revision table, if equal then this + // is the default revision. + $query->addExpression('base.' . $this->revisionKey . ' = revision.' . $this->revisionKey, 'isDefaultRevision'); + } + + $query->fields('base', $entity_fields); + + if ($ids) { + $query->condition("base.{$this->idKey}", $ids, 'IN'); + } + + return $query; + } + + /** * Overrides DatabaseStorageController::attachLoad(). * * Added mapping from storage records to entities. @@ -220,39 +270,54 @@ protected function mapFromStorageRecords(array $records, $load_revision = FALSE) * * @param array &$entities * Associative array of entities, keyed on the entity ID. - * @param boolean $load_revision - * (optional) TRUE if the revision should be loaded, defaults to FALSE. + * @param int $revision_id + * (optional) The revision to be loaded. Defaults to FALSE. */ - protected function attachPropertyData(array &$entities, $load_revision = FALSE) { + protected function attachPropertyData(array &$entities, $revision_id = FALSE) { if ($this->dataTable) { - $query = db_select($this->dataTable, 'data', array('fetch' => PDO::FETCH_ASSOC)) + // If a revision table is available, we need all the properties of the + // latest revision. Otherwise we fall back to the data table. + $table = $this->revisionTable ?: $this->dataTable; + $query = db_select($table, 'data', array('fetch' => PDO::FETCH_ASSOC)) ->fields('data') ->condition($this->idKey, array_keys($entities)) ->orderBy('data.' . $this->idKey); - if ($load_revision) { - // Get revision ID's. - $revision_ids = array(); - foreach ($entities as $id => $entity) { - $revision_ids[] = $entity->get($this->revisionKey)->value; + + if ($this->revisionTable) { + if ($revision_id) { + $query->condition($this->revisionKey, $revision_id); + } + else { + // Get revision ID's. + $revision_ids = array(); + foreach ($entities as $id => $entity) { + $revision_ids[] = $entity->get($this->revisionKey)->value; + } + $query->condition($this->revisionKey, $revision_ids); } - $query->condition($this->revisionKey, $revision_ids); } + $data = $query->execute(); - // Fetch the field definitions to check which field is translatable. $field_definition = $this->getFieldDefinitions(array()); $data_fields = array_flip($this->entityInfo['schema_fields_sql']['data_table']); foreach ($data as $values) { $id = $values[$this->idKey]; + + if ($this->revisionTable) { + // Unless a revision id was specified we are dealing with the default + // revision. + $entities[$id]->getBCEntity()->isDefaultRevision = intval(empty($revision_id)); + } + // Field values in default language are stored with LANGUAGE_DEFAULT as // key. $langcode = empty($values['default_langcode']) ? $values['langcode'] : LANGUAGE_DEFAULT; $translation = $entities[$id]->getTranslation($langcode); foreach ($field_definition as $name => $definition) { - // Set translatable properties only. - if (isset($data_fields[$name]) && !empty($definition['translatable'])) { + if (isset($data_fields[$name])) { // @todo Figure out how to determine which property has to be set. // Currently it's guessing, and guessing is evil! $property_definition = $translation->{$name}->getPropertyDefinitions(); @@ -483,7 +548,9 @@ protected function mapToDataStorageRecord(EntityInterface $entity, $langcode) { $record = new \stdClass(); foreach ($this->entityInfo['schema_fields_sql']['data_table'] as $name) { - $record->$name = $translation->$name->value; + if (isset($translation->$name->value)) { + $record->$name = $translation->$name->value; + } } $record->langcode = $langcode; $record->default_langcode = intval($default_langcode == $langcode); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php index d182289..52226b5 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php @@ -136,7 +136,7 @@ function getFeedEditObject($feed_url = NULL, array $values = array()) { */ 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} n WHERE n.promote = 1 AND n.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 26f324e..40c5aad 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -290,9 +290,9 @@ 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', 'n', 'n.nid = n.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'); @@ -302,8 +302,10 @@ function book_get_books() { $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/book/lib/Drupal/book/Plugin/block/block/BookNavigationBlock.php b/core/modules/book/lib/Drupal/book/Plugin/block/block/BookNavigationBlock.php index 165c798..97ffa07 100644 --- a/core/modules/book/lib/Drupal/book/Plugin/block/block/BookNavigationBlock.php +++ b/core/modules/book/lib/Drupal/book/Plugin/block/block/BookNavigationBlock.php @@ -96,12 +96,12 @@ public function build() { 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); diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index 0418b1d..6d5a882 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', 'n', 'n.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 48bb5a4..8b171c3 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -37,7 +37,8 @@ function comment_uninstall() { */ function comment_enable() { // Insert records into the node_comment_statistics for nodes that are missing. - $query = db_select('node', 'n'); + // TODO Add support for multilingual properties. + $query = db_select('node_property_data', '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'); diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index dd87b29..6435f53 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -465,7 +465,7 @@ 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', 'n', 'n.nid = c.nid'); $query->addTag('node_access'); $query->addMetaData('base_table', 'comment'); $comments = $query diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc index e74c97c..8886eb0 100644 --- a/core/modules/comment/comment.views.inc +++ b/core/modules/comment/comment.views.inc @@ -503,7 +503,7 @@ function comment_views_data_alter(&$data) { ), ); - $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( @@ -517,7 +517,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 77e441f..95f35ed 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorageController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorageController.php @@ -232,7 +232,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 c45efbd..5991ab3 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/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php index e614c1e..b46922e 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/FilterUserUIDTest.php @@ -36,11 +36,11 @@ function testCommentUserUIDTest() { $options = array( 'id' => 'uid_touch', - 'table' => 'node', + 'table' => 'node_property_data', 'field' => 'uid_touch', 'value' => array($this->loggedInUser->uid), ); - $view->addItem('default', 'filter', 'node', 'uid_touch', $options); + $view->addItem('default', 'filter', 'node_property_data', 'uid_touch', $options); $this->executeView($view, array($this->account->uid)); $result_set = array( array( diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php index f84cf64..ea86854 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php @@ -80,7 +80,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/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_user_uid.yml b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_user_uid.yml index dfa4b9c..ed9917f 100644 --- a/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_user_uid.yml +++ b/core/modules/comment/tests/modules/comment_test_views/test_views/views.view.test_comment_user_uid.yml @@ -18,7 +18,7 @@ display: number_of_records: '0' summary_options: items_per_page: '25' - table: node + table: node_property_data plugin_id: argument_comment_user_uid cache: type: none diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php index 62b7b27..ad5d89e 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php @@ -91,7 +91,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', @@ -110,7 +110,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. @@ -124,7 +124,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( @@ -144,7 +144,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/forum/forum.module b/core/modules/forum/forum.module index 574d536..236ec11 100644 --- a/core/modules/forum/forum.module +++ b/core/modules/forum/forum.module @@ -729,7 +729,7 @@ function forum_forum_load($tid = NULL) { $_forums = taxonomy_get_tree($vid, $tid, NULL, TRUE); if (count($_forums)) { - $query = db_select('node', 'n'); + $query = db_select('node_property_data', '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'); @@ -760,7 +760,7 @@ function forum_forum_load($tid = NULL) { } // Query "Last Post" information for this forum. - $query = db_select('node', 'n'); + $query = db_select('node_property_data', '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->join('users', 'u', 'ncs.last_comment_uid = u.uid'); @@ -807,7 +807,7 @@ 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 = db_select('node_property_data', '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'); @@ -880,7 +880,7 @@ 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', 'n') ->extend('Drupal\Core\Database\Query\TableSortExtender'); $query->fields('n', array('nid')); @@ -900,7 +900,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('n.nid', $nids) + ->groupBy('n.nid'); $result = array(); foreach ($query->execute() as $row) { @@ -1280,7 +1281,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/node/config/views.view.frontpage.yml b/core/modules/node/config/views.view.frontpage.yml index fb98768..26c6406 100644 --- a/core/modules/node/config/views.view.frontpage.yml +++ b/core/modules/node/config/views.view.frontpage.yml @@ -80,7 +80,7 @@ display: is_grouped: '0' operator: '=' relationship: none - table: node + table: node_property_data value: '1' plugin_id: boolean status: @@ -89,7 +89,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' plugin_id: boolean pager: @@ -109,7 +109,7 @@ display: field: created id: created order: DESC - table: node + table: node_property_data plugin_id: date sticky: admin_label: '' @@ -121,7 +121,7 @@ display: id: sticky order: ASC relationship: none - table: node + table: node_property_data plugin_id: boolean style: type: default diff --git a/core/modules/node/lib/Drupal/node/NodeStorageController.php b/core/modules/node/lib/Drupal/node/NodeStorageController.php index c9e832e..40389ae 100644 --- a/core/modules/node/lib/Drupal/node/NodeStorageController.php +++ b/core/modules/node/lib/Drupal/node/NodeStorageController.php @@ -80,21 +80,6 @@ protected function attachLoad(&$queried_entities, $load_revision = FALSE) { } /** - * Overrides Drupal\Core\Entity\DatabaseStorageController::buildQuery(). - */ - protected function buildQuery($ids, $revision_id = FALSE) { - // Ensure that uid is taken from the {node} table, - // 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'; - $query->addField('revision', 'uid', 'revision_uid'); - return $query; - } - - /** * Overrides Drupal\Core\Entity\DatabaseStorageController::invokeHook(). */ protected function invokeHook($hook, EntityInterface $node) { @@ -129,6 +114,16 @@ protected function invokeHook($hook, EntityInterface $node) { } /** + * Overrides \Drupal\Core\Entity\DatabaseStorageControllerNG::mapToDataStorageRecord(). + */ + protected function mapToDataStorageRecord(EntityInterface $entity, $langcode) { + // @todo Remove this once comment is a regular entity field. + $record = parent::mapToDataStorageRecord($entity, $langcode); + $record->comment = isset($record->comment) ? intval($record->comment) : 0; + return $record; + } + + /** * Overrides Drupal\Core\Entity\DatabaseStorageController::preSave(). */ protected function preSave(EntityInterface $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 92ed8e8..a3e22cb 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 @@ -28,7 +28,8 @@ * }, * translation_controller_class = "Drupal\node\NodeTranslationController", * base_table = "node", - * revision_table = "node_revision", + * data_table = "node_property_data", + * revision_table = "node_property_revision", * uri_callback = "node_uri", * fieldable = TRUE, * translatable = TRUE, 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 5630b03..da015b6 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 3136671..e41e53d 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/Link.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php index dc77691..2e39e41 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 24cee3d..c4b69bb 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 @@ -30,7 +30,7 @@ class RevisionLink extends Link { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { parent::init($view, $display, $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() { @@ -45,7 +45,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"; } @@ -70,7 +70,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 4096ad9..9a756ee 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 bb5bc37..dab2413 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 8a4cb5f..21a8477 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 4f868f7..906c228 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 0f41638..e13198f 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 6b7d00d..d5ca47a 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessBaseTableTest.php @@ -85,7 +85,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 bcfbfcd..8ba9e99 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAdminTest.php @@ -44,7 +44,7 @@ function testContentAdminSort() { } // Test that the default sort by node.changed DESC actually fires properly. - $nodes_query = db_select('node', 'n') + $nodes_query = db_select('node_property_data', 'n') ->fields('n', array('nid')) ->orderBy('changed', 'DESC') ->execute() @@ -59,7 +59,7 @@ function testContentAdminSort() { // 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') + $nodes_query = db_select('node_property_data', 'n') ->fields('n', array('nid')) ->orderBy('title') ->execute() diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php index 3beb969..ca4040b 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeBlockFunctionalTest.php @@ -74,13 +74,13 @@ public 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 f382457..633a004 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeFieldMultilingualTestCase.php @@ -138,4 +138,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 46244b8..d5b27c9 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeRevisionsTest.php @@ -112,12 +112,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 139b2d2..052cf72 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -5,7 +5,7 @@ * Content administration and module settings user interface. */ -use Drupal\Core\Database\Query\SelectInterface; +use Drupal\Core\Entity\Query\QueryInterface; /** * Page callback: Form constructor for the permission rebuild confirmation form. @@ -131,18 +131,21 @@ function node_filters() { * @param Drupal\Core\Database\Query\SelectInterface $query * A SelectQuery to which the filters should be applied. */ -function node_build_filter_query(SelectInterface $query) { +function node_build_filter_query(QueryInterface $query) { // Build query $filter_data = isset($_SESSION['node_overview_filter']) ? $_SESSION['node_overview_filter'] : array(); foreach ($filter_data as $index => $filter) { list($key, $value) = $filter; switch ($key) { case 'status': - // Note: no exploitable hole as $key/$value have already been checked when submitted + // Note: no exploitable hole as $key/$value have already been checked + // when submitted. list($key, $value) = explode('-', $value, 2); + $query->condition($key, $value); + break; case 'type': case 'langcode': - $query->condition('n.' . $key, $value); + $query->condition($key, $value); break; } } @@ -460,11 +463,11 @@ function node_admin_nodes() { $header = array( 'title' => array( 'data' => t('Title'), - 'field' => 'n.title', + 'specifier' => 'title', ), 'type' => array( 'data' => t('Content type'), - 'field' => 'n.type', + 'specifier' => 'type', 'class' => array(RESPONSIVE_PRIORITY_MEDIUM), ), 'author' => array( @@ -473,47 +476,45 @@ function node_admin_nodes() { ), 'status' => array( 'data' => t('Status'), - 'field' => 'n.status', + 'specifier' => 'status', ), 'changed' => array( 'data' => t('Updated'), - 'field' => 'n.changed', + 'specifier' => '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'), 'specifier' => '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 = entity_query('node') + ->pager(50) + ->tableSort($header) + // Provide a default sort. + ->sort('nid', 'desc'); 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()) { - $query->condition(db_or() - ->condition('n.status', 1) - ->condition('n.nid', $own_unpublished, 'IN') + if (user_access('view own unpublished content') && $own_unpublished = entity_query('node')->condition('uid', $GLOBALS['user']->uid)->condition('status', 0)->execute()) { + $query->condition( + $query->orConditionGroup() + ->condition('status', 1) + ->condition('nid', $own_unpublished, 'IN') ); } else { // If not, restrict the query to published nodes. - $query->condition('n.status', 1); + $query->condition('status', 1); } } - $nids = $query - ->fields('n',array('nid')) - ->limit(50) - ->orderByHeader($header) - ->addTag('node_access') - ->execute() - ->fetchCol(); + + $nids = $query->execute(); $nodes = node_load_multiple($nids); // Prepare the list of nodes. @@ -568,7 +569,7 @@ function node_admin_nodes() { 'query' => $destination, ); } - if (module_invoke('translation_entity', 'enabled', 'node', $node->bundle())) { + if ($node->isTranslatable()) { $operations['translate'] = array( 'title' => t('Translate'), 'href' => 'node/' . $node->nid . '/translations', @@ -655,14 +656,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 ebbce13..573bdba0 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,56 +47,8 @@ function node_schema() { 'not null' => TRUE, 'default' => '', ), - 'title' => array( - 'description' => 'The title of this node, always treated as non-markup plain text.', - 'type' => 'varchar', - 'length' => 255, - 'not null' => TRUE, - 'default' => '', - ), - 'uid' => array( - 'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.', - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - ), - 'status' => array( - 'description' => 'Boolean indicating whether the node is published (visible to non-administrators).', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 1, - ), - 'created' => array( - 'description' => 'The Unix timestamp when the node was created.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'changed' => array( - 'description' => 'The Unix timestamp when the node was most recently saved.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'comment' => array( - 'description' => 'Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write).', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'promote' => array( - 'description' => 'Boolean indicating whether the node should be displayed on the front page.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), - 'sticky' => array( - 'description' => 'Boolean indicating whether the node should be displayed at the top of lists in which it appears.', - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - ), + // @todo Remove the following columns when removing the legacy Content + // Translation module. 'tnid' => array( 'description' => 'The translation set id for this node, which equals the node id of the source post in each set.', 'type' => 'int', @@ -112,15 +64,9 @@ function node_schema() { ), ), '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_type' => array(array('type', 4)), + 'tnid' => array('tnid'), + 'translate' => array('translate'), ), 'unique keys' => array( 'vid' => array('vid'), @@ -128,76 +74,118 @@ function node_schema() { ), 'foreign keys' => array( 'node_revision' => array( - 'table' => 'node_revision', + 'table' => 'node_property_revision', 'columns' => array('vid' => 'vid'), ), - 'node_author' => array( - 'table' => 'users', - 'columns' => array('uid' => 'uid'), - ), ), 'primary key' => array('nid'), ); - $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 storage. + $schema['node_property_data'] = array( + 'description' => 'Base table for node properties.', 'fields' => array( 'nid' => array( - 'description' => 'The {node}.nid this record affects.', - 'type' => 'int', + 'description' => 'The primary identifier for a node.', + 'type' => 'serial', '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.", + 'vid' => array( + 'description' => 'The current {node_property_revision}.vid version identifier.', 'type' => 'int', '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 these node property values.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + 'default_langcode' => array( + 'description' => 'Boolean indicating whether the property values are in the {language}.langcode of this node.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 1, + ), + 'title' => array( + 'description' => 'The title of this node, 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 owns this node; initially, this is the user that created it.', '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 translation is published (visible to non-administrators).', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 1, + ), + 'created' => array( + 'description' => 'The Unix timestamp when the node translation was created.', '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.', + 'changed' => array( + 'description' => 'The Unix timestamp when the node translation was most recently saved.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'comment' => array( + 'description' => 'Whether comments are allowed on this node translation: 0 = no, 1 = closed (read only), 2 = open (read/write).', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'promote' => array( + 'description' => 'Boolean indicating whether the node translation should be displayed on the front page.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'sticky' => array( + 'description' => 'Boolean indicating whether the node translation should be displayed at the top of lists in which it appears.', 'type' => 'int', - 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - 'size' => 'tiny', ), ), - 'primary key' => array('nid', 'gid', 'realm'), + 'indexes' => array( + 'node_changed' => array('changed'), + 'node_created' => array('created'), + 'node_frontpage' => array('promote', 'status', 'sticky', 'created'), + // @todo Figure out how to replace the 'node_status_type' and the + // 'node_title_type' indexes. + 'nid' => array('nid'), + 'vid' => array('vid'), + 'uid' => array('uid'), + ), 'foreign keys' => array( - 'affected_node' => array( + 'node_base' => array( 'table' => 'node', 'columns' => array('nid' => 'nid'), ), - ), + 'node_author' => array( + 'table' => 'users', + 'columns' => array('uid' => 'uid'), + ), + ), + 'primary key' => array('nid', 'vid', 'langcode'), ); - $schema['node_revision'] = array( + // Node property revision storage. + $schema['node_property_revision'] = array( 'description' => 'Stores information about each saved version of a {node}.', 'fields' => array( 'nid' => array( @@ -205,7 +193,6 @@ function node_schema() { 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, - 'default' => 0, ), 'vid' => array( 'description' => 'The primary identifier for this version.', @@ -213,29 +200,30 @@ function node_schema() { 'unsigned' => TRUE, 'not null' => TRUE, ), - 'uid' => array( - 'description' => 'The {users}.uid that created this version.', + 'langcode' => array( + 'description' => 'The {language}.langcode of this version.', + 'type' => 'varchar', + 'length' => 12, + 'not null' => TRUE, + 'default' => '', + ), + 'default_langcode' => array( + 'description' => 'Boolean indicating whether the property values of this version are in the {language}.langcode of this node.', 'type' => 'int', - 'unsigned' => TRUE, 'not null' => TRUE, - 'default' => 0, + 'default' => 1, ), 'title' => array( - 'description' => 'The title of this version.', + 'description' => 'The title of this version, always treated as non-markup plain text.', '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.', + 'uid' => array( + 'description' => 'The {users}.uid that created this version.', 'type' => 'int', + 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), @@ -245,6 +233,18 @@ function node_schema() { 'not null' => TRUE, 'default' => 1, ), + 'created' => array( + 'description' => 'The Unix timestamp when the version was created.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'changed' => array( + 'description' => 'The Unix timestamp when the version was most recently saved.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), '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', @@ -263,12 +263,18 @@ function node_schema() { 'not null' => TRUE, 'default' => 0, ), + 'log' => array( + 'description' => 'The log entry explaining the changes in this version.', + 'type' => 'text', + 'not null' => FALSE, + 'size' => 'big', + ), ), 'indexes' => array( 'nid' => array('nid'), 'uid' => array('uid'), + 'vid' => array('vid'), ), - 'primary key' => array('vid'), 'foreign keys' => array( 'versioned_node' => array( 'table' => 'node', @@ -279,6 +285,65 @@ function node_schema() { 'columns' => array('uid' => 'uid'), ), ), + '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.', + 'fields' => array( + 'nid' => array( + 'description' => 'The {node}.nid this record affects.', + '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', + '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.', + '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.', + '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.', + '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.', + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'size' => 'tiny', + ), + ), + 'primary key' => array('nid', 'gid', 'realm'), + 'foreign keys' => array( + 'affected_node' => array( + 'table' => 'node', + 'columns' => array('nid' => 'nid'), + ), + ), ); $schema['node_type'] = array( @@ -361,7 +426,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.', diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 4c7392b..e57536c 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1368,6 +1368,7 @@ 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', 'n', 'n.nid = n.nid'); $query ->condition('n.status', 1) ->addTag('node_access') @@ -1468,7 +1469,8 @@ 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') + $nodes = db_select('node_property_data', 'n') + ->distinct(TRUE) ->fields('n', array('nid')) ->condition('uid', $account->uid) ->execute() @@ -1479,14 +1481,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') + $nodes = db_select('node_property_data', 'n') + ->distinct(TRUE) ->fields('n', 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(); @@ -1500,14 +1503,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') + $nodes = db_select('node_property_data', 'n') + ->distinct(TRUE) ->fields('n', 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); } @@ -1607,7 +1611,7 @@ function _node_revision_access(EntityInterface $node, $op = 'view', $account = N // 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)) { @@ -1858,7 +1862,7 @@ function node_page_title(EntityInterface $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; } /** @@ -1872,7 +1876,15 @@ function node_last_changed($nid) { */ function node_revision_list(EntityInterface $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} n ON n.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; } @@ -1891,13 +1903,13 @@ function node_revision_list(EntityInterface $node) { * visible to the current user. */ function node_get_recent($number = 10) { - $query = db_select('node', 'n'); + $query = db_select('node_property_data', 'n'); 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') @@ -2081,10 +2093,11 @@ function node_feed($nids = FALSE, $channel = array()) { $rss_config = config('system.rss'); if ($nids === FALSE) { - $nids = db_select('node', 'n') + $nids = db_select('node_property_data', 'n') ->fields('n', array('nid', 'created')) ->condition('n.promote', 1) ->condition('n.status', 1) + ->groupBy('n.nid') ->orderBy('n.created', 'DESC') ->range(0, $rss_config->get('items.limit')) ->addTag('node_access') @@ -2777,7 +2790,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 863babd..fd1d3cb 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -379,7 +379,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 03b6bcd..865670c 100644 --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -32,6 +32,14 @@ function node_views_data() { $data['node']['table']['entity type'] = 'node'; $data['node']['table']['wizard_id'] = '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', + ); + $data['node']['nid'] = array( 'title' => t('Nid'), 'help' => t('The node ID.'), @@ -53,7 +61,7 @@ function node_views_data() { ); // 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'), 'help' => t('The content title.'), 'field' => array( @@ -75,7 +83,7 @@ function node_views_data() { ), ); - $data['node']['created'] = array( + $data['node_property_data']['created'] = array( 'title' => t('Post date'), 'help' => t('The date the content was posted.'), 'field' => array( @@ -89,7 +97,7 @@ function node_views_data() { ), ); - $data['node']['changed'] = array( + $data['node_property_data']['changed'] = array( 'title' => t('Updated date'), 'help' => t('The date the content was last updated.'), 'field' => array( @@ -120,7 +128,7 @@ function node_views_data() { ), ); - $data['node']['status'] = array( + $data['node_property_data']['status'] = array( 'title' => t('Published status'), 'help' => t('Whether or not the content is published.'), 'field' => array( @@ -141,7 +149,7 @@ function node_views_data() { ), ); - $data['node']['status_extra'] = array( + $data['node_property_data']['status_extra'] = array( 'title' => t('Published status or admin user'), 'help' => t('Filters out unpublished content if the current user cannot view it.'), 'filter' => array( @@ -151,7 +159,7 @@ function node_views_data() { ), ); - $data['node']['promote'] = array( + $data['node_property_data']['promote'] = array( 'title' => t('Promoted to front page status'), 'help' => t('Whether or not the content is promoted to the front page.'), 'field' => array( @@ -170,7 +178,7 @@ function node_views_data() { ), ); - $data['node']['sticky'] = array( + $data['node_property_data']['sticky'] = array( 'title' => t('Sticky status'), 'help' => t('Whether or not the content is sticky.'), 'field' => array( @@ -261,7 +269,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( @@ -270,7 +278,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( @@ -279,7 +287,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( @@ -288,7 +296,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( @@ -297,7 +305,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( @@ -306,7 +314,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( @@ -315,7 +323,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( @@ -324,7 +332,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( @@ -333,7 +341,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( @@ -342,7 +350,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( @@ -351,7 +359,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( @@ -360,7 +368,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( @@ -369,7 +377,7 @@ function node_views_data() { ), ); - $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( @@ -399,7 +407,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', @@ -411,15 +419,15 @@ function node_views_data() { ), ); - $data['node_revision']['table']['entity type'] = 'node'; + $data['node_property_revision']['table']['entity type'] = 'node'; // 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']['group'] = t('Content revision'); - $data['node_revision']['table']['wizard_id'] = 'node_revision'; + $data['node_property_revision']['table']['group'] = t('Content revision'); + $data['node_property_revision']['table']['wizard_id'] = 'node_property_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.'), @@ -429,14 +437,14 @@ 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( 'node' => array( 'left_field' => 'vid', 'field' => 'vid', ), ); - $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( @@ -447,7 +455,7 @@ function node_views_data() { ), ); - $data['node_revision']['nid'] = array( + $data['node_property_revision']['nid'] = array( 'title' => t('Nid'), 'help' => t('The revision NID of the content revision.'), 'field' => array( @@ -472,7 +480,7 @@ function node_views_data() { ), ); - $data['node_revision']['vid'] = array( + $data['node_property_revision']['vid'] = array( 'title' => t('Vid'), 'help' => t('The revision ID of the content revision.'), 'field' => array( @@ -497,7 +505,7 @@ function node_views_data() { ), ); - $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( @@ -518,12 +526,12 @@ function node_views_data() { ), ); - $data['node_revision']['title'] = array( + $data['node_property_revision']['title'] = array( 'title' => t('Title'), 'help' => t('The content title.'), 'field' => array( 'field' => 'title', - 'id' => 'node_revision', + 'id' => 'node_property_revision', ), 'sort' => array( 'id' => 'standard', @@ -536,7 +544,7 @@ function node_views_data() { ), ); - $data['node_revision']['log'] = array( + $data['node_property_revision']['log'] = array( 'title' => t('Log message'), 'help' => t('The log message entered when the revision was created.'), 'field' => array( @@ -547,7 +555,7 @@ function node_views_data() { ), ); - $data['node_revision']['timestamp'] = array( + $data['node_property_revision']['changed'] = array( 'title' => t('Updated date'), 'help' => t('The date the node was last updated.'), 'field' => array( @@ -561,7 +569,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 to revision'), 'help' => t('Provide a simple link to the revision.'), @@ -570,7 +578,7 @@ function node_views_data() { ), ); - $data['node_revision']['revert_revision'] = array( + $data['node_property_revision']['revert_revision'] = array( 'field' => array( 'title' => t('Link to revert revision'), 'help' => t('Provide a simple link to revert to the revision.'), @@ -579,7 +587,7 @@ function node_views_data() { ), ); - $data['node_revision']['delete_revision'] = array( + $data['node_property_revision']['delete_revision'] = array( 'field' => array( 'title' => t('Link to delete revision'), 'help' => t('Provide a simple link to delete the content revision.'), diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_filter_node_uid_revision.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_filter_node_uid_revision.yml index 7a7065a..cd8c28d 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_filter_node_uid_revision.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/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' plugin_id: node_uid_revision diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_nid.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_nid.yml index 58e7e64..614954f 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_nid.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_nid.yml @@ -1,5 +1,5 @@ id: test_node_revision_nid -base_table: node_revision +base_table: node_property_revision core: 8 display: default: @@ -7,19 +7,19 @@ display: relationships: nid: id: nid - table: node_revision + table: node_property_revision field: nid required: true plugin_id: standard fields: vid: id: vid - table: node_revision + table: node_property_revision field: vid plugin_id: standard nid_1: id: nid_1 - table: node_revision + table: node_property_revision field: nid plugin_id: standard nid: @@ -31,7 +31,7 @@ display: arguments: nid: id: nid - table: node_revision + table: node_property_revision field: nid plugin_id: node_nid display_plugin: default diff --git a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_vid.yml b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_vid.yml index fe29d14..fb20d97 100644 --- a/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_vid.yml +++ b/core/modules/node/tests/modules/node_test_views/test_views/views.view.test_node_revision_vid.yml @@ -1,5 +1,5 @@ id: test_node_revision_vid -base_table: node_revision +base_table: node_property_revision core: 8 display: default: @@ -7,19 +7,19 @@ display: relationships: vid: id: vid - table: node_revision + table: node_property_revision field: vid required: true plugin_id: standard fields: vid: id: vid - table: node_revision + table: node_property_revision field: vid plugin_id: standard nid_1: id: nid_1 - table: node_revision + table: node_property_revision field: nid plugin_id: standard nid: @@ -31,7 +31,7 @@ display: arguments: nid: id: nid - table: node_revision + table: node_property_revision field: nid plugin_id: node_nid display_plugin: default diff --git a/core/modules/search/search.api.php b/core/modules/search/search.api.php index ce581b0..a4737d8 100644 --- a/core/modules/search/search.api.php +++ b/core/modules/search/search.api.php @@ -118,8 +118,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); } @@ -205,17 +205,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()) { @@ -232,29 +232,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 85e58d3..e6633df 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -633,10 +633,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 5cca38a..aba4967 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php @@ -274,10 +274,10 @@ protected function drupalCreateNode(array $settings = array()) { $node->save(); // Small hack to link revisions to our test user. - db_update('node_revision') - ->fields(array('uid' => $node->uid)) - ->condition('vid', $node->vid) - ->execute(); +// db_update('node_revision') +// ->fields(array('uid' => $node->uid)) +// ->condition('vid', $node->vid) +// ->execute(); return $node; } diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 66842a5..395d8c3 100644 --- a/core/modules/statistics/statistics.module +++ b/core/modules/statistics/statistics.module @@ -119,7 +119,7 @@ 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', 'n'); $query->addTag('node_access'); $query->join('node_counter', 's', 'n.nid = s.nid'); $query->join('users', 'u', 'n.uid = u.uid'); @@ -130,6 +130,7 @@ function statistics_title_list($dbfield, $dbrows) { ->condition($dbfield, 0, '<>') ->condition('n.status', 1) ->orderBy($dbfield, 'DESC') + ->groupBy('n.nid') ->range(0, $dbrows) ->execute(); } diff --git a/core/modules/tracker/tracker.module b/core/modules/tracker/tracker.module index 125b5da..0755231 100644 --- a/core/modules/tracker/tracker.module +++ b/core/modules/tracker/tracker.module @@ -84,7 +84,7 @@ function tracker_cron() { if ($max_nid > 0) { $batch_size = config('tracker.settings')->get('cron_index_limit'); $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; @@ -269,7 +269,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. @@ -308,7 +308,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, @@ -330,7 +330,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 a801ad7..c438705 100644 --- a/core/modules/tracker/tracker.pages.inc +++ b/core/modules/tracker/tracker.pages.inc @@ -50,9 +50,9 @@ function tracker_page($account = NULL, $set_title = FALSE) { $rows = array(); if (!empty($tracker_data)) { $nids = array_keys($tracker_data); - $nodes = entity_load_multiple('node', $nids); + $nodes = node_load_multiple($nids); // Now, get the data and put into the placeholder array. - $result = db_query('SELECT n.nid, 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' => $nids), array('target' => 'slave'))->fetchAllKeyed(); + $result = db_query('SELECT n.nid, n.title, n.type, n.changed, n.uid, u.name, l.comment_count FROM {node_property_data} n INNER JOIN {node} nb ON nb.nid = n.nid 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) GROUP BY n.nid ORDER BY n.changed DESC', array(':nids' => $nids), array('target' => 'slave')); foreach ($result as $nid => $comment_count) { $nodes[$nid]->last_activity = $tracker_data[$nid]->changed; $nodes[$nid]->comment_count = $comment_count; diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index 41d8e83..962496e 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -487,11 +487,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', 'n'); + $query->innerJoin('node', 'n', 'n.nid = n.nid AND n.langcode = n.langcode'); + $query->fields('n', 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/tests/modules/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml index 1a6c66b..80eea23 100644 --- a/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml +++ b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml @@ -35,7 +35,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/user/tests/modules/user_test_views/test_views/views.view.test_user_relationship.yml b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_user_relationship.yml index c2d22e2..2274b62 100644 --- a/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_user_relationship.yml +++ b/core/modules/user/tests/modules/user_test_views/test_views/views.view.test_user_relationship.yml @@ -53,7 +53,7 @@ display: id: title label: '' link_to_node: '1' - table: node + table: node_property_data plugin_id: node uid: alter: diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php index 652c5b5..8fdf807 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -119,7 +119,7 @@ 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') + $nodes = db_select('node_property_data', 'n') ->fields('n', array('nid')) ->condition('uid', $account->uid) ->execute() @@ -130,14 +130,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') + $nodes = db_select('node_property_data', 'n') ->fields('n', 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 13b1690..70ef61c 100644 --- a/core/modules/user/user.views.inc +++ b/core/modules/user/user.views.inc @@ -46,7 +46,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'), @@ -74,7 +74,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 45bddd1..a6d7343 100644 --- a/core/modules/views/config/views.view.archive.yml +++ b/core/modules/views/config/views.view.archive.yml @@ -26,14 +26,14 @@ display: sorts: created: id: created - table: node + table: node_property_data field: created order: DESC plugin_id: date arguments: created_year_month: id: created_year_month - table: node + table: node_property_date field: created_year_month default_action: summary exception: @@ -52,7 +52,7 @@ display: filters: status: id: status - table: node + table: node_property_date field: status value: '1' group: '0' @@ -87,7 +87,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 9d35c3d..9528a5a 100644 --- a/core/modules/views/config/views.view.backlinks.yml +++ b/core/modules/views/config/views.view.backlinks.yml @@ -36,7 +36,7 @@ display: fields: title: id: title - table: node + table: node_property_data field: title label: '' link_to_node: '1' @@ -58,7 +58,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 ea8f71d..185e050 100644 --- a/core/modules/views/config/views.view.comments_recent.yml +++ b/core/modules/views/config/views.view.comments_recent.yml @@ -48,8 +48,8 @@ display: date_format: 'time ago' plugin_id: date sorts: - timestamp: - id: timestamp + changed: + id: changed table: comment field: changed order: DESC @@ -57,7 +57,7 @@ display: filters: status_extra: id: status_extra - table: node + table: node_property_data field: status_extra relationship: nid group: '0' @@ -84,7 +84,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.glossary.yml b/core/modules/views/config/views.view.glossary.yml index adf523d..d3b7708 100644 --- a/core/modules/views/config/views.view.glossary.yml +++ b/core/modules/views/config/views.view.glossary.yml @@ -28,7 +28,7 @@ display: fields: title: id: title - table: node + table: node_property_data field: title link_to_node: '1' plugin_id: node @@ -42,7 +42,7 @@ display: plugin_id: user_name changed: id: changed - table: node + table: node_property_data field: changed label: 'Last update' date_format: long @@ -50,7 +50,7 @@ display: 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 plugin_id: standard style: @@ -125,7 +125,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 f138efb..8671362 100644 --- a/core/modules/views/config/views.view.taxonomy_term.yml +++ b/core/modules/views/config/views.view.taxonomy_term.yml @@ -25,13 +25,13 @@ display: sorts: sticky: id: sticky - table: node + table: node_property_date field: sticky order: DESC plugin_id: standard created: id: created - table: node + table: node_property_date field: created order: DESC plugin_id: date @@ -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 6e3b025..03cd9d9 100644 --- a/core/modules/views/config/views.view.tracker.yml +++ b/core/modules/views/config/views.view.tracker.yml @@ -28,7 +28,7 @@ display: relationships: uid: id: uid - table: node + table: node_property_data field: uid plugin_id: standard fields: @@ -39,7 +39,7 @@ display: plugin_id: node_type title: id: title - table: node + table: node_property_data field: title plugin_id: node name: @@ -61,14 +61,6 @@ display: field: last_comment_timestamp label: 'Last Post' plugin_id: comment_last_timestamp - timestamp: - id: timestamp - table: history - field: timestamp - label: '' - link_to_node: '0' - comments: '1' - plugin_id: node_history_user_timestamp new_comments: id: new_comments table: node @@ -87,7 +79,7 @@ display: arguments: uid_touch: id: uid_touch - table: node + table: node_property_data field: uid_touch exception: title_enable: '1' @@ -101,7 +93,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 75623b8..02a01c0 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 @@ -157,6 +157,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi $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/Handler/ArgumentStringTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php index b0098f3..e1ed866 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/ArgumentStringTest.php @@ -47,13 +47,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/UI/SettingsTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php index 28978d6..5a5420e 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/SettingsTest.php @@ -116,7 +116,7 @@ function testEditUI() { $xpath = $this->xpath('//div[@class="views-query-info"]//pre'); $this->assertEqual(count($xpath), 1, 'The views sql is shown.'); $this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.'); - $this->assertTrue(strpos($xpath[0], "node.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.'); + $this->assertTrue(strpos($xpath[0], "node_property_data.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.'); } } 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 51ba883..b8a2a0b 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 0813353..ccae66d 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['id'] = 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); @@ -60,7 +60,7 @@ function testSorting() { $view2['human_name'] = $this->randomName(16); $view2['id'] = 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/test_views/views.view.test_argument_default_current_user.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_current_user.yml index 3d57318..a51253b 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_current_user.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_current_user.yml @@ -12,7 +12,7 @@ display: default_action: default field: uid id: uid - table: node + table: node_property_data plugin_id: numeric cache: type: none @@ -33,7 +33,7 @@ display: hide_empty: '0' id: title link_to_node: '0' - table: node + table: node_property_data plugin_id: node pager: options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_fixed.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_fixed.yml index c9c59bd..2b0e269 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_argument_default_fixed.yml +++ b/core/modules/views/tests/views_test_config/test_views/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 plugin_id: node pager: options: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_destroy.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_destroy.yml index 5758759..09b3507 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_destroy.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_destroy.yml @@ -35,21 +35,21 @@ display: field: created_day id: created_day style_plugin: default_summary - table: node + table: node_property_data plugin_id: node_created_day created_fulldate: default_argument_type: fixed field: created_fulldate id: created_fulldate style_plugin: default_summary - table: node + table: node_property_data plugin_id: node_created_fulldate created_month: default_argument_type: fixed field: created_month id: created_month style_plugin: default_summary - table: node + table: node_property_data plugin_id: node_created_month cache: type: none @@ -72,7 +72,7 @@ display: created: field: created id: created - table: node + table: node_property_data plugin_id: date nid: field: nid @@ -93,12 +93,12 @@ display: status: field: status id: status - table: node + table: node_property_data plugin_id: boolean title: field: title id: title - table: node + table: node_property_data plugin_id: string footer: area: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_display.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_display.yml index 14269f0..c6f57c5 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_display.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_display.yml @@ -44,14 +44,14 @@ display: title: field: title id: title - table: node + table: node_property_data plugin_id: node filters: status: field: status group: '1' id: status - table: node + table: node_property_data value: '1' plugin_id: boolean pager: @@ -70,7 +70,7 @@ display: field: created id: created order: DESC - table: node + table: node_property_data plugin_id: date style_plugin: default title: 'Test Display' diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_admin_ui.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_admin_ui.yml index 488bcc8..521f72e 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_admin_ui.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_exposed_admin_ui.yml @@ -29,7 +29,7 @@ display: created: field: created id: created - table: node + table: node_property_data plugin_id: date style: type: default diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_feed_display.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_feed_display.yml index 24f6e2e..f04c490 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_feed_display.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_feed_display.yml @@ -28,7 +28,7 @@ display: id: title label: '' link_to_node: '1' - table: node + table: node_property_data plugin_id: node filters: status: @@ -37,7 +37,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' plugin_id: boolean pager: @@ -57,7 +57,7 @@ display: field: created id: created order: DESC - table: node + table: node_property_data plugin_id: date style: type: default diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_get_entity.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_get_entity.yml index 5b951c2..e447195 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_field_get_entity.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_field_get_entity.yml @@ -52,7 +52,7 @@ display: label: author relationship: nid required: '0' - table: node + table: node_property_data plugin_id: standard sorts: { } style: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_date_between.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_date_between.yml index 3008935..cc7b924 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_date_between.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_date_between.yml @@ -21,7 +21,7 @@ display: created: field: created id: created - table: node + table: node_property_data plugin_id: date pager: type: full diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_group_override.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_group_override.yml index d0e94f9..588b9e4 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_group_override.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_group_override.yml @@ -19,7 +19,7 @@ display: field: title id: title label: '' - table: node + table: node_property_data plugin_id: node filters: status: @@ -28,7 +28,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' plugin_id: boolean pager: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_groups.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_groups.yml index f04854b..4f388e5 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_groups.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_filter_groups.yml @@ -19,7 +19,7 @@ display: field: title id: title label: '' - table: node + table: node_property_data plugin_id: node filter_groups: groups: @@ -48,7 +48,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' plugin_id: boolean pager: @@ -62,7 +62,7 @@ display: field: created id: created order: DESC - table: node + table: node_property_data plugin_id: date title: test_filter_groups style: @@ -105,7 +105,7 @@ display: field: status group: '1' id: status - table: node + table: node_property_data value: '1' plugin_id: boolean path: test-filter-groups diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_glossary.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_glossary.yml index 95a1b5b..f8db11e 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_glossary.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_glossary.yml @@ -19,7 +19,7 @@ display: number_of_records: '0' summary_options: items_per_page: '25' - table: node + table: node_property_data plugin_id: string cache: type: none @@ -30,7 +30,7 @@ display: field: title id: title label: '' - table: node + table: node_property_data plugin_id: node pager: type: full diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_handler_relationships.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_handler_relationships.yml index 8eda05c..cc50539 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_handler_relationships.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_handler_relationships.yml @@ -8,7 +8,7 @@ display: fields: title: id: title - table: node + table: node_property_data field: title plugin_id: node relationships: diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_redirect_view.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_redirect_view.yml index 7868325..2ad0224 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_redirect_view.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_redirect_view.yml @@ -34,7 +34,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: @@ -63,7 +63,7 @@ display: sorts: created: id: created - table: node + table: node_property_data field: created order: DESC plugin_id: date diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_pager_full_zero_items_per_page.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_pager_full_zero_items_per_page.yml index 5fa6f25..1cc6578 100644 --- a/core/modules/views/tests/views_test_config/test_views/views.view.test_view_pager_full_zero_items_per_page.yml +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_view_pager_full_zero_items_per_page.yml @@ -26,7 +26,7 @@ display: hide_empty: '0' id: title link_to_node: '0' - table: node + table: node_property_data plugin_id: node pager: options: