- πΊπΈUnited States alfattal Minnesota
The patch in #104 failed to apply on Drupal 10.2 branch while the patch in #84 still working.
After upgrading from Drupal 8.9 to Drupal 9.0 I get the two following error/warning messages when trying to create new content using some (not all) of my content types, among them the native βpageβ-type:
Error message:
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).
Warning message:
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 397 of core/lib/Drupal/Core/Field/FieldConfigBase.php).
Does anyone know what causes this?
Node::getCurrentUserId
method was deprecated in 8.6.x and was removed in 9.0.0. The replacing method in Drupal 9 is Node::getDefaultEntityOwner
The following workaround steps are for Node entities but should be quite well applicable for other Entity types as well.
1. You want to identify those Node content types that are affected by this issue.
2. You can either a) do this by trial and error i.e. try to create new nodes for each content type on your site and see which content types are affected OR b) you can export your configuration and search for 'getCurrentUserId' to get a list of configuration files that are affected. The following steps use approach b) using Drush command line tool on Linux.
3. Export all configuration from command line using drush config:export
4. Navigate to your config/sync directory.
5. Identify the affected configuration files using
grep -R "getCurrentUserId" *
. The files matching this search will be like core.base_field_override.node.CONTENT_TYPE.uid.yml
, for example core.base_field_override.node.page.uid.yml
. As mentioned above, other entity types than nodes might also be affected.
6. For each affected configuration file, first take a backup of the configuration file. Then, use your favorite text editor and replace default_value_callback: 'Drupal\node\Entity\Node::getCurrentUserId'
with default_value_callback: 'Drupal\node\Entity\Node::getDefaultEntityOwner'
in each affected configuration file. If your site is affected by some other Entity type than Node, you will need to modify this find / replace according to your entity type.
7. Once you have edited all affected configuration you can double check with grep -R "getCurrentUserId" *
that you did not miss any affected configuration file.
8. Once you have fixed all affected configuration files, you will need to import these configurations from your config/sync directory back to your database. This can be done with drush config:import
9. After you have imported the configurations, you will need to rebuild your caches. This can be done with drush cache:rebuild
10. Test and verify that you are now able to create new nodes of the affected content types.
Fixed
9.3
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
The patch in #104 failed to apply on Drupal 10.2 branch while the patch in #84 still working.