array_merge(): Expected parameter 1 to be an array, null given

Created on 29 April 2021, over 3 years ago
Updated 3 October 2023, about 1 year ago

Problem/Motivation

When using audiofield for file fields with jplayer or MediaElement Player selected, Drupal throws these php warnings in Drupal log and on the website:
Warning: array_merge(): Expected parameter 1 to be an array, null given in Drupal\Core\Theme\Registry->mergePreprocessFunctions() (line 671 of /app/web/core/lib/Drupal/Core/Theme/Registry.php)
Warning: array_diff(): Expected parameter 2 to be an array, null given in Drupal\Core\Theme\Registry->mergePreprocessFunctions() (line 670 of /app/web/core/lib/Drupal/Core/Theme/Registry.php)
Notice: Undefined index: preprocess functions in Drupal\Core\Theme\Registry->mergePreprocessFunctions() (line 670 of /app/web/core/lib/Drupal/Core/Theme/Registry.php)

Steps to reproduce

Use audiofield ("drupal/audiofield": "1.x-dev@dev") with the bootstrap theme (Bootstrap 8.x-3.23).

Proposed resolution

It looks like that all warnings are related and the issue has somehow to do with:

/**
 * Implements hook_theme_registry_alter().
 */
function audiofield_theme_registry_alter(&$theme_registry) {
  /*
   * By default, Drupal 8 does not include theme suggestions from inside the
   * module in which they were created, so we must add them manually here.
   */
  $path = drupal_get_path('module', 'audiofield');
  $audioplayer_templates = drupal_find_theme_templates($theme_registry, '.html.twig', $path);
  foreach ($audioplayer_templates as &$audioplayer_template) {
    $audioplayer_template['type'] = 'module';
  }
  $theme_registry += $audioplayer_templates;
}

in file audiofield.module. When I deactivate the last line, there are no warnings anymore.

The full log for the first warning is:

#0 /app/web/core/includes/bootstrap.inc(600): _drupal_error_handler_real(2, 'array_merge(): ...', '/app/web/core/l...', 671, Array)
#1 [internal function]: _drupal_error_handler(2, 'array_merge(): ...', '/app/web/core/l...', 671, Array)
#2 /app/web/core/lib/Drupal/Core/Theme/Registry.php(671): array_merge(NULL, NULL)
#3 /app/web/core/lib/Drupal/Core/Theme/Registry.php(638): Drupal\Core\Theme\Registry->mergePreprocessFunctions('audioplayer__jp...', 'audioplayer__jp...', Array, Array)
#4 /app/web/core/lib/Drupal/Core/Theme/Registry.php(759): Drupal\Core\Theme\Registry->completeSuggestion('audioplayer__jp...', Array)
#5 /app/web/themes/contrib/bootstrap/src/Plugin/Alter/ThemeRegistry.php(142): Drupal\Core\Theme\Registry->postProcessExtension(Array, Object(Drupal\Core\Theme\ActiveTheme))
#6 /app/web/themes/contrib/bootstrap/src/Bootstrap.php(303): Drupal\bootstrap\Plugin\Alter\ThemeRegistry->alter(Array, NULL, NULL)
#7 /app/web/themes/contrib/bootstrap/bootstrap.theme(139): Drupal\bootstrap\Bootstrap::alter('bootstrap_theme...', Array, NULL, NULL)
#8 /app/web/core/lib/Drupal/Core/Theme/ThemeManager.php(449): bootstrap_theme_registry_alter(Array, NULL, NULL)
#9 /app/web/core/lib/Drupal/Core/Theme/Registry.php(374): Drupal\Core\Theme\ThemeManager->alterForTheme(Object(Drupal\Core\Theme\ActiveTheme), 'theme_registry', Array)
#10 /app/web/core/lib/Drupal/Core/Theme/Registry.php(240): Drupal\Core\Theme\Registry->build()
#11 /app/web/core/lib/Drupal/Core/Utility/ThemeRegistry.php(88): Drupal\Core\Theme\Registry->get()
#12 /app/web/core/lib/Drupal/Core/Utility/ThemeRegistry.php(69): Drupal\Core\Utility\ThemeRegistry->initializeRegistry()
#13 /app/web/core/lib/Drupal/Core/Theme/Registry.php(260): Drupal\Core\Utility\ThemeRegistry->__construct('theme_registry:...', Object(Drupal\Core\Cache\ChainedFastBackend), Object(Drupal\Core\ProxyClass\Lock\DatabaseLockBackend), Array, true)
#14 /app/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(205): Drupal\Core\Theme\Registry->getRuntime()
#15 /app/web/core/modules/node/src/NodeViewBuilder.php(61): Drupal\Core\Entity\EntityViewBuilder->getBuildDefaults(Object(Drupal\node\Entity\Node), 'full')
#16 /app/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(168): Drupal\node\NodeViewBuilder->getBuildDefaults(Object(Drupal\node\Entity\Node), 'full')
#17 /app/web/core/lib/Drupal/Core/Entity/EntityViewBuilder.php(134): Drupal\Core\Entity\EntityViewBuilder->viewMultiple(Array, 'full', NULL)
#18 /app/web/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php(105): Drupal\Core\Entity\EntityViewBuilder->view(Object(Drupal\node\Entity\Node), 'full')
#19 /app/web/core/modules/node/src/Controller/NodeViewController.php(71): Drupal\Core\Entity\Controller\EntityViewController->view(Object(Drupal\node\Entity\Node), 'full', NULL)
#20 [internal function]: Drupal\node\Controller\NodeViewController->view(Object(Drupal\node\Entity\Node), 'full', NULL)
#21 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#22 /app/web/core/lib/Drupal/Core/Render/Renderer.php(573): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#24 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#25 /app/vendor/symfony/http-kernel/HttpKernel.php(151): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#26 /app/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#27 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /app/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#34 {main} 

Thank you for your support!

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany kopfduenger Wiesbaden

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024