Problem/Motivation

Non existing $video['#cache']['tags'] causes error:

The website encountered an unexpected error. Please try again later.
TypeError: Argument 2 passed to Drupal\Core\Cache\Cache::mergeTags() must be of the type array, null given, called in /docroot/modules/contrib/colorbox_media_video/src/Plugin/Field/FieldFormatter/ColorboxMediaRemoteVideoFormatter.php on line 456 in Drupal\Core\Cache\Cache::mergeTags() (line 57 of core/lib/Drupal/Core/Cache/Cache.php).
Drupal\Core\Cache\Cache::mergeTags() (Line: 456)
Drupal\colorbox_media_video\Plugin\Field\FieldFormatter\ColorboxMediaRemoteVideoFormatter->viewElements() (Line: 89)
Drupal\Core\Field\FormatterBase->view() (Line: 263)
Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple() (Line: 351)
Drupal\Core\Entity\EntityViewBuilder->buildComponents() (Line: 293)
Drupal\Core\Entity\EntityViewBuilder->buildMultiple() (Line: 250)
Drupal\Core\Entity\EntityViewBuilder->build()
call_user_func_array() (Line: 100)

Steps to reproduce

I used Colorbox Media Remote Video formatter and it returened the error.

Proposed resolution

Add validation for existing $video['#cache']['tags'] and set empty value is needed. I will attach patch for this problem.

Comments

levmyshkin created an issue. See original summary.

levmyshkin’s picture

I used this patch for my project ^^