The update does not work correctly with Commerce 2.16

Comments

zenimagine created an issue. See original summary.

jsacksick’s picture

"The update does not work correctly with Commerce 2.16" => which update?

zenimagine’s picture

@jsacksick The entity update as you can see in the screenshot. It is no longer possible to use drush to do this. How to correct errors ? Thank you

bojanz’s picture

Status: Active » Closed (cannot reproduce)

We don't know how this happened, so we can't be of much help.
You might need to use https://www.drupal.org/project/devel_entity_updates to fix it.

If you manage to find a concrete cause, and/or write a patch for it, please reopen the issue.

zenimagine’s picture

Status: Closed (cannot reproduce) » Active

@bojanz This happened right after updating to Commerce 2.16 and Commerce Marketplace.

With each update, I always have a problem.

bojanz’s picture

Status: Active » Closed (cannot reproduce)

I understand. And that problem is caused either by Marketplace or the way you update your site. We ourselves have no problem on dozens of sites we update.

So, please reopen the issue once you can provide a fix or pointers to a problematic part in code. There's nothing more we can do for you with the given information.

jsacksick’s picture

Status: Closed (cannot reproduce) » Needs review
StatusFileSize
new972 bytes

Well, I actually could reproduce this too, and this seems to be caused by this commit: https://git.drupalcode.org/project/commerce_pricelist/commit/79b1a90.

Unfortunately, we cannot just call the updateEntityType() method on the entity definition update manager (An EntityStorageException is thrown when trying to do that with the following message: "'It is not possible to change the entity type schema outside of a batch context. Use EntityDefinitionUpdateManagerInterface::updateFieldableEntityType() instead.'").

The attached patch fixes the issue for me locally though.

@zenimagine: Could you confirm if works on your side as well?

mglaman’s picture

I'm slightly considered about manually setting the installed schema instead of calling install/update fields or EntityDefinitionUpdateManagerInterface::updateFieldableEntityType() so specifically.

That method should be reentrant

zenimagine’s picture

Thanks, I tested the patch and it fixes the errors

jsacksick’s picture

Status: Needs review » Fixed

@zenimagine: Thank you for testing that, FYI, an other update hook was introduced already in dev for #3102979: Add a uid field to pricelist and price list items, if you ran "commerce_pricelist_update_8204", on your site then "commerce_pricelist_update_8203" isn't going to be executed and you'd be left without a "uid" field.

Committed.

  • jsacksick committed 39a0421 on 8.x-2.x
    Issue #3105383 by jsacksick: Fix the entity definition mismatch caused...
jsacksick’s picture

Status: Needs review » Fixed
zenimagine’s picture

@jsacksick On my production site, I have the RC1 version and I have not applied any patches.

What should I do to not break anything ? Thank you

zenimagine’s picture

@jsacksick The patch worked on my test site.

As you told me, I did not apply the patch and I updated my production site to the DEV version of the module. But that does not correct, I still have the errors in the dashboard.

ubuntu@www-example-com /var/www/www-example-com $ composer require 'drupal/commerce_pricelist:2.x-dev'
./composer.json has been updated
Gathering patches for root package.
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-feed is abandoned, you should avoid using it. Use laminas/laminas-feed instead.
Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
Generating autoload files
> DrupalProject\composer\ScriptHandler::createRequiredFiles
ubuntu@www-example-com /var/www/www-example-com $ drush updatedb
-------------------- ----------- --------------- -----------------------------
Module Update ID Type Description
-------------------- ----------- --------------- -----------------------------
commerce_pricelist 8202 hook_update_n Define event handlers for
price list and price list
items.
commerce_pricelist 8203 hook_update_n Add a 'uid' field to price
lists and price list items.

commerce_pricelist 8204 hook_update_n Fix the entity definition
mismatch caused by the
"data_table" key removal.
-------------------- ----------- --------------- -----------------------------

jsacksick’s picture

StatusFileSize
new844 bytes

@zenimagine: The attached patch should fix the issue.
However, I'm not 100% sure I should commit this since I already committed a fix to commerce_pricelist_update_8203() which means the issue shouldn't occur on sites that will upgrade to the next RC, on using the current dev version.

The issue should occur if you've updated to commerce price list dev, prior to this commit: https://git.drupalcode.org/project/commerce_pricelist/commit/cc861e98dbb...

Do you know if that's what you did?

zenimagine’s picture

@jsacksick Thanks, the patch works. I applied the patch with the DEV version, updated the database and removed the patch. So it's good, the RC5 won't be a problem?

Status: Fixed » Closed (fixed)

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