diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php index da0862a..e522c9f 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php @@ -169,15 +169,15 @@ function testNodeAccessLanguageAware() { $this->assertNodeAccess($expected_node_access_no_access, $this->nodes['both_private'], $this->web_user, 'ca'); $this->assertNodeAccess($expected_node_access_no_access, $this->nodes['both_private'], $this->web_user, 'en'); - // No language private Node: + // No language private node: // The only existing language (not specified) is set as private, so no - // access on every language + // access on every language. $this->assertNodeAccess($expected_node_access_no_access, $this->nodes['no_language_private'], $this->web_user); $this->assertNodeAccess($expected_node_access_no_access, $this->nodes['no_language_private'], $this->web_user, 'hu'); $this->assertNodeAccess($expected_node_access_no_access, $this->nodes['no_language_private'], $this->web_user, 'ca'); $this->assertNodeAccess($expected_node_access_no_access, $this->nodes['no_language_private'], $this->web_user, 'en'); - // No language public Node: + // No language public node: // The only existing language (not specified) is set as public, so only // the request with no language will give access, as this request will be // made with the lancode of the node, which is "not specified". @@ -198,7 +198,7 @@ function testNodeAccessLanguageAware() { // Three nodes should be returned: // - Node with both translations public. // - Node with only the Catalan translation marked as private. - // - No language Node marked as public. + // - No language node marked as public. $this->assertEqual(count($nids), 3, 'db_select() returns 3 nodes when no langcode is specified.'); $this->assertTrue(array_key_exists($this->nodes['both_public']->nid, $nids), 'The node with both translations public is returned.'); $this->assertTrue(array_key_exists($this->nodes['ca_private']->nid, $nids), 'The node with only the Catalan translation private is returned.'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php index ab18ff6..85b0a52 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php @@ -35,7 +35,7 @@ function setUp() { // After enabling a node access module, the access table has to be rebuild. node_access_rebuild(); - // Enable the private node feature of node_access_test module. + // Enable the private node feature of the node_access_test module. state()->set('node_access_test.private', TRUE); // Add Hungarian and Catalan. diff --git a/core/modules/node/node.install b/core/modules/node/node.install index dde2fea..238f375 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -724,7 +724,7 @@ function node_update_8014() { } /** - * Add language.langcode and fallback field to {node_access} table. + * Add language support to the {node_access} table */ function node_update_8015() { // Add the langcode field. diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d6c7e13..ef55586 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2508,10 +2508,6 @@ function node_form_system_themes_admin_form_submit($form, &$form_state) { * TRUE if the operation may be performed, FALSE otherwise. * * @see node_menu() - * - * @todo - * Add langcode support to node_access schema / queries. - * http://drupal.org/node/1658846 */ function node_access($op, $node, $account = NULL, $langcode = NULL) { if (!$node instanceof EntityInterface) { @@ -2807,7 +2803,6 @@ function node_query_node_access_alter(AlterableInterface $query) { // Find all instances of the base table being joined -- could appear // more than once in the query, and could be aliased. Join each one to // the node_access table. - $grants = node_access_grants($op, $account); foreach ($tables as $nalias => $tableinfo) { $table = $tableinfo['table']; @@ -2817,8 +2812,8 @@ function node_query_node_access_alter(AlterableInterface $query) { ->fields('na', array('nid')); $grant_conditions = db_or(); - // If any grant exists for the specified user, - // then user has access to the node for the specified operation. + // If any grant exists for the specified user, then user has access to the + // node for the specified operation. foreach ($grants as $realm => $gids) { foreach ($gids as $gid) { $grant_conditions->condition(db_and() @@ -2834,11 +2829,11 @@ function node_query_node_access_alter(AlterableInterface $query) { } $subquery->condition('na.grant_' . $op, 1, '>='); - // Add langcode based filtering if on a multilingual site. + // Add langcode-based filtering if this is a multilingual site. if (language_multilingual()) { // If no specific langcode to check for is given, use the grant entry - // which is set as fallback. - // If specific langcode is given, use the grant entry for it. + // which is set as a fallback. + // If a specific langcode is given, use the grant entry for it. if ($langcode === FALSE) { $subquery->condition('na.fallback', 1, '='); } @@ -2851,8 +2846,6 @@ function node_query_node_access_alter(AlterableInterface $query) { // Now handle entities. $subquery->where("$nalias.$field = na.nid"); - drupal_alter('node_access_tag_subquery', $subquery, $query); - $query->exists($subquery); } } @@ -2922,8 +2915,8 @@ function _node_access_write_grants(EntityInterface $node, $grants, $realm = NULL // Only perform work when node_access modules are active. if (!empty($grants) && count(module_implements('node_grants'))) { $query = db_insert('node_access')->fields(array('nid', 'langcode', 'fallback', 'realm', 'gid', 'grant_view', 'grant_update', 'grant_delete')); - // If we have defined a granted langcode, use it. But if not, add a grant for - // every language this node is translated to. + // If we have defined a granted langcode, use it. But if not, add a grant + // for every language this node is translated to. foreach ($grants as $grant) { if ($realm && $realm != $grant['realm']) { continue; @@ -3530,7 +3523,7 @@ function node_modules_disabled($modules) { // loaded in memory. Module functions must no longer be called. We only // check whether a hook implementation function exists and do not invoke it. // Node access also needs to be rebuilt if language module is disabled - // to remove any language specific grants. + // to remove any language-specific grants. if (!node_access_needs_rebuild() && (module_hook($module, 'node_grants') || $module == 'language')) { node_access_needs_rebuild(TRUE); }