Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm not sure why I never saw an issue for this in the Pathauto issue queue as I would have likely accepted it. It should be fairly trivial to move the transfer the migration integration from here to Pathauto.
Comment | File | Size | Author |
---|---|---|---|
#26 | pathauto-migrate-1128870-25.patch | 1.94 KB | mikeryan |
#21 | pathauto-migrate-1128870-20.patch | 1.95 KB | badrange |
#16 | pathauto-migrate-1128870-16.patch | 1.96 KB | mikeryan |
#13 | pathauto-migrate-1128870-13.patch | 1.59 KB | mikeryan |
#12 | 1128870.patch | 1.62 KB | EclipseGc |
Comments
Comment #1
mikeryanYeah, we didn't get the final release of Migrate 2.0 out until DrupalCon, and I haven't really had time to pursue getting support into contrib modules. Should be simple - copy pathauto.inc to pathauto.migrate.inc, reference it in the pathauto.info, add hook_migrate_api() - I can submit a patch to the pathauto queue if you'd like.
Comment #2
mikeryanOK Dave, here it is (for D7).
Comment #4
mikeryanAnd for D6.
Comment #5
mikeryanRerolled as a submodule, with examples and tests.
Comment #6
mikeryanAnd for D6.
Comment #7
Dave ReidDoes migrate.module define hook_migrate_api() in migrate_hook_info() so that the function can be moved to the pathauto.migrate.inc file?
Comment #8
mikeryanNo, but I think putting the migration support into a separate module addresses this (no migrate overhead in pathauto itself).
Comment #9
Dave ReidI don't really see why there is any overhead when it's in the module as well. If anything something like this seems overkill for a separate module.
Comment #10
mikeryanYes, I may have gone overboard in the pathauto case, but I'm trying to establish a new design pattern for migration integration (see #1180612: Support for migration for a case with slightly more substantial examples and tests), and thus applying it consistently. If you prefer, I can define migrate_hook_info() (probably a good idea anyway) and reroll the original patch accordingly.
Comment #11
mikeryan#1181826: Define migrate_hook_info()
Comment #12
EclipseGc CreditAttribution: EclipseGc commentedThis has gone a long time without getting in. I simplified the whole thing and just put it straight into pathauto. I didn't attempt to port the tests since they appeared to need another one of the submodules, but I had an active use for this patch and it completely worked as advertised.
Comment #13
mikeryanUpdated with latest code from migrate_extras, and moved hook_migrate_api to the migrate.inc file.
Comment #14
Dave ReidThis is super close, but I think that this needs to add files[] = pathauto.migrate.inc to pathauto.info in order to have the class available?
Comment #15
mikeryanNot only that, but to work with Migrate 2.5 or later the handler needs to be registered in hook_migrate_api(). I'll reroll...
Comment #16
mikeryanComment #17
Dave Reid@mikeryan: Sort-of unrelated question, do I need to add 'destination handlers' for Field handlers that extend MigrateSimpleFieldHandler?
Comment #18
mikeryan'field handlers', actually.
Comment #19
rroblik CreditAttribution: rroblik commentedCan we expect this patch
Migrate 2.5+ api
to be ported ?Integrate it into pathauto is the best practice :)
Comment #20
badrange CreditAttribution: badrange commentedI tried the patch, and I am a bit confused. It doesn't seem to *DO* anything,
It has a prepare function:
but the row, which contains "the $row argument is an object containing the data after prepareRow() and any callbacks have been applied." according to Migrate module "Commonly implemented Migration methods") in the migrate module's docs, is not used.
When I try to run a migrate update on a node (after applying this patch), nothing changes on the node I have already imported. But I have verified with the debugger that the code is indeed executed.
Comment #21
badrange CreditAttribution: badrange commentedAttaching a patch (made against 7.x-1.2)
Comment #22
badrange CreditAttribution: badrange commentedComment #23
Dave ReidI feel like we should register the same types as MigratePathEntityHandler does, which is
$this->registerTypes(array('entity'));
instead of just node, taxonomy_term, and user.If I'm ready to commit this, do we need to consider/prevent any errors if the user has an competing pathauto migrate handlers (older version of Migrate Extras and a newer version of Pathauto enabled)?
Comment #24
mikeryan$row is a representation of the source data, and in a general-purpose destination handler we cannot make any assumptions about the form of the source data. This will work for a Drupal-to-Drupal migration, but not for migrations from other systems. It's up to the migration to map the appropriate source field to 'path', and here we would use that as $entity->path.
Migrate supports disabling handlers by name - this is done through the UI at admin/content/migrate/configure, and the variable migrate_disable_handlers lists handlers that should be ignored. So, I would suggest an update function disabling migrate_extra's handler along the lines of:
I'll roll a new patch...
Comment #25
mikeryanOK, this is the patch from #16 with two changes:
I've tested both with and without migrate_extras enabled and it works fine in both situations - with 'pathauto' mapped to 0 in the migration, alias generation is disabled during migration and the value mapped to 'path' gets used. There'll be a tiny performance hit from the redundant handler, but I think it's fine since this will be one of the (big) nails in the coffin of migrate_extras as a whole, not worth introducing the update function. Dave, if you would like to disable the migrate_extras handler let me know and I'll add the update function.
Comment #26
mikeryanUmm, helps to actually attach the patch...
Comment #27
roberttstephens CreditAttribution: roberttstephens commentedIs it actually necessary to include pathauto.migrate.inc in pathauto.info? It looks like it's unnecessary, since the migrate module uses hook_hook_info().
Comment #28
mikeryanhook_hook_info() allows for the autoloading of the .inc file for calling hook_migrate_api(), but adding the file to .info allows for autoloading of the destination handler class. Now, I think normally you should always have the hook called before any use of the class, but I feel better to be sure that the class is in Drupal's code registry and always available.
Comment #29
DamienMcKennaComment #31
mikeryanBump... If there are any watchers here (besides badrange and EclipseGc, who contributed iterations of the patch) who can test and move this to RTBC, that would be great.
Comment #32
hargobindThe patch in #26 applies cleanly against pathauto 1.2. It removes the warning ["pathauto" was used as destination field in "" mapping but is not in list of destination fields] when viewing the Migration UI registration, and it solves an issue I was seeing where aliases were being duplicated for each node that was imported.
Thanks!
Comment #33
Dave ReidComment #34
hargobindForgot to change the status after my testing.
Comment #35
drurian CreditAttribution: drurian commentedWorks well, please commit.
Comment #36
dillix CreditAttribution: dillix commentedPlease commit this!
Comment #38
dillix CreditAttribution: dillix commentedDave, patch in #26 goes green, can you commit it?
Comment #39
Dave ReidComitted #26 to 7.x-1.x. Thanks everyone!