Private methods could be protected in Importer.php

Created on 16 June 2025, 20 days ago

Problem/Motivation

When running the processFile method, $url in updateTargetRevisionId() method could be null, causing the error below:

ResponseText: The website encountered an unexpected error. Try again later.

TypeError: Drupal\default_content_deploy\Importer::getEntityTypeByLink(): Argument #1 ($link) must be of type string, null given, called in /app/web/modules/contrib/default_content_deploy/src/Importer.php on line 928 in Drupal\default_content_deploy\Importer->getEntityTypeByLink() (line 896 of modules/contrib/default_content_deploy/src/Importer.php). Drupal\default_content_deploy\Importer->updateTargetRevisionId(Array) (Line: 662)
Drupal\default_content_deploy\Importer->processFile(Object, 847, 1043, 1, Array) (Line: 814)

Steps to reproduce

I have an export from version dev-2.0.x and trying to run an import on version 2.1.4. Running an import throws the above error.

Proposed resolution

Unfortunately the updateTargetRevisionId() is private, so I cannot override it. Note that getEntityTypeByLink is private as well.

Instead of duplicating the processFile() method only to call my private updateTargetRevisionId() to fix it, it would be better if updateTargetRevisionId() and getEntityTypeByLink() are protected methods. Also, a check for null inside the updateTargetRevisionId() would be great!

Remaining tasks

Make methods protected, add null check on $url.

User interface changes

None

API changes

None

Data model changes

None

๐Ÿ› Bug report
Status

Active

Version

2.1

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada sagesolutions

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024