I have upgraded from Drupal 8.9.2, which had no errors, to Drupal 9.0.2 - everything ran smoothly. No errors. But when trying to create a standard Article, the core library gives me the following error:
The website encountered an unexpected error. Please try again later. Error: Call to a member function getAccountName() on null in Drupal\node\NodeForm->form() (line 155 of core/modules/node/src/NodeForm.php). quote Drupal\node\NodeForm->form(Array, Object) (Line: 106) Drupal\Core\Entity\EntityForm->buildForm(Array, Object) call_user_func_array(Array, Array) (Line: 532) Drupal\Core\Form\FormBuilder->retrieveForm('node_article_form', Object) (Line: 278) Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73) Drupal\Core\Controller\FormController->getContentResult(Object, Object) call_user_func_array(Array, Array) (Line: 123) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 573) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97) Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber{closure}() (Line: 158) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 705) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
What is exactly causing it? My modules are: Schema.org 8x-16 (the latest), Metatag and Google Analytics - are the latest. Standard Bartik theme.
Comments
Comment #2
droodpal commentedComment #3
avpadernoComment #4
cilefen commentedThis looks like a duplicate of this critical: #3153455: UID base field override configs can still have old default value callbacks.
Comment #5
droodpal commentedComment #6
droodpal commentedThe Schema.org Metatag 8x-16 is causing it, the module is not ready for the D9.
Comment #7
cilefen commentedI am closing this as a core issue.
Comment #8
droodpal commentedComment #9
droodpal commentedJust to update:
the same issue when manually upgrading from Drupal 8.9.7 to Drupal 9.0.7 with Schema.org Metatag 8x-2.1.
Comment #10
droodpal commentedComment #11
droodpal commentedJust to update, tried to upgrade from a cleaned dev website, with no modules. From 8.9.11 to 9.10, the same error referring to the core/modules/Node.php. Cleaned all caches manually in the admin.php, like cache_entity, cache_config, etc, nothing changed.
Comment #12
alexpertsi commentedSame problem after update 8.6.3 -> 8.9.16 -> 9.2.1
I get this error when I try to add a new node
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getAccountName() on null in Drupal\node\NodeForm->form() (line 155 of C:\wamp64\www\mysite\core\modules\node\src\NodeForm.php)
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'Drupal\node\Entity\Node' does not have a method 'getCurrentUserId' in Drupal\Core\Field\FieldConfigBase->getDefaultValue() (line 398 of C:\wamp64\www\mysite\core\lib\Drupal\Core\Field\FieldConfigBase.php)
Comment #13
attraktive commentedHello,
Same problem after update 8.9.18 > 9.2.5
The website encountered an unexpected error. Please try again later.
Error: Call to a member function getAccountName() on null in Drupal\node\NodeForm->form() (line 155 of core/modules/node/src/NodeForm.php).
Without the warning.
Thanks
Comment #14
attraktive commentedok solved Here :
https://www.drupal.org/project/drupal/issues/3161212#comment-14174315
#8 ans #10 comments did the trick ;)
Thanks
Comment #15
Sbonder commentedFor me I solved it by a Drush command to update default callback:
Comment #16
Dency Mary AThanks Sbonder .
#15 working good in Drupal 9.3
Comment #17
devil2005 commentedHi,
I have this error when i try to test #15 :
[error] Config core.base_field_override.media.document.uid does not exist
same for others commands
thanks
Comment #18
devnull_13 commentedI also had this issue and #15 was the method I used but my default callback and entities had different names.
I used
drush config:exportto get the files to search through withgrep -R "getCurrentUserId" *This gave me the correct strings for my config and I changed them via
drush config:set GREP_VALUE default_value_callback 'Drupal\PATH\FROM\GREP::getDefaultEntityOwner' -yso a grep line
core.base_field_override.node.article.uid.yml:default_value_callback: 'Drupal\node\Entity\Node::getCurrentUserId'became
./vendor/bin/drush config:set core.base_field_override.node.article.uid default_value_callback 'Drupal\node\Entity\Node::getDefaultEntityOwner' -yComment #19
rahul_sankrit commentedIn Drupal 9.4.x, I had the same issue and #15 worked fine.
Thank you.