diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php index 08b48d7..d72bd1d 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php @@ -46,13 +46,9 @@ public static function getInfo() { function setUp() { parent::setUp(); + // After enabling a node access module, the access table has to be rebuild. node_access_rebuild(); - // Clear permissions for authenticated users. - db_delete('role_permission') - ->condition('rid', DRUPAL_AUTHENTICATED_RID) - ->execute(); - // Add Hungarian and Catalan. $language = new Language(array( 'langcode' => 'hu', @@ -63,8 +59,12 @@ function setUp() { )); language_save($language); + // Create a normal authenticated user. $this->web_user = $this->drupalCreateUser(array('access content')); + // Load the user 1 user for later use. + $this->admin_user = user_load(1); + // The node_access_test_language module allows individual translations of // a node to be marked private (not viewable by normal users), and the // node_access_test module allows whole nodes to be marked private. (In a @@ -299,20 +299,22 @@ function testNodeAccessLanguageAwareCombination() { // There are no nodes with German translations, so no results are returned. $this->assertTrue(empty($nids), 'db_select() returns an empty result.'); - // Query the nodes table as user 1 (full access) with the node access tag - // and no specific langcode. + // Query the nodes table as admin user (full access) with the node + // access tag and no specific langcode. $select = db_select('node', 'n') ->fields('n', array('nid')) + ->addMetaData('account', $this->admin_user) ->addTag('node_access'); $nids = $select->execute()->fetchAllAssoc('nid'); // All nodes are returned. $this->assertEqual(count($nids), 10, 'db_select() returns all nodes.'); - // Query the nodes table as user 1 (full access) with the node access tag - // and langcode de. + // Query the nodes table as admin user (full access) with the node + // access tag and langcode de. $select = db_select('node', 'n') ->fields('n', array('nid')) + ->addMetaData('account', $this->admin_user) ->addMetaData('langcode', 'de') ->addTag('node_access'); $nids = $select->execute()->fetchAllAssoc('nid'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php index a704913..5b23926 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php @@ -46,16 +46,15 @@ public static function getInfo() { function setUp() { parent::setUp(); + // After enabling a node access module, the access table has to be rebuild. node_access_rebuild(); - // Clear permissions for authenticated users. - db_delete('role_permission') - ->condition('rid', DRUPAL_AUTHENTICATED_RID) - ->execute(); - // Create a normal authenticated user. $this->web_user = $this->drupalCreateUser(array('access content')); + // Load the user 1 user for later use. + $this->admin_user = user_load(1); + // Add Hungarian and Catalan. $language = new Language(array( 'langcode' => 'hu', @@ -239,20 +238,22 @@ function testNodeAccessLanguageAware() { // There are no nodes with German translations, so no results are returned. $this->assertTrue(empty($nids), 'db_select() returns an empty result when the de langcode is specified.'); - // Query the nodes table as user 1 (full access) with the node access tag - // and no specific langcode. + // Query the nodes table as admin user (full access) with the node + // access tag and no specific langcode. $select = db_select('node', 'n') ->fields('n', array('nid')) + ->addMetaData('account', $this->admin_user) ->addTag('node_access'); $nids = $select->execute()->fetchAllAssoc('nid'); // All nodes are returned. $this->assertEqual(count($nids), 6, 'db_select() returns all nodes.'); - // Query the nodes table as user 1 (full access) with the node access tag - // and langcode de. + // Query the nodes table as admin user (full access) with the node + // access tag and langcode de. $select = db_select('node', 'n') ->fields('n', array('nid')) + ->addMetaData('account', $this->admin_user) ->addMetaData('langcode', 'de') ->addTag('node_access'); $nids = $select->execute()->fetchAllAssoc('nid'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php index 04f9f12..b44e53c 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageTest.php @@ -32,13 +32,9 @@ public static function getInfo() { function setUp() { parent::setUp(); + // After enabling a node access module, the access table has to be rebuild. node_access_rebuild(); - // Clear permissions for authenticated users. - db_delete('role_permission') - ->condition('rid', DRUPAL_AUTHENTICATED_RID) - ->execute(); - // Enable the private node feature of node_access_test module. state()->set('node_access_test.private', TRUE); @@ -171,8 +167,12 @@ function testNodeAccessPrivate() { * Tests db_select() with a 'node_access' tag and langcode metadata. */ function testNodeAccessQueryTag() { + // Create a normal authenticated user. $web_user = $this->drupalCreateUser(array('access content')); + // Load the user 1 user for later use. + $admin_user = user_load(1); + // Creating a private node with langcode Hungarian, will be saved as // the fallback in node access table. $node_private = $this->drupalCreateNode(array('body' => array('hu' => array(array())), 'langcode' => 'hu', 'private' => TRUE)); @@ -214,20 +214,22 @@ function testNodeAccessQueryTag() { // Because no nodes are created in German, no nodes are returned. $this->assertTrue(empty($nids), 'db_select() returns an empty result.'); - // Query the nodes table as user 1 (full access) with the node access tag - // and no specific langcode. + // Query the nodes table as admin user (full access) with the node + // access tag and no specific langcode. $select = db_select('node', 'n') ->fields('n', array('nid')) + ->addMetaData('account', $admin_user) ->addTag('node_access'); $nids = $select->execute()->fetchAllAssoc('nid'); // All nodes are returned. $this->assertEqual(count($nids), 3, 'db_select() returns all three nodes.'); - // Query the nodes table as user 1 (full access) with the node access tag - // and langcode de. + // Query the nodes table as admin user (full access) with the node + // access tag and langcode de. $select = db_select('node', 'n') ->fields('n', array('nid')) + ->addMetaData('account', $admin_user) ->addMetaData('langcode', 'de') ->addTag('node_access'); $nids = $select->execute()->fetchAllAssoc('nid'); diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 81069e1..058ec29 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -202,7 +202,7 @@ function node_schema() { 'size' => 'tiny', ), ), - 'primary key' => array('nid', 'gid', 'langcode', 'realm'), + 'primary key' => array('nid', 'gid', 'realm', 'langcode'), 'foreign keys' => array( 'affected_node' => array( 'table' => 'node', @@ -730,7 +730,7 @@ function node_update_8014() { /** * Add language.langcode and fallback field to node_access table. */ -function node_update_8014() { +function node_update_8015() { // Add the langcode field. $langcode_field = array( 'type' => 'varchar', @@ -752,7 +752,7 @@ function node_update_8014() { db_add_field('node_access', 'fallback', $fallback_field); db_drop_primary_key('node_access'); - db_add_primary_key('node_access', array('nid', 'gid', 'langcode', 'realm')); + db_add_primary_key('node_access', array('nid', 'gid', 'realm', 'langcode')); } /**