SourcePluginBase provides a count() method which returns the number of available source rows, and optionally caches the counts in the presence of the cache_counts configuration option. By default, it obtains the initial count with $this->getIterator()->count()
. Particular source plugins may have more efficient ways to obtain their counts - notably, SqlBase uses a COUNT query. Previous to 8.2.x, to implement a custom count algorithm required overriding SourcePluginBase::count(), effectively disabling the caching functionality. As of 8.2.x, a source plugin implementing a custom count algorithm should do this in a protected doCount() method rather than count().
No change is required - source plugins which override count() will see no change, but it is recommended to move the count implementation to computeCount() so your source can take advantage of caching.
Previously:
public function count() {
return $this->query()->countQuery()->execute()->fetchField();
}
Now:
protected function doCount() {
return $this->query()->countQuery()->execute()->fetchField();
}