Follow up for #1658846-199: Add language support to node access grants and records
Problem/Motivation
Logic in the wrong class.
Proposed resolution
Move into NodeAccessController
+++ b/core/modules/node/node.module
@@ -2522,6 +2522,18 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) {
+ // If the Language module is enabled, try to use the language from
+ // content negotiation.
+ if (module_exists('language')) {
+ // Load languages the node exists in.
+ $node_translations = $node->getTranslationLanguages();
+ // Load the language from content negotiation.
+ $content_negotiation_langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
+ // If there is a translation available, use it.
+ if (isset($node_translations[$content_negotiation_langcode])) {
+ $langcode = $content_negotiation_langcode;
+ }
+ }
Remaining tasks
TBD
User interface changes
No UI changes.
API changes
TBD.
Original report by @effulgentsia in #1658846-199: Add language support to node access grants and records
Posted by effulgentsia on March 22, 2013 at 7:06pm
+++ b/core/modules/node/node.module
@@ -2522,6 +2522,18 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) {
+ // If the Language module is enabled, try to use the language from
+ // content negotiation.
+ if (module_exists('language')) {
+ // Load languages the node exists in.
+ $node_translations = $node->getTranslationLanguages();
+ // Load the language from content negotiation.
+ $content_negotiation_langcode = language(LANGUAGE_TYPE_CONTENT)->langcode;
+ // If there is a translation available, use it.
+ if (isset($node_translations[$content_negotiation_langcode])) {
+ $langcode = $content_negotiation_langcode;
+ }
+ }
This logic probably should be moved into NodeAccessController, but didn't do so in #198 in order to keep that a straight reroll. I think that can be follow up material though, unless someone is inspired to do it here.