Problem with updating to Thunder 7 when another editor is also enabled

Created on 11 January 2024, 6 months ago

Problem/Motivation

We came across a problem that when we want to update to Drupal 10 and Thunder 7 the install hook thunder_post_update_0001_upgrade_to_thunder7 gives the following error:

 >  [warning] Undefined array key "toolbar" CKEditor5PluginManager.php:203
  >  [warning] Trying to access array offset on value of type null CKEditor5PluginManager.php:203
  > [2024-01-11T13:22:38.000771+01:00] php.ERROR: TypeError: array_intersect(): Argument #1 ($array) must be of type array, null given in array_intersect() (line 203 of /var/www/html/web/core/modules/c
  keditor5/src/Plugin/CKEditor5PluginManager.php) #0 /var/www/html/web/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php(203): array_intersect(NULL, Array) #1 /var/www/html/web/core/modules/
  ckeditor5/src/SmartDefaultSettings.php(925): Drupal\ckeditor5\Plugin\CKEditor5PluginManager->getEnabledDefinitions(Object(Drupal\editor\Entity\Editor)) #2 /var/www/html/web/core/modules/ckeditor5/src
  /SmartDefaultSettings.php(242): Drupal\ckeditor5\SmartDefaultSettings->addDefaultSettingsForEnabledConfigurablePlugins(Object(Drupal\editor\Entity\Editor)) #3 /var/www/html/web/profiles/contrib/thund
  er/thunder.post_update.php(84): Drupal\ckeditor5\SmartDefaultSettings->computeSmartDefaultSettings(Object(Drupal\editor\Entity\Editor), Object(Drupal\filter\Entity\FilterFormat)) #4 /var/www/html/ven
  dor/drush/drush/src/Commands/core/UpdateDBCommands.php(288): thunder_post_update_0001_upgrade_to_thunder7(Array) #5 /var/www/html/vendor/drush/drush/includes/batch.inc(256): Drush\Commands\core\Updat
  eDBCommands::updateDoOnePostUpdate('thunder_post_up...', Object(DrushBatchContext)) #6 /var/www/html/vendor/drush/drush/includes/batch.inc(201): _drush_batch_worker() #7 /var/www/html/vendor/drush/dr
  ush/includes/batch.inc(95): _drush_batch_command('29') #8 /var/www/html/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(131): drush_batch_command('29') #9 [internal function]: Drush\Command
  s\core\UpdateDBCommands->process('29', Array) #10 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array(Array, Array) #11 /var/www/html/vendor/conso
  lidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData)) #12 /var/www/h
  tml/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\Comm
  andData)) #13 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\Cons
  oleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData)) #14 /var/www/html/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execu
  te(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #15 /var/www/html/vendor/symfony/console/Application.php(1081): Symfony\Component\Console
  \Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) #16 /var/www/html/vendor/symfony/console/Application.php(320): Symfony
  \Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Consol
  eOutput)) #17 /var/www/html/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Conso
  le\Output\ConsoleOutput)) #18 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfo
  ny\Component\Console\Output\ConsoleOutput)) #19 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput
  )) #20 /var/www/html/vendor/drush/drush/drush.php(79): Drush\Runtime\Runtime->run(Array) #21 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...') #22 /var/www/html/vendor/bin/drus
  h(119): include('/var/www/html/v...') #23 {main}. {"exception":"[object] (TypeError(code: 0): array_intersect(): Argument #1 ($array) must be of type array, null given at /var/www/html/web/core/modul
  es/ckeditor5/src/Plugin/CKEditor5PluginManager.php:203)","severity_level":3} {"referer":"","ip":"127.0.0.1","request_uri":"https://kifinfo.ddev.site/","uid":0,"user":""}
  > TypeError: array_intersect(): Argument #1 ($array) must be of type array, null given in /var/www/html/web/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php on line 203 #0 /var/www/html/w
  eb/core/modules/ckeditor5/src/Plugin/CKEditor5PluginManager.php(203): array_intersect(NULL, Array)
  > #1 /var/www/html/web/core/modules/ckeditor5/src/SmartDefaultSettings.php(925): Drupal\ckeditor5\Plugin\CKEditor5PluginManager->getEnabledDefinitions(Object(Drupal\editor\Entity\Editor))
  > #2 /var/www/html/web/core/modules/ckeditor5/src/SmartDefaultSettings.php(242): Drupal\ckeditor5\SmartDefaultSettings->addDefaultSettingsForEnabledConfigurablePlugins(Object(Drupal\editor\Entity\Edi
  tor))
  > #3 /var/www/html/web/profiles/contrib/thunder/thunder.post_update.php(84): Drupal\ckeditor5\SmartDefaultSettings->computeSmartDefaultSettings(Object(Drupal\editor\Entity\Editor), Object(Drupal\filt
  er\Entity\FilterFormat))
  > #4 /var/www/html/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(288): thunder_post_update_0001_upgrade_to_thunder7(Array)
  > #5 /var/www/html/vendor/drush/drush/includes/batch.inc(256): Drush\Commands\core\UpdateDBCommands::updateDoOnePostUpdate('thunder_post_up...', Object(DrushBatchContext))
  > #6 /var/www/html/vendor/drush/drush/includes/batch.inc(201): _drush_batch_worker()
  > #7 /var/www/html/vendor/drush/drush/includes/batch.inc(95): _drush_batch_command('29')
  > #8 /var/www/html/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(131): drush_batch_command('29')
  > #9 [internal function]: Drush\Commands\core\UpdateDBCommands->process('29', Array)
  > #10 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array(Array, Array)
  > #11 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedComm
  and\CommandData))
  > #12 /var/www/html/vendor/consolidation/annotated-command/src/CommandProcessor.php(176): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\Annot
  atedCommand\CommandData))
  > #13 /var/www/html/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(391): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutpu
  t), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
  > #14 /var/www/html/vendor/symfony/console/Command/Command.php(326): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Compone
  nt\Console\Output\ConsoleOutput))
  > #15 /var/www/html/vendor/symfony/console/Application.php(1081): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Ou
  tput\ConsoleOutput))
  > #16 /var/www/html/vendor/symfony/console/Application.php(320): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\
  Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  > #17 /var/www/html/vendor/symfony/console/Application.php(174): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Outpu
  t\ConsoleOutput))
  > #18 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(124): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Out
  put\ConsoleOutput))
  > #19 /var/www/html/vendor/drush/drush/src/Runtime/Runtime.php(51): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
  > #20 /var/www/html/vendor/drush/drush/drush.php(79): Drush\Runtime\Runtime->run(Array)
  > #21 /var/www/html/vendor/drush/drush/drush(4): require('/var/www/html/v...')
  > #22 /var/www/html/vendor/bin/drush(119): include('/var/www/html/v...')
  > #23 {main}

Initially we thought it was because we already enabled CKeditor5 in Drupal 9, but we found out that in the update hook it tries to update every editor with the following code:

$format = $editor->getFilterFormat();
      [$updated_text_editor] = $ckEditorMigration->computeSmartDefaultSettings($editor, $format);
      $updated_text_editor->save();

Which will fail if the editor is not CKEditor, but for example TinyMCE or in our case Gutenberg.

Steps to reproduce

  • Install Thunder 6 with another editor also enabled, for example Gutenberg
  • Update to Thunder 7
  • The error will occur on updating the database (drush updb)

Proposed resolution

Our solution was to check if the editor is CKeditor before executing the code. I've created a patch for it already. Will add in the first comment.

πŸ› Bug report
Status

Needs review

Version

7.1

Component

Code

Created by

πŸ‡³πŸ‡±Netherlands interactivex

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

Comments & Activities

Production build 0.69.0 2024