Problem/Motivation

The errorCount method on the MigrateIdMapInterface documents the return value as a string but Sql::errorCount() returns a string. This is likely true for the other count methods, importedCount, UpdateCount, messageCount, processedCount. Note that NullIdMap::errorCount(), and the other count methods in that class, return an integer.

Assertions in MigrateSqlIdMapTest.php are aware of this

  $this->assertSame(2, (int) $id_map->importedCount());

Proposed resolution

Change the methods in Sql to return an int

Remaining tasks

Write a patch

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quietone created an issue. See original summary.

jofitz’s picture

Tighten up the tests and cast the results of the 5 count functions.

The last submitted patch, 2: 2937666-2-test_only.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 2: 2937666-2-complete.patch, failed testing. View results

jofitz’s picture

Status: Needs work » Needs review
FileSize
577 bytes
5.8 KB

Correct test failure. It seems other places are promising integers and returning strings too!

quietone’s picture

Status: Needs review » Needs work

Thanks, that tidies this up nicely. I applied the patch and grepped for all the count functions and found one odd one. Why did this not require a change?

In MigrateFieldTest.php
$this->assertSame($migration->getSourcePlugin()->count(), $migration->getIdMap()->processedCount());

jofitz’s picture

Status: Needs work » Needs review

@quietone The instance you have highlighted did not require a change because previously it was comparing to integer strings, it is now comparing two integers. getSourcePlugin() uses the count() function in SqlBase.php (that has been updated to cast to integer) while getIdMap() uses the processedCount() function in Sql.php (that has also been updated to cast to integer).

quietone’s picture

Status: Needs review » Reviewed & tested by the community

@Jo Fitzgerald, thanks. I see it now.

  • catch committed 7ecda05 on 8.6.x
    Issue #2937666 by Jo Fitzgerald, quietone: errorCount() returns string...
catch’s picture

Version: 8.6.x-dev » 8.5.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.6.x and cherry-picked to 8.5.x. Thanks!

  • catch committed b235999 on 8.5.x
    Issue #2937666 by Jo Fitzgerald, quietone: errorCount() returns string...

Status: Fixed » Closed (fixed)

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