Problem/Motivation

See \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::count() + \Drupal\migrate\Plugin\migrate\source\SourcePluginBase::$cacheCounts.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Status: Needs review » Needs work

The last submitted patch, 2: 3190804-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Wim Leers’s picture

I cannot reproduce those failures. Re-testing against 9.1 in case that makes a difference.

Wim Leers’s picture

Title: Allow source counts to be cached: implement ::doCount() instead of ::count() » [PP-1] Allow source counts to be cached: implement ::doCount() instead of ::count()
Status: Needs work » Postponed
DamienMcKenna’s picture

Thanks for the patch and improvement, I look forward to the core change being committed so we can take advantage of this.

Wim Leers’s picture

Issue tags: +Novice

@DamienMcKenna: wow that was fast! 😄

+++ b/src/Plugin/migrate/source/d7/MetatagFieldInstance.php
@@ -137,7 +137,7 @@ class MetatagFieldInstance extends DrupalSqlBase {
-  public function count($refresh = FALSE) {
+  public function doCount() {

Nit: should be protected.

Wim Leers’s picture

Title: [PP-1] Allow source counts to be cached: implement ::doCount() instead of ::count() » Allow source counts to be cached: implement ::doCount() instead of ::count()
Status: Postponed » Needs review
DamienMcKenna’s picture

This would break compatibility with 8.9, so let's see if we can have both functions.

Wim Leers’s picture

+++ b/src/Plugin/migrate/source/d7/MetatagFieldInstance.php
@@ -141,4 +141,11 @@ public function count($refresh = FALSE) {
+  public function doCount() {

Should still be changed to protected 😅

Wim Leers’s picture

Status: Needs review » Needs work
Issue tags: -Novice

FYI: the two failures in #12 on PHP 8 + Drupal 9.2 are the same two that exist in HEAD: https://www.drupal.org/pift-ci-job/2057145.

Also, the change in #10 + #12 compared to #12 breaks the performance improvement that #3190815: Source count caching broken: impossible to enable source count caching for SqlBase-based source plugins (plus, unneeded cache I/O) made possible.

If you want to support both simultaneously, you'll need to make count() smarter: you'll need to update its logic to be conditional depending on the Drupal core version…

Wim Leers’s picture

With #3190818: Allow source counts to be cached: implement ::doCount() instead of ::count() also committed … and with time having passed … I'm wondering if you'd be willing to commit this without BC layer for Drupal 8.9, @DamienMcKenna?

DamienMcKenna’s picture

With Drupal 8 no longer supported, I think this can go in the next release.

DamienMcKenna’s picture

Status: Needs work » Fixed

Committed. Thank you.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.