Problem
Promoter_Taxonomy::find_or_create_promoter( \$name, \$data ) in Extra-Chill/data-machine-events is a near-duplicate of DM core's ResolveTermAbility::resolve( \$identifier, \$taxonomy, \$create = true ). Both:
- Match a flat taxonomy term by name/slug.
- Create the term if not found.
- Return the term ID + a "was created" signal.
The only non-core delta in find_or_create_promoter is the metadata smart-merge on hit. That belongs post-resolution in a second step — not inside the resolver.
Proposal
Refactor find_or_create_promoter to:
- Call
\\DataMachine\\Core\\Abilities\\Taxonomy\\ResolveTermAbility::resolve( \$name, 'promoter', create: true ).
- If the call returned
success + term_id, apply smart_merge_promoter_meta() to the returned term ID.
- Return the same
{ term_id, was_created } shape to preserve the public signature.
Net: find_or_create_promoter goes from ~60 lines to ~20. Zero behaviour change for callers.
Not-in-scope
Venue_Taxonomy::find_or_create_venue is NOT a candidate for the same collapse — it adds domain-specific fuzzy matching (address-based match, "The" prefix toggle, normalised-name match) that doesn't generalise cleanly. Keep it as-is.
When to build
Low priority — pure cleanup, no user-facing change. File now so the duplication is tracked. Land alongside any future change to Promoter_Taxonomy.
References
- Automattic/intelligence#147 — the wiki refactor that led me to audit find-or-create patterns across the DM ecosystem.
- DM core
inc/Abilities/Taxonomy/ResolveTermAbility.php — the target primitive.
data-machine-events/inc/Core/Promoter_Taxonomy.php — the collapse target.
Problem
Promoter_Taxonomy::find_or_create_promoter( \$name, \$data )in Extra-Chill/data-machine-events is a near-duplicate of DM core'sResolveTermAbility::resolve( \$identifier, \$taxonomy, \$create = true ). Both:The only non-core delta in
find_or_create_promoteris the metadata smart-merge on hit. That belongs post-resolution in a second step — not inside the resolver.Proposal
Refactor
find_or_create_promoterto:\\DataMachine\\Core\\Abilities\\Taxonomy\\ResolveTermAbility::resolve( \$name, 'promoter', create: true ).success + term_id, applysmart_merge_promoter_meta()to the returned term ID.{ term_id, was_created }shape to preserve the public signature.Net:
find_or_create_promotergoes from ~60 lines to ~20. Zero behaviour change for callers.Not-in-scope
Venue_Taxonomy::find_or_create_venueis NOT a candidate for the same collapse — it adds domain-specific fuzzy matching (address-based match, "The" prefix toggle, normalised-name match) that doesn't generalise cleanly. Keep it as-is.When to build
Low priority — pure cleanup, no user-facing change. File now so the duplication is tracked. Land alongside any future change to
Promoter_Taxonomy.References
inc/Abilities/Taxonomy/ResolveTermAbility.php— the target primitive.data-machine-events/inc/Core/Promoter_Taxonomy.php— the collapse target.