Skip to content

Track the plugin of executed seeds in cake_seeds#1107

Open
dereuromark wants to merge 2 commits into
5.xfrom
issue-1106-plugin-seeds
Open

Track the plugin of executed seeds in cake_seeds#1107
dereuromark wants to merge 2 commits into
5.xfrom
issue-1106-plugin-seeds

Conversation

@dereuromark

Copy link
Copy Markdown
Member

Fixes #1106

Seeds executed from a plugin were logged into cake_seeds with plugin = NULL.

The plugin was derived from the seed class name, but seed classes are not namespaced (see templates/bake/Seed/seed.twig), so str_contains($className, '\\') was always false and the plugin was always null. The same broken detection existed in four places:

  • AbstractAdapter::seedExecuted() - wrong insert
  • AbstractAdapter::removeSeedFromLog() - deleted plugin IS NULL rows only
  • Manager::isSeedExecuted() - plugin seeds were never detected as executed, so they re-ran on every seeds run and were skipped by seeds reset
  • SeedStatusCommand::execute() - plugin seeds always reported as pending

All four now use the plugin of the current run (Util::getSeedPlugin()), the same source migrations already use.

Backwards compatibility

Entries written before this fix carry plugin = NULL for plugin seeds. To avoid re-running seeds that already ran, a NULL entry still matches when looking up a plugin seed, and seeds reset --plugin removes those entries too. The trade-off: an application seed sharing its name with a plugin seed can be matched as well. That is preferred over re-running a non-idempotent seed and duplicating data.

Seed classes are not namespaced, so deriving the plugin from the class name
never matched and plugin seeds were logged with a null plugin. The plugin of
the current run is used instead, matching how migrations are tracked.

Because of the null plugin, plugin seeds were also never detected as executed,
so they ran again on every seeds run and were skipped by seeds reset.

Seed log entries written before this fix are still matched for plugin seeds so
that they are not executed a second time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seeds in Plugins do not shown in cake_seeds table as plugin seed

1 participant