Problem/Motivation
Right now, pathauto pattern migration is a monolithic migration, and this can cause issues with the migrated pathauto pattern config entities:
even though patterns with bundle selection criteria depend on the corresponding entity bundle migrations, this isn't reflected in the migration dependencies. Right now, only d7_node_type
is defined as a dependency, but e.g. taxonomy term pattern migrations require d7_taxonomy_vocabulary
.
Proposed resolution
Derive pathauto pattern migrations per entity type (and bundle), and set the accurate migration dependencies (for known destination entity types) in the new deriver class.
Remaining tasks
I wasn't able to properly separate this issue from #3179835: Migrate forum pattern to taxonomy term forums if forum is enabled on the source site which prepares the required components for this issue. So for now:
- Let's see what happens at #3179835: Migrate forum pattern to taxonomy term forums if forum is enabled on the source site. If the patch I just posted can be merged, this issue will be unblocked.
- Patch + test update.
User interface changes
Nothing.
API changes
Nothing.
Data model changes
Accurate migration dependencies for pathauto pattern migrations.
Comment | File | Size | Author |
---|---|---|---|
#25 | interdiff-3179865-24-25.txt | 28.42 KB | huzooka |
#25 | pathauto-derive_pathauto_migrations_per_entity_type-3179865-25.patch | 40.09 KB | huzooka |
Comments
Comment #2
huzookaComment #3
huzookaComment #4
huzookaComment #5
huzookaComment #6
huzookaRebased on #3179835-9: Migrate forum pattern to taxonomy term forums if forum is enabled on the source site.
Comment #7
Wim Leers🤔 So when no *_default as a derivative ID. Sounds reasonable!
OTOH … why even rename it in this case? Why not keep the original plugin ID? Isn't there only ever going to be one?
Let's add
default:
and add explicit logging?That way the person doing the migration would be warned about missing dependencies (for bundle definitions for entity types whose bundle creation migration is not known). It could even check
\Drupal\Core\Entity\EntityTypeInterface::getBundleEntityType()
to not show this message when bundles are not configurable but hardcoded.I don't think this comment matches the query? 😅
🤔 What does this mean? You're OR'ing with the default condition I think?
🤔 What is a "source variable ID"?
🤯 Woah! How? Can you include an example in this comment? 🙏
When/how could this happen? Including an example here might be valuable 🙏
Why do these two happen in this order?
🤓 s/with/to/
Comment #8
huzookaComment #9
huzookaRe #7 (it is the review of #5, and not the most-recent path posted at #6):
d7_pathauto_pattern:node
andd7_pathauto_pattern:node:article
because in this case the plugin manager cannot decide whatd7_pathauto_pattern:node
refers to: it is also the ID of the fallback pattern and also the partial ID of the bundle-specific pattern migration derivatives (d7_pathauto_pattern:node:<whatever>
).node
andtaxonomy_term
.TodoFixed in #10.Todo (it needs additional comments)Fixed in #10.TodoFixed in #10.Comment #10
huzookaThis patch addressed the remaining points of the review posted in #7.
Comment #11
Wim Leers#9
Defensive programming FTW 😊
#9.8: it just looks odd to me to first import
:foo
and then:foo_default
. It's still not entirely clear to me what the difference is.Review
s/has also be/must also be/
s/every pattern variables/every pattern variable/
Comment #12
Wim LeersRE #9.8: @huzooka clarified that
d7_pathauto_patterns:taxonomy_term
results in all bundle-specific derivatives getting executed, so for example:d7_pathauto_patterns:taxonomy_term:tags
d7_pathauto_patterns:taxonomy_term:sujet_de_discussion
And only after those
d7_pathauto_patterns:taxonomy_term_default
gets migrated. This is the fallback pattern. So … it totally makes sense 👍Comment #13
huzookaThis should address every issue raised in #11.
Comment #14
Wim LeersRTBC once the blocker lands 🚢
Comment #15
Wim LeersI'm tempted to mark this a bug instead of a feature request — the issue summary describes pretty clearly why this is a bug.
Comment #16
Wim LeersProblem
When the source site has installed
file_entity
, they'll also have bundles for thefile
entity type.On a particular site I am testing against, I'm seeing the following Pathauto patterns in the
variable
table:pathauto_file_audio_pattern
pathauto_file_document_pattern
pathauto_file_image_pattern
pathauto_file_pattern
pathauto_file_video_pattern
which results in this error:
Proposals
1️⃣ First, to make this easier to debug, this should at the very least be throwing a more helpful exception, like so:
2️⃣ Second, it should not crash, but instead it should just continue without adding dependencies.
3️⃣ Third, let's add explicit support for file entities?
Comment #17
huzookaWell, Pathauto Entity module is the thing which makes it possible to have pathauto pattern(s) for file entities (and any kind of (custom) entities – and even for comments).
Comment #18
huzookaI try to address #16 Proposal 3️⃣.
Comment #19
Wim LeersManually tested #18. I can confirm it works.
Review
Isn't this returning too early? Doesn't this mean that the new
file
andcomment
cases you added later in this file will never get executed?Comment #20
huzookaRe #19: Those patterns work only if you have Pathauto Entity installed on the source site. So I think it isn't a too-early-return.
Comment #21
huzooka#20 isn't totally correct.
Comment #22
huzookaThis patch addresses the concern raised by #19.
Summary:
D7 File Entity provides support for file pathauto pattern. This means that file entities may have a bundle-agnostic (aka default) pattern.
D7 Pathauto Entity goes a bit further and it also supports per-bundle file patterns (while a default pattern can be still functional and behave as a fallback).
Comment #23
huzookaThe patch #22 is wrong.
I've added a
continue
inside the switch statement (see the interdiff) – and inside a switch, it is equivalent to abreak
. I should usecontinue 2
instead.Comment #24
huzookaThis patch addresses #23.
Comment #25
huzookaThe source plugin should support returning only the default patterns (eg.
pathauto_node_pattern
).This patch:
bundle
config asFALSE
, then the source plugin returns the default pattern of the givenentity_type
.Postponing on #3179835: Migrate forum pattern to taxonomy term forums if forum is enabled on the source site.
Comment #26
Wim LeersLooks good 👍
🤓 Nit.
So this means we assign different meanings to
bundle === NULL
(the default value, pre-existing) andbundle === FALSE
(introduced here).We should document that in
\Drupal\pathauto\Plugin\migrate\source\PathautoPattern::__construct()
IMHO, or better yet, in the class-level docblock.Comment #27
DamienMcKennaCould someone please clarify this part:
That class method doesn't exist and this change causes the tests to fail with the error "Illegal string offset 'default'".
Comment #28
DamienMcKennaCorrection, it fails on this bit:
$connection_info[$target]['prefix'] is a string, not an array.
This change lets the tests pass:
Comment #29
DamienMcKennaLooking at it again I spotted this:
#2552791 was closed as a duplicate of #2681869 which was committed in 2016. Does this mean that other changes are needed in core, or that the code needs to be refactored to account for core changes from 2016? The comment isn't clear.
Comment #30
DamienMcKennaPutting this back to "needs work" due to my findings above.