Closed (fixed)
Project:
Insert
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Issue tags:
Reporter:
Created:
15 Feb 2022 at 11:18 UTC
Updated:
17 Mar 2023 at 07:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
srishtiiee commentedComment #3
huzookaSince the module is in a beta phase, we cannot remove the migrate plugins; but since they also contains bugs, I will include them in this review.
Preexisting plugins:
PerComponentEntityFormDisplayInsertdestination plugin:I see two issues here:
FieldInstanceWidgetInsertSettingsprocess plugin might return with an empty array as well, theinsertkey in$thirdPartySettingsmight be completely missing. This means thatcount($thirdPartySettings['insert'])will throw an error.Solution: instead of getting the value of
'options/third_party_settings', we should read the'options/third_party_settings/insert'destination property. If it is NULL, then we don't have to save anything.EntityDisplayInterface::getComponent()will return withNULL. This also triggers an error.Solution: if
$entity->getComponent($values['field_name']);returns with NULL, then the field is hidden, so we can't (and shouldn't) save the third party settings.The best (compatible) solution is for #1 is instead of getting the value of
'options/third_party_settings', we should read the'options/third_party_settings/insert'destination property. If it is NULL, then we don't have to save anything.FieldInstanceWidgetInsertSettingsprocess plugin:autoto Drupal 9insert__auto, and isn't aware of that theinsert_defaultmight also contain animage_prefixed image style ID.Suggested solution: add a helper function which does the key mapping, and use it in the foreach loop and also for the default style:
insert_stylearray, so we might try to process0values instead of the actual keys likelink,imageetc.Solution: process the array keys instead, and use that as the key value as well if the value is not empty
Review of patch in #2:
The row prepare hook produces different Insert third party settings than the preexisting migration + the preexisting process and destination plugins: it doesn't removes the
image_prefix from the image style specific insert styles, it uses a wrong keystyleinstead ofstyles, and it migrates these style mapping even when it shouldn't do so (for thefield_cmnt_imageandfield_filefield formatters in thegallerynode type's default form).I suggest starting over:
d7_field_instance_widget_insert_settingsmigration, and change your assertions according the actual results.d7_field_instance_widget_insert_settingsfrom your migration test, and return to the migrate prepare row hook implementation. You should produce the same results what you had in point 3.Later on we also have to create an update hook for being able to remove the migration yaml file (without a BC break), but for first, let's focus on these!
I'm uploading a "dummy" schema yaml patch (hoping that it will help not just your work, but also the maintainer).
Comment #4
srishtiiee commentedTODO: create an update hook as mentioned in #3.
Comment #5
huzookaWe don't need these restrictions.
We don't need this query: you try to get data what is already available in the current row.
Default style also should be mapped.
field_fileorfield_cmnt_image, and actually, you're right, and the preexisting migrate process plugin still has a bug:That
!isset($widget_settings['insert'])should be replaced withempty($widget_settings['insert']). Why? Because if this settings does not exist, or it is set to0, the insert button wasn't shown on the source site.Comment #6
srishtiiee commentedComment #7
huzooka@srishti.bankar, great work 🥳! Imho #6 is functionally perfect, I only have some very-very little nits:
Nit: indentation error.
Nit: it would be better to rename this make it clear that it is a migration utility. I would add
Migrate(either as prefix, or as a suffix). I also miss the class/method comments.It would be better to check whether
$settings['insert]is empty. Because you should returnNULLeven if it is'0'.If you do so, then you can remove the condition in the next line, and just process the widget settings you have.
Nit: could you please remove this todo comment?
Nit: could you replace this
$this->assertNoMigrationMessages();with a non-custom assertion? I know this just checks whether no migration messages were logged during the test, and those messages are stored in the protected$migrationMessagesproperty, so$this->assertEmpty($this->migrateMessages);would be fine.I think I also have a plan how to deprecate the preexisting migration. If the nits above are addressed, I will implement it.
Comment #8
srishtiiee commentedAddressed the nits.
Comment #9
huzooka#8 addresses all of my concerns.
Let's deprecate the standalone migration!
Comment #10
huzookaComment #11
huzookaComment #12
huzookaComment #13
huzookaWe still need a change record, but for now, let's try to get an approval from the maintainers!
Comment #14
huzookaComment #15
huzookaComment #16
huzookaComment #17
huzookaComment #18
snater commentedExcuse me for not checking sooner, I have not been around for a while. I can see you have spent a lot of time on making a proper patch! That's great, very appreciated! I have looked at the code and would certainly be fine merging it. While I do not have time to test it properly, I can see you have been working on it together which I guess qualifies for reviewed and tested by the community.
I'm sorry I don't manage finding sufficient time to properly maintain the project as of now. If there is something left to do on the change, feel free to add. In any case, I'd be super ok merging. I have seen the notes on deprecating migrations to be removed in a future beta version 3.0. I'm just not 100% sure which code is to be removed then, in addition to deleting
PerComponentEntityFormDisplayInsertandFieldInstanceWidgetInsertSettings. I guess I would then also remove dealing withinsert_migration_plugins_alterininsert_migration_plugins_alterand removeMigrateInsertWidgetSettings::standaloneMigrationIsOmittableas well asd7_field_instance_widget_insert_settings.ymlalong?Just a tiny thing my IDE was complaining when looking at the code:
in
MigrateInsertWidgetSettingswould be missing the parameter's type declaration:I'll just add that before merging in, if there is nothing else left.
Sorry again for not being around for a long time.
Comment #20
snater commented