TypeError: Unsupported operand types: array + null

Created on 3 July 2025, 8 days ago

Versions

Drupal Core: 10.4.8
Search API Solr: 4.3.10
Search API Opensolr: 2.2.3
OpenSolr Core Type [Index or Cluster]: Index
OpenSolr Core Version & Country: Chicago 9.6

While trouble shooting the initial setup, I had also enabled, disabled, and re-enabled the search_api_opensolr_security sub-module. (The search index is currently working, but I can no longer edit the server or the security settings. I plan to report the error I get when trying to edit the security settings in a separate issue and will update this one with a link after I do so.)

Problem/Motivation

I get a PHP error when I try to edit the search API server:

Message: TypeError: Unsupported operand types: array + null in Drupal\Core\Render\Element\Select::processSelect() (line 152 of /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...).

Severity: Error

Backtrace:
#0 [internal function]: Drupal\Core\Render\Element\Select::processSelect()
#1 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(1011): call_user_func_array()
#2 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(1074): Drupal\Core\Form\FormBuilder->doBuildForm()
#3 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(1074): Drupal\Core\Form\FormBuilder->doBuildForm()
#4 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(1074): Drupal\Core\Form\FormBuilder->doBuildForm()
#5 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(1074): Drupal\Core\Form\FormBuilder->doBuildForm()
#6 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(579): Drupal\Core\Form\FormBuilder->doBuildForm()
#7 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(326): Drupal\Core\Form\FormBuilder->processForm()
#8 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(73): Drupal\Core\Form\FormBuilder->buildForm()
#9 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/modules/layout...(39): Drupal\Core\Controller\FormController->getContentResult()
#10 [internal function]: Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
#11 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(123): call_user_func_array()
#12 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(638): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(121): Drupal\Core\Render\Renderer->executeInRenderContext()
#14 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
#15 /var/www/www.umass.edu/agriculture-food-environment/.blue/vendor/symfony/http-ker...(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /var/www/www.umass.edu/agriculture-food-environment/.blue/vendor/symfony/http-ker...(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
#17 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(53): Symfony\Component\HttpKernel\HttpKernel->handle()
#18 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(48): Drupal\Core\StackMiddleware\Session->handle()
#19 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
#20 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/modules/big_pi...(32): Drupal\Core\StackMiddleware\ContentLength->handle()
#21 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/modules/page_c...(116): Drupal\big_pipe\StackMiddleware\ContentLength->handle()
#22 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/modules/page_c...(90): Drupal\page_cache\StackMiddleware\PageCache->pass()
#23 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/modules/ban/sr...(50): Drupal\page_cache\StackMiddleware\PageCache->handle()
#24 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(48): Drupal\ban\BanMiddleware->handle()
#25 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
#26 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
#27 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(51): Drupal\Core\StackMiddleware\AjaxPageState->handle()
#28 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/core/lib/Drupal/Cor...(741): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
#29 /var/www/www.umass.edu/agriculture-food-environment/.blue/web/index.php(19): Drupal\Core\DrupalKernel->handle()
#30 {main}

Steps to reproduce

Go to /admin/config/search/search-api/server/opensolr_####/edit

Proposed resolution

Possible cause: Search API Opensolr leaves the #options property of a
element NULL; when Drupal core tries to merge that value with its default “_none” option ($element['#options'] += …) PHP 8 throws “array + null”.

User interface changes

NA

API changes

NA

🐛 Bug report
Status

Active

Version

2.2

Component

Code

Created by

🇺🇸United States thoogend

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @thoogend
  • 🇷🇴Romania bbu23

    Hi, thanks for reporting this issue, and providing detailed information.
    It seems that the index selector field might be affected.
    I'll look into it.

  • 🇺🇸United States thoogend
  • 🇺🇸United States thoogend
  • 🇷🇴Romania bbu23

    Could you confirm the following:
    1. You were not using the key module when you initially defined your opensolr credentials
    2. You've recently installed the key module
    3. If you navigate to opensolr config form /admin/config/search/search-api/opensolr you see the secret key select with an empty value set to "- Select a key -"

  • 🇺🇸United States thoogend

    1 and 2: The key module was installed and in use before installing search_api_opensolr. I can't remember now for sure, but believe the initial setup I did for opensolr was done with the key module.
    3. When I navigate to the opensolr config form, it is not empty. I see the key name I setup.

    I double checked the Automation REST API Key in our opensolr account and was surprised to see that it does not match the value I stored in the string. Should I update the key value to match and test again?

  • 🇷🇴Romania bbu23

    Interesting. Yes, please. Try updating the key to match the one in your opensolr account and let me know if you can edit the Server after that.

  • 🇺🇸United States thoogend

    That fixed the problem. It also fixed the related issue.

    I wonder why the API key changed. I did not regenerate it. We tested with the free account on opensolr a couple of days ago. When indexing failed part way through, we worked with opensolr support to reload the index. After they did that, the drush sapi-i command ran through to completion and everything worked wonderfully (search performance with opensolr as the backend instead of the database is so much faster). Is it possible the API key was regenerated as a part of that reload?

    Thank you so much for your support in fixing this issue! I really appreciate it.

  • 🇷🇴Romania bbu23

    That's excellent news! I'm really glad to hear that the fix worked and resolved both the main issue and the related one.

    Regarding the API key changing unexpectedly on your end, I honestly don't know why that would have happened. On my side, during development and testing, I've sometimes accidentally regenerated keys, so I know it can occur. However, if your experience was different and you didn't manually regenerate it, it's intriguing, I'll have to check what other opensolr actions can lead to this.

    I'll keep both issues open for now. My goal is to prevent similar crashes from happening and to ensure that if any failures do occur, the module provides clearer status messages so issues like this are easier to diagnose in the future.

    Thank you for your collaboration while we worked through this. I'm really glad I could help!

  • 🇺🇸United States thoogend

    If you work on code updates related to these issues, I would be more than happy to help test patches. Thanks again for your help!

  • 🇷🇴Romania bbu23

    That would be a great help!
    Thank you, I will post the updates on the issues when I have a patch.

Production build 0.71.5 2024