Skip to content

Collapse data-machine-events find_or_create_promoter onto ResolveTermAbility::resolve() #1164

@chubes4

Description

@chubes4

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:

  1. Call \\DataMachine\\Core\\Abilities\\Taxonomy\\ResolveTermAbility::resolve( \$name, 'promoter', create: true ).
  2. If the call returned success + term_id, apply smart_merge_promoter_meta() to the returned term ID.
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions