As Stefan Freudenberg reported in #2723115: Count cache configuration does not work as expected
I have also noticed that the default cache key provided is the same for all migrations sharing a source plugin.
if (!isset($this->cacheKey)) { $this->cacheKey = hash('sha256', $this->getPluginId()); }I am a not sure how to obtain a safe default.
While this isn't an issue in practice for SqlBase-based plugins (as those in core are) because usually each migration has a distinct source plugin (for its distinct query), I can verify that this is broken by adding cache_count: true to the "url" source plugins in migrate_example_advanced - all the migrations report a count of "2", which is the true count for the first one.
Much as I hate having the source plugin coupled to the migration plugin, we have to live with that anyway in 8.x. The primary purpose of the count is for reporting on the frontend, where it is tied to the migration, so I think using the migration's ID ($this->migration->getPluginId()) is the best solution here.
Comments
Comment #11
mikelutzClosing as a dupe of #3092227: SourcePluginBase should cache based on a hash of the source configuration, not just the plugin id.. Despite this issue being older, the other issue has a significant amount of work put in, while this has none.
Comment #12
wim leersEven though this predates #3092227: SourcePluginBase should cache based on a hash of the source configuration, not just the plugin id. by more than three years, that issue has all the activity. So, marking as duplicate in favor of that one.
EDIT: cross-posted, hah!