Closed (fixed)
Project:
Migrate Plus
Version:
6.0.x-dev
Component:
API
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
19 Jul 2024 at 03:14 UTC
Updated:
22 Aug 2024 at 17:49 UTC
Jump to comment: Most recent
The changes made to Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json for #2640516: Support paging through multiple requests included backwards-incompatible API changes (protected method signature changes).
We have a custom module that includes a data_parser plugin that extends the Json plugin. After upgrading migrate_plus to 6.0.3 we saw errors when scanning our custom module code with PHPStan:
------ ---------------------------------------------------------------------------------------------------------------------------
Line modules/custom/custom_module/src/Plugin/migrate_plus/data_parser/CustomJson.php
------ ---------------------------------------------------------------------------------------------------------------------------
20 Method
Drupal\custom_module\Plugin\migrate_plus\data_parser\CustomJson::getSourceData()
overrides method
Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::getSourceData()
but misses parameter #2 $item_selector.
21 Method
Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::getSourceData()
invoked with 1 parameter, 2 required.
------ ---------------------------------------------------------------------------------------------------------------------------
[ERROR] Found 2 errors
Set a default value for the new parameter to preserve backwards compatibility.
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
joegraduateComment #3
joegraduateComment #4
joegraduateComment #6
joegraduateComment #7
heddnNW for some minor feedback.
Comment #8
joegraduateApplied suggestions from @lucashedding and a couple of other changes. I think this is ready for review again.
Comment #9
heddnNice enhancements!
Comment #11
heddnComment #12
huzooka@joegraduate, @heddn, Thank you! 🙏
Comment #13
jsacksick commentedFYI, that change broke all my migrations... After I reverted to 6.0.2, all my migrations ran successfully again...
Not really sure what information I can provide, somehow it seems no rows was detected by the migration.
Comment #14
heddnhttps://www.drupal.org/project/migrate_plus/releases/6.0.4 does include the BC fix now too.
Comment #15
jsacksick commentedAfter upgrading to 6.0.4, the rows count is 0 for all my migrations, reverting to 6.0.2 fixes the issue...
Comment #16
huzooka@jsacksick, Could you please check whether the
3465782-using-slash-json-parserbranch (MR 102) in #3465782: Using "/" item_selector in Json parser plugin config does not work as expected anymore fixes the issue you have?Comment #17
joegl commented6.0.4 does not fix this issue. Our custom plugin which extends Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::getSourceData is still broken:
PHP Fatal error: Declaration of Drupal\CustomJson\Plugin\migrate_plus\data_parser\CustomJson::getSourceData(string $url): array must be compatible with Drupal\migrate_plus\Plugin\migrate_plus\data_parser\Json::getSourceData(string $url, string|int $item_selector = '')It looks like the BC fix only introduces a default value if one is not specified. This would fix an issue with using the getSourceData method in code, but does not fix issues when the Json class is extended to a custom class which implements the getSourceData method. I don't think there is necessarily a backwards-compatible fix extending the class. Typically a change to a class definition would constitute at least a minor version increase to indicate the change is not backwards-compatible, (i.e., this release should have been 6.1.0, not 6.0.3).