Closed (fixed)
Project:
Focal Point
Version:
2.x-dev
Component:
Other Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Mar 2022 at 13:21 UTC
Updated:
20 May 2024 at 03:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
yash.rode commentedFocal point migration.
Comment #3
narendrarI am not able to apply patch. Getting below error:
Comment #4
yash.rode commentedComment #5
yash.rode commentedComment #6
narendrarBy doing initial review of module it seems that more work needs to be done in patch.
Basically focal_point is applied based on settings at
/admin/config/media/focal_point. So:Standard image fieldsis checkedMedia module image fieldsis checkedComment #7
yash.rode commentedfollow up for #6.
Comment #8
narendrarI am not able to open patch in Dreditor may be because of size. Why there is so much patch size difference between #4 and #7? Size seems suspicious to me.
Also migration shouldn't be executed if focal_point is not enabled on the source site.
focal_point_migration.yml:dependencies should be replaced with migration_dependencies.MigrationSubscriber.php:Check this condition by enabling only media and doing the migration and then observe for image field.FocalPointMigrationTest.php: protected static $configSchemaCheckerExclusions = ['field.field.node.article.field_media'];Add inheritdoc
Comment #9
yash.rode commentedFollow up for #8
Comment #10
yash.rode commentedadded smart_sql_idmap as external module.
Comment #11
yash.rode commentedComment #12
narendrarMigration looks good to me. Some nits:
Extra line.
This variable will not be available if module is just enabled and configuration form is not saved. See https://git.drupalcode.org/project/focal_point/-/blob/7.x-1.x/focal_poin.... This needs to be handled here.
crop_field_Data => crop_field_data
Seems unnecessary to me.
Not necessary.
Comment #13
yash.rode commentedFolllow up for #12
Comment #14
yash.rode commentedpatch with --binary.
Comment #15
narendrarLooks good to me.
Comment #16
huzookaThe two files used in #14's migration test are about 500kB.
I'm adding a lot smaller patch which is the same as #14 except of these fixture files, but here they consume only ~5.1kB space.
Comment #17
huzookaThe 'migration' suffix is redundant both in the ID and in the label. Just name it
focal_point_crop.Since this plugin inspects a destination file, we should pass the destination fid to it, and not the source source fid.
If you restructure the order of the destination properties here, then you might use the computed
@entity_idvalue (if its process will be changed to migration_lookup).Nit: imho the
_fieldsuffix in the plugin ID is irrelevant.This value is exactly the same what we pass to the
focal_point_to_crop_fieldas the first source property: so it can be simplified toentity_id: fid.But why don't we use a migration lookup instead?
This is always
file, so it is unnecessary to use a migrate process plugin for providing this value.Please specify a constant in the source plugin's configuration, and use that instead!
Would be nice to describe what this event subscriber does.
Changes field widget to focal point for image media entities when needed.
I also miss parameter comment and the return type (this should be fixed for every other custom method).
It would be nice to leave a comment here about that this is an optional support for Media Migration module.
The
focal_point_enabled_forvariable isn't available if it wasn't ever saved on the source, but its default value is['image', 'media']:https://git.drupalcode.org/search?search=focal_point_enabled_for&group_i...
You have to restructure this method, and also change the
!empty()checks toin_array().You should use dependency injection.
Instead of using
getimagesize(), I would use core'sImageFactoryto sonstruct an image object, and then get the image with and height by calling$image->getWidth()....and then:
Instead of using the values from the destination site, it would be better to create migrations for the focal_point crop type and even for
focal_point.settings.These should (and can) be done in the migration yaml.
I don't see any reason why we perform our tests with focal point being disabled for image fields.
This isn't necessary at all.
Please remove the empty line between the docblock and the property declaration.
There are no items there which would display a migration message.
You can merge these migrations into the first
MigrateTestBase::executeMigrations()method call.These assertions should be replaced with something which uses Crop API:
Comment #18
yash.rode commentedfollow up for #17.
Comment #19
huzookaRe #18:
Imho everything is addressed except #17.6, #17.7 and #17.8.
If you return nothing, then the
in_array()checks above will fail.Pleas clarify what the return type should be here, and update your code accordingly.
You don't need to check whether
$focal_point_enabled_foris empty or not: You can use these default values in the conditional value assignment above.And on the other hand, StatementInterface::fetchField() might return with
FALSE(when this variable wasn't saved), and unserializing a booleanFALSEmakes no sense.Just do what
DrupalSqlBase::variableGet()does.Comment #20
yash.rode commentedFollow up for #19.
Comment #21
yash.rode commentedpatch with --binary.
Comment #22
huzookaI'm still missing the parameter documentation from the event subscriber's methods:
Comment #23
yash.rode commentedAdded parameter documentation for custom methods.
Comment #24
yash.rode commentedAdded parameter documentation for custom methods.
Comment #25
huzookaThe patch in #24 addresses every concern we raised.
Definitely RTBC!
@yash.rode, many thanks for your work!
Comment #26
fmb commentedI was able to use your patch to migrate data from D7. Thanks a lot!
Comment #27
yash.rode commentedmaking the patch binary.
Comment #28
yash.rode commentedpatch name changed.
Comment #29
huzookaRestoring RTBC status for #28, which patch can be applied with
cweagans/composer-patches.Comment #30
very_random_man commentedHi. I've noticed that this patch is actually causing an error if you have focal_point module installed without the migrate module. It looks like it ought to check if the module is enabled perhaps in the event subscriber.
Comment #31
karlsheaThe focal_point_crop migration should have a Content tag instead of Configuration, since it relies on files having been imported.
I might have fixed the MigrateEvents not defined error but I don't know if it's the right way to do that or have even tested it.
Comment #32
very_random_man commentedCan confirm that patch works. Thanks!
Comment #33
wim leersConfirmed again by @vistree at #3393712-3: Update: focal_point migration patch in #3267350 (to prevent error in some scenarios) 👍
Comment #34
ovilla commentedThanks for the patch, I was trying to use the one in comment #31, but in my case I had a problem, because in my source site an image file is missing, then the migration was suddenly interrupted in the middle of the "focal_point_crop" migration, I received the following message:
In case someone has the same problem, I attach a fix for skipping rows where no image file is found.
Comment #35
leducdubleuet commentedThis is great, I can confirm the patch in comment #34 is working perfectly with the current release without any error and it migrates the focal points with success from Drupal 7!
It would be great to have it committed in a new release!
Thanks to all who worked on this patch!
Comment #37
rajeshreeputraCan we get the MR for ease of merge, Will merge and release this weekend. Thank you everyone working on this.
Comment #39
karlsheaMR created from patch in #34
Comment #41
rajeshreeputraMerged, release to follow shortly.