Problem/Motivation

Drupal\content_translation\Plugin\migrate\source\I18nQueryTrait is also used in multiple migrate source plugins of other modules (e.g. Drupal\block_content\Plugin\migrate\source\d7\BlockCustomTranslation). This may make sense as translations usually require to have content_translation enabled. However it prevents e.g. the type checking of such plugins without instantiating them, as done in https://www.drupal.org/project/entity_import, Drupal\entity_import\EntityImportSourceManager::getDefinitions().

Steps to reproduce

  • Install Drupal standard installation profile in English, make sure content_translation is not enabled
  • Install migrate_drupal module
  • Install https://www.drupal.org/project/entity_import
  • Login in and go to /admin/config/system/entity-importer/add (Content > Importers > entity importer creation page)

Instead of displaying a form to add an entity importer, the following fatal error occurs:

Trait 'Drupal\content_translation\Plugin\migrate\source\I18nQueryTrait' not found in /var/www/html/web/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustomTranslation.php on line 22

Proposed resolution

I18nQueryTrait is used in the context of migrations and the migrate module already contains Drupal\migrate\Plugin\migrate\source\DummyQueryTrait. Hence it seems reasonable to move Drupal\content_translation\Plugin\migrate\source\I18nQueryTrait to Drupal\migrate\Plugin\migrate\source\I18nQueryTrait in order to avoid unnecessary dependencies.

User interface changes

None.

API changes

None.

Data model changes

None.

Issue fork drupal-3258581

Command icon Show commands

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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

boromino created an issue. See original summary.

boromino’s picture

Issue summary: View changes

boromino’s picture

Status: Active » Needs review
boromino’s picture

Issue summary: View changes
merlin06’s picture

Version: 9.4.x-dev » 9.3.x-dev
FileSize
9.71 KB

Patch applies against 9.3.3

merlin06’s picture

Version: 9.3.x-dev » 9.4.x-dev

Sorry, I didn't intend to change the version number.

quietone’s picture

Component: content_translation.module » migration system
Category: Feature request » Bug report
Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative

I tested this on 9.4.x, standard install and was not able to reproduce this error. I followed the steps given in the Issue Summary. Is there something else that needs to be done? Changing status to get more information.

The migrate maintainers work from the 'migration system' component, changing component.

This isn't a feature request and although I can't reproduce the problem, changing to a bug report.

sanduhrs’s picture

Status: Postponed (maintainer needs more info) » Active

Just ran into the exact same issue while trying to install entity_import module.
The 'Add entity importer' just gives a WSOD.

quietone’s picture

Assigned: Unassigned » quietone

@sanduhrs, thanks for reporting the problem.

I am still not able to reproduce the problem using the steps in the Issue Summary.

Doing more research I see that In the related issue the explanation for the problem is given and so is the workaround. I suggest using that method.

The i18nQuery trait is only needed for migrating a drupal database and thus will not be moving to the migrate module. What could be done in core is add checkRequirements to the source plugins using the trait to ensure that content_translation is enabled. Assigning this to myself to consider that later.

boromino’s picture

Issue summary: View changes

Sorry for the confusion, migrate_drupal module has to be installed, too. I edited the issue description accordingly.

@quietone I see your point regarding migrate module. Would you consider to add the trait to the migrate_drupal module, instead? Then I would provide a patch for that. As entity_import does not require migrate_drupal, another work-around makes probably more sense.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture