Follow up for 4. in
#1658846-187: Add language support to node access grants and records β
Problem/Motivation
If some hook implementation defines a langcode, but language is off or the language is not enabled, it looks like this would blow up.
Proposed resolution
If some hook implementation defines a langcode, but language is off or the language is not enabled, it looks like this would blow up. Did I say that already and ask for a test for it? Edit: No, I think I said maybe it was on the contrib module to add language to its requirements. However, let's make sure we document that somehow, somewhere. If you execute a db_insert() with no values, does it simply insert no records, or does it fail? Can someone test this?
Remaining tasks
- Find out what happens when execute a db_insert() with no values. Does it simply insert no records, or does it fail?
- Add comments to the code to document what happens.
- Add the test for if a module has some hook implementation defining a langcode when language is not enabled. See contributor task document for writing tests: http://drupal.org/node/1468170
User interface changes
No UI changes.
API changes
No API changes.
Original report by @xjm
In 4. in
#1658846-187: Add language support to node access grants and records β
+++ b/core/modules/node/node.moduleundefined
@@ -3036,18 +3077,35 @@ function _node_access_write_grants(Node $node, $grants, $realm = NULL, $delete =
+ if (isset($grant['langcode'])) {
+ $grant_languages = array($grant['langcode'] => language_load($grant['langcode']));
+ }
+ else {
+ $grant_languages = $node->getTranslationLanguages(TRUE);
+ }
+ foreach ($grant_languages as $grant_langcode => $grant_language) {
+ // Only write grants; denies are implicit.
+ if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) {
+ $grant['nid'] = $node->nid;
+ $grant['langcode'] = $grant_langcode;
+ // The record with the original langcode is used as the fallback.
+ if ($grant['langcode'] == $node->langcode) {
+ $grant['fallback'] = 1;
+ }
+ else {
+ $grant['fallback'] = 0;
+ }
+ $query->values($grant);
+ }
If some hook implementation defines a langcode, but language is off or the language is not enabled, it looks like this would blow up. Did I say that already and ask for a test for it? Edit: No, I think I said maybe it was on the contrib module to add language to its requirements. However, let's make sure we document that somehow, somewhere. If you execute a db_insert() with no values, does it simply insert no records, or does it fail? Can someone test this?