Problem/Motivation

Hi,

When I updated my website from 9.5 to 10.2, I found myself unable to edit some contents, whether they're published or not.

I get the following error message :

The website encountered an unexpected error. Try again later.

TypeError: uasort(): Argument #1 ($array) must be of type array, null given in uasort() (line 65 of core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php).
Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager->getPluginId() (Line: 50)
Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager->getInstance() (Line: 101)
Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager->getSelectionHandler() (Line: 671)
Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem->getSettableOptions() (Line: 143)
Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsWidgetBase->getOptions() (Line: 34)
Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsSelectWidget->formElement() (Line: 448)
Drupal\Core\Field\WidgetBase->formSingleElement() (Line: 98)
Drupal\Core\Field\WidgetBase->form() (Line: 186)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm() (Line: 121)
Drupal\Core\Entity\ContentEntityForm->form() (Line: 127)
Drupal\node\NodeForm->form() (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm()
call_user_func_array() (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 704)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Only some types of nodes have this problem, it seems it's those which can be created my any logged-in user, without special privileges, but I could be wrong.
These nodes have only a couple of text field, and a reference to commerce products, but other types of nodes with the same fields but that can only be created of edited by moderators work fine.

Issue fork drupal-3419074

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Shenron_segamag created an issue. See original summary.

Version: 10.2.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

himanshu_jhaloya made their first commit to this issue’s fork.

tabestan’s picture

StatusFileSize
new1.23 KB

Here's a patch that works with 10.2.x.

wanjee’s picture

I have the same error message in 10.2.6 when I try to add a field of type "reference" or "media" to a content type or paragraph (did not test other entity types).

Patch provided in #5 also fixes this issue.

Patch lead to another issue in the same flow ( : "Symfony\Component\Routing\Exception\InvalidParameterException: Parameter "selection_handler" for route "system.entity_autocomplete" must match "[^/]++" ("" given) to generate a corresponding URL. in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 209 of /var/www/html/docroot/core/lib/Drupal/Core/Routing/UrlGenerator.php)."

I think the root cause is related to this ticket: https://www.drupal.org/project/drupal/issues/2327883

pearls’s picture

Tested. Cannot apply patch #5 (3419074-uasort-plugin-manager.patch)
Tested version: Drupal 10.3.2.

coaston’s picture

HI shenron_segamag,

I am experiencing the same issue - it was caused by uninstalling business rules which have been used as "dependent field" based on this guide here :dependent-field, so I had to install it back, however business rules are not D10 ready and are replaced with ECA.

For D10 it would be better to achieve the same with this module dependent_fields and this guide: guide

In my case for every content type where such "dependent" business rule entity reference is being used I am unable to edit/add once bussines rules module is not available. In content which does not have such rule everything works as expected. So looks like similar or the same issues to me.

Maybe it is different case, but at least it can help anyone else who tries to migrate from D9 to D10 and deleted all business rules but forgot to get rid of rules configured in views as entity reference.

rajneeshb made their first commit to this issue’s fork.

shenron_segamag’s picture

Hi @coaston,

Thank you, I had no idea business rules was a requirement to use dependent fields. I have already started to use ECA instead of it, but I will follow your advice to totally get rid of it.

mialdi98’s picture

StatusFileSize
new1.19 KB

Created a patch for version 10.3.0 , as attached #5 and the one that comes with a merge request didn't work.

mdranove’s picture

StatusFileSize
new753 bytes

For me patch in #11 fixes the exception in SelectionPluginManager, but then leads to the exception described in #6.

I think this patch ought to be a temporary solution. Believe this is isn't necessary in d11.

kumudb’s picture

I am not able to reproduce this on Drupal 11.x.dev version there is no error occuring while creating or editing node type with entity reference fields.
Steps to Reproduce
1. Create a Content Type

  • Add fields that reference other entities, such as Commerce Products or other content types.
  • Allow any logged-in user to create/edit these nodes

.

2.Test Permissions:

  • Ensure permissions are assigned such that non-moderator roles can interact with these fields.

3. Test Node Edit:

  • Create a node type.
  • Attempt to edit the node as a user with minimal privileges.

4.Check Field Configuration:

  • Review the entity reference field’s storage and widget settings.
  • Ensure the selection handler is correctly set and aligns with the referenced entity type.
cilefen’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce, +Needs issue summary update, +Needs tests
smustgrave’s picture

Bumping 1 more time for steps before closing please.

mykola dolynskyi’s picture

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.