Problem/Motivation
As pointed out by Upchuk in comment https://www.drupal.org/project/commerce_shipping/issues/3248745#comment-...
the system reports Mismatched entity and/or field definitions after https://www.drupal.org/node/3248745 has been committed.
(I cannot re-open #3248745: Add "created" and "changed" timestamps to shipping method entities hence this new issue.)
Steps to reproduce
- Have a system on 8.x-2.2 with commerce_shipping_method entities
- Have content translation enabled on shipping methods
- Upgrade to commerce_shipping 8.x-2.3
- Check the status page at admin/reports/status
Proposed resolution
A simple way to fix this is removal of the now obsolete field storage definitions.
NB: There is no data migration to the new fields. Since 8.x-2.3 has already been released the data in the old fields are no longer maintained anyway though.
Data model changes
Removal of "content_translation_created" and "content_translation_changed" field storage definitions. The field definitions are already gone due to the core not adding them if created and changed are present.
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | interdiff_11-12.txt | 289 bytes | narendra.rajwar27 |
| #12 | 3263586-12.patch | 891 bytes | narendra.rajwar27 |
| #11 | 3263586-11.patch | 919 bytes | alexdoma |
| #2 | 3263586-remove-stale-field-storage-definitions.patch | 1.46 KB | cspitzlay |
Comments
Comment #2
cspitzlayComment #3
upchuk commentedHey there, i had already created this followup https://www.drupal.org/project/commerce_shipping/issues/3262879 but forgot to mention in that other issue. I will close mine.
Comment #4
upchuk commentedI'm not sure this is a correct approach because it will remove data accumulated from before adding the created/changed fields. It should be copied over at least IMO because this will leave it will empty created/changed values where before we used to have translation created/changed values.
Comment #5
mkalkbrennerIn my opinion this is a bug in core. If content_translation adds fields it it also responsible for removing the fields if the condition for their existence no longer exists.
Anyway, copying the old values is dangerous. You should not do it in an update hook, but in a post update. But what happens if you save the shipping method (and all its translations.) Won't that modify the changed date immediately?
Does it trigger any APIs and potentially custom code you don't wont to have executed?
And content translation created doesn't exactly mean the same as entity created if content translation has been installed later.
What about revisions?
I think that simply deleting the fields is the only reliable patch to not open more bugs and to avoid unexpected side effects.
Having "wrong" dates after the deletion might be the least serious issue. Especially if you consider that this has never been a feature of this module itself.
Comment #6
calbasiYour patch #2 not running in my side:
Comment #7
c_archer commentedI've seen the same issue, I had raised a new ticket (https://www.drupal.org/project/commerce_shipping/issues/3308423) but closed as it appears to be similar if not the same as this one.
Comment #8
alexdoma commentedupdate a patch
Comment #9
alexdoma commentedComment #10
alexdoma commentedadd correct patch
Comment #11
alexdoma commentedThis patch generated by linux. Previous patch generated by Windows(powershell) not applied. reason - encoding
Comment #12
narendra.rajwar27Adding patch. by fixing CS issue.
Comment #13
c_archer commentedThe patch in #11 resolved the issue for me.
Comment #15
jsacksick commentedCommitted, thanks everyone!