Problem/Motivation

We have to make sure that the dropzonejs_eb_widget_update_8201 update hook runs after media_entity_update_8201

Proposed resolution

Implement hook_update_dependencies

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chr.fritsch created an issue. See original summary.

chr.fritsch’s picture

Status: Active » Needs review
FileSize
1.78 KB

After discussion with @mtodor, we decided to move the changes from object level to config level. Then we don't need to introduce a hook_update_dependencies

chr.fritsch’s picture

Status: Needs review » Fixed

Pushed to 8.x-2.x

KevinVanRansbeeck’s picture

Are you sure it's fixed on 2.x-dev?
When I used alpha1 with this patch - errors were gone.

Now I removed the patch and use 2.x-dev:

/Volumes/webdev/www/project/web(master*) » drush updb                                                                                                          
The following updates are pending:

dropzonejs_eb_widget module : 
  8202 -   Update configurations for new keys. 

Do you wish to run all pending updates? (y/n): y
The "media_type" entity type does not exist.                                                                                                                                          [error]
Performing dropzonejs_eb_widget_update_8202                                                                                                                                   [ok]
Failed: The "media_type" entity type does not exist.           

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Stephen Rockwell’s picture

I'm having the same issue with alpha2

chr.fritsch’s picture

Status: Closed (fixed) » Needs work
woprrr’s picture

Status: Needs work » Needs review

I have another errors during Upgrade path tests for media suite #2915738: Increase reliability of upgrade path to Media in core fixture.

A fatal error during dropzonejs_eb_widget_update_8201()

[error]  Error: Call to a member function getConfigDependencyKey() on null in Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\MediaEntityDropzoneJsEbWidget->calculateDependencies() (line 153 of /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/modules/contrib/dropzonejs/modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php) #0 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/core/lib/Drupal/Core/Plugin/PluginDependencyTrait.php(47): Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\MediaEntityDropzoneJsEbWidget->calculateDependencies()
#1 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(388): Drupal\Core\Config\Entity\ConfigEntityBase->calculatePluginDependencies(Object(Drupal\dropzonejs_eb_widget\Plugin\EntityBrowser\Widget\MediaEntityDropzoneJsEbWidget))
#2 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(346): Drupal\Core\Config\Entity\ConfigEntityBase->calculateDependencies()
#3 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/modules/contrib/entity_browser/src/Entity/EntityBrowser.php(400): Drupal\Core\Config\Entity\ConfigEntityBase->preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))
#4 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(434): Drupal\entity_browser\Entity\EntityBrowser->preSave(Object(Drupal\Core\Config\Entity\ConfigEntityStorage))
#5 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(389): Drupal\Core\Entity\EntityStorageBase->doPreSave(Object(Drupal\entity_browser\Entity\EntityBrowser))
#6 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(259): Drupal\Core\Entity\EntityStorageBase->save(Object(Drupal\entity_browser\Entity\EntityBrowser))
#7 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/core/lib/Drupal/Core/Entity/Entity.php(377): Drupal\Core\Config\Entity\ConfigEntityStorage->save(Object(Drupal\entity_browser\Entity\EntityBrowser))
#8 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(637): Drupal\Core\Entity\Entity->save()
#9 /Users/woprrr/Sites/Sandbox/WoprrrLabs/web/modules/contrib/dropzonejs/modules/eb_widget/dropzonejs_eb_widget.install(85): Drupal\Core\Config\Entity\ConfigEntityBase->save()
#10 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/src/Commands/core/UpdateDBCommands.php(152): dropzonejs_eb_widget_update_8202(Array)
#11 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/includes/batch.inc(232): Drush\Commands\core\UpdateDBCommands->updateDoOne('dropzonejs_eb_w...', 8202, Array, Object(DrushBatchContext))
#12 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/includes/batch.inc(180): _drush_batch_worker()
#13 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/includes/batch.inc(95): _drush_batch_command('4')
#14 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/src/Drupal/Commands/core/BatchCommands.php(21): drush_batch_command('4')
#15 [internal function]: Drush\Drupal\Commands\core\BatchCommands->process('4', Array)
#16 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/consolidation/annotated-command/src/CommandProcessor.php(235): call_user_func_array(Array, Array)
#17 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/consolidation/annotated-command/src/CommandProcessor.php(181): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#18 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/consolidation/annotated-command/src/CommandProcessor.php(147): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#19 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(404): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#20 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/symfony/console/Command/Command.php(264): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/symfony/console/Application.php(859): Symfony\Component\Console\Command\Command->run(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/symfony/console/Application.php(206): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#23 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/symfony/console/Application.php(125): Symfony\Component\Console\Application->doRun(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#24 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/src/Runtime/Runtime.php(111): Symfony\Component\Console\Application->run(Object(Drush\Symfony\LessStrictArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#25 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/src/Runtime/Runtime.php(42): Drush\Runtime\Runtime->doRun(Array)
#26 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/drush.php(64): Drush\Runtime\Runtime->run(Array)
#27 /Users/woprrr/Sites/Sandbox/WoprrrLabs/vendor/drush/drush/drush(4): require('/Users/woprrr/S...')
#28 {main}.

The following patch does fixe this issue.

Are you sure it's fixed on 2.x-dev?
When I used alpha1 with this patch - errors were gone.

Now I removed the patch and use 2.x-dev:

Have you upgrade and used Media in core before updb ? I can't reproduce this error in my upgrade tests .

woprrr’s picture

FileSize
1.02 KB

So sorry ... forget to attach patch O_O

Berdir’s picture

Problem with that approach that it's just hiding a deeper problem. You seem to have broken configuration, to a media type that doesn't exist anymore, or maybe the update didn't run to update the configuration key, so your browser will be broken.

instead of silently doing nothing, you could throw a useful exception, like dependency on non-existing media type X in entity browser Y so you see what/where the problem is.

woprrr’s picture

Status: Needs review » Needs work
+++ b/modules/eb_widget/src/Plugin/EntityBrowser/Widget/MediaEntityDropzoneJsEbWidget.php
@@ -147,9 +147,11 @@ class MediaEntityDropzoneJsEbWidget extends DropzoneJsEbWidget {
+    if ($media_type = $this->getType()) {
+      $media_type = $this->getType();

wrong duplicate $media_type

Problem with that approach that it's just hiding a deeper problem. You seem to have broken configuration, to a media type that doesn't exist anymore, or maybe the update didn't run to update the configuration key, so your browser will be broken.

instead of silently doing nothing, you could throw a useful exception, like dependency on non-existing media type X in entity browser Y so you see what/where the problem is.

Yes, That's happen after update of media suite 8.3.7 => 8.4.2 the 2.x branch of eb_widget are only based on media_type provided by core media. In my case I'm just before upgrade with media_entity 2.x. This is more a miss configuration / miss during upgrade path than a real problem. In all cases using $media_type directly withou any test seem's to be dangerous. To your suggestion about exeception to prevent this kind of miss can we test the version of media_entity (2.x are mandatory at this point) installed AND/OR if media (core) is installed if Yes, NULL isn't normal but if on of thoses conditions are not respected we can throw an exception to explain we try to use eb_widget designed for media in core with a media_entity.

chr.fritsch’s picture

What about implementing hook_update_dependencies to ensure the media_entity upgrade path is already finished?

chr.fritsch’s picture

Status: Needs work » Needs review
FileSize
768 bytes

Like this

slashrsm’s picture

Status: Needs review » Fixed

Works fine. Committed.

Also set up the Jenkis job to push from GitHub to drupal.org. Commiters make sure that you push to GH from now on.

rwam’s picture

One question: should the last patch be more specific? The patch doesn't make sense in my eyes resp. it prevented updating if you haven't media_entity installed. I work with media from core only and update 8202 is pending now because of the patch. I removed the dependency and the update was performed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

miax’s picture

FileSize
694 bytes

I'm experiencing the same problem as rwam (#17) is experiencing. We do not use the media_entity module and because of this the update won't apply. Added a patch that checks if media_entity module is installed before using the dependency. This fixes the issue for us and the update is applied correctly.

Berdir’s picture

Please open a new issue for that, this won't be visible enough/get committed here.

miax’s picture

Thanks for letting me know.
I added a comment and patch to this active issue instead: update 8202 will not apply, causing Drupal to think there is always an update pending