- Issue created by @webadpro
- 🇨🇦Canada webadpro
Error:
For error #0: TypeError: Drupal\language\LanguageNegotiationMethodBase::setCurrentUser(): Argument #1 ($current_user) must be of type Drupal\Core\Session\AccountInterface, null given, called in /app/web/core/modules/language/src/LanguageNegotiator.php on line 215 in Drupal\language\LanguageNegotiationMethodBase->setCurrentUser() (line 52 of /app/web/core/modules/language/src/LanguageNegotiationMethodBase.php) #0 /app/web/core/modules/language/src/LanguageNegotiator.php(215): Drupal\language\LanguageNegotiationMethodBase->setCurrentUser(NULL) #1 /app/web/modules/contrib/graphql_core_schema/src/Plugin/GraphQL/DataProducer/Route.php(211): Drupal\language\LanguageNegotiator->getNegotiationMethodInstance('language-url') #2 [internal function]: Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\Route->resolve('/jacestrap', Object(Drupal\graphql\GraphQL\Execution\FieldContext)) #3 /app/web/modules/contrib/graphql/src/Plugin/GraphQL/DataProducer/DataProducerPluginBase.php(51): call_user_func_array(Array, Array) #4 /app/web/modules/contrib/graphql/src/Plugin/GraphQL/DataProducer/DataProducerProxy.php(238): Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase->resolveField(Object(Drupal\graphql\GraphQL\Execution\FieldContext)) #5 /app/web/modules/contrib/graphql/src/Plugin/GraphQL/DataProducer/DataProducerProxy.php(181): Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerProxy->resolveUncached(Object(Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\Route), Object(Drupal\graphql\GraphQL\Execution\ResolveContext), Object(Drupal\graphql\GraphQL\Execution\FieldContext)) #6 /app/web/modules/contrib/graphql/src/GraphQL/Utility/DeferredUtility.php(72): Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerProxy->Drupal\graphql\Plugin\GraphQL\DataProducer\{closure}(Object(Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\Route)) #7 /app/web/modules/contrib/graphql/src/Plugin/GraphQL/DataProducer/DataProducerProxy.php(182): Drupal\graphql\GraphQL\Utility\DeferredUtility::returnFinally(Object(Drupal\graphql_core_schema\Plugin\GraphQL\DataProducer\Route), Object(Closure))
- Status changed to Needs review
over 1 year ago 12:01pm 9 August 2023 - 🇮🇳India shabana.navas
Not sure if this is the correct fix, but maybe we can check to see if it's a multilingual site before calling negotiator.
- 🇨🇭Switzerland dulnan
I think the issue comes from the fact that the language-url negotiator is not enabled in a single-language setup, but the data producer still tries to get an instance of it. While this works even if the negotiator is not enabled, it seems that, because it has not been initialized properly by Drupal, the $currentUser on the instance is NULL.
I have added a check to see if the language-url method is enabled before getting the instance. I think this will also resolve the issue.
- 🇨🇦Canada webadpro
There are still bugs within this commit. Where the languageNegotiator is still being referenced in the code.
- 🇨🇦Canada webadpro
I've pushed some code changes which seems to be fixing my issue https://git.drupalcode.org/issue/graphql_core_schema-3373726/-/compare/1...
- 🇨🇭Switzerland ayalon
I was able to reproduce both errors:
- Case: 1: Just a single language installed but language module enabled
- Case: 2: Language module disabled
I have fixed both cased and improved the code to support Case 1 and Case 2.
The fix will be part of the upcoming relase, which will be released soon.
- Status changed to Fixed
10 months ago 9:07am 24 January 2024