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

droodpal created an issue. See original summary.

droodpal’s picture

Issue summary: View changes
avpaderno’s picture

Assigned: droodpal » Unassigned
Issue tags: -Drupal 9, -update, -nodeformsettings, -bug
cilefen’s picture

Status: Active » Postponed (maintainer needs more info)
Related issues: +#3153455: UID base field override configs can still have old default value callbacks
droodpal’s picture

Title: Can't create an Article after an update to Drupal 9.0.2 » Can't create an Article node after an upgrade to Drupal 9.0.2
Issue summary: View changes
droodpal’s picture

The Schema.org Metatag 8x-16 is causing it, the module is not ready for the D9.

cilefen’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

I am closing this as a core issue.

droodpal’s picture

Issue summary: View changes
droodpal’s picture

Just 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.

droodpal’s picture

Title: Can't create an Article node after an upgrade to Drupal 9.0.2 » Can't create any new article after an upgrade to Drupal 9.x
droodpal’s picture

Just 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.

alexpertsi’s picture

Same 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)

attraktive’s picture

Hello,

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

attraktive’s picture

ok solved Here :

https://www.drupal.org/project/drupal/issues/3161212#comment-14174315

#8 ans #10 comments did the trick ;)

Thanks

Sbonder’s picture

For me I solved it by a Drush command to update default callback:

drush config:set core.base_field_override.media.document.uid  default_value_callback 'Drupal\media\Entity\Media::getDefaultEntityOwner' -y

drush config:set core.base_field_override.media.file.uid  default_value_callback 'Drupal\media\Entity\Media::getDefaultEntityOwner' -y

drush config:set core.base_field_override.media.image.uid  default_value_callback 'Drupal\media\Entity\Media::getDefaultEntityOwner' -y

drush config:set core.base_field_override.node.landing_page.uid  default_value_callback 'Drupal\media\Entity\Media::getDefaultEntityOwner' -y

drush config:set core.base_field_override.node.page.uid  default_value_callback 'Drupal\media\Entity\Media::getDefaultEntityOwner' -y

drush config:set core.base_field_override.node.slideshow.uid  default_value_callback 'Drupal\media\Entity\Media::getDefaultEntityOwner' -y
Dency Mary A’s picture

Thanks Sbonder .
#15 working good in Drupal 9.3

devil2005’s picture

Hi,

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

devnull_13’s picture

I also had this issue and #15 was the method I used but my default callback and entities had different names.

I used drush config:export to get the files to search through with grep -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' -y

so 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' -y

rahul_sankrit’s picture

In Drupal 9.4.x, I had the same issue and #15 worked fine.

Thank you.