Follow-up to #2833562-10: Installing modules using the ConfigImporter does not work

Problem/Motivation

There was introduced special event #2361423: Add a step to config import to allow contrib to create content based on config dependencies to handle missing content when config import finishing.
The parent issue allows to install default content fixtures for newly installed modules but in case of block content config it may need to import missing content entities instead of all module's default content

Proposed resolution

Add handling of the event to add missing content after config import

Remaining tasks

Reviews needed.

User interface changes

None

API changes

None

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

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
FileSize
3.38 KB

Initial stub on it, discovery still needs proper implementation

tstoeckler’s picture

Status: Needs review » Needs work
+++ b/src/EventSubscriber/ConfigImportMissingContentEventSubscriber.php
@@ -0,0 +1,75 @@
+      $data['uuid'] . '.json',

I think this is problematic. While Default Content exports content with the .json filename by default, it supports renaming the files to something more semantic just fine.

As far as I can tell, the only way to reliably find the UUID is to actually parse the file.

basil_snowman’s picture

Status: Needs work » Needs review
+++ b/src/EventSubscriber/ConfigImportMissingContentEventSubscriber.php
...
+  protected function doResolve($uuid, array $data) {
...
    /** @var \Drupal\default_content\DefaultContentManagerInterface $service */
+    $service = \Drupal::service('default_content.manager');
+    //$service->importContent($module, $uuid);
+    $service->importContent($path);

This construction does not work. Need change method importContent() into DefaultContentManager.

andypost’s picture

I think we need to iterate only inside uuids that defined in module's info.yml "default_content" key

otoh it require to iterate over all modules and their files to find how many of exported files has this uuid inside, so could be disk intensive operation

basil_snowman’s picture

Status: Needs review » Needs work
andypost’s picture

Status: Needs work » Needs review

I used to write scanner and looks it's not so slow, so now it needs to unserialize from files and select latest if any changed property exists

https://github.com/andypost/default_content/blob/ui/default_content_ui/s...

andypost’s picture

Status: Needs review » Needs work

it still needs
- scanner to locate files
- import entity with dependencies

alexpott made their first commit to this issue’s fork.

alexpott’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

Let's solve this in 2.0.x

alexpott’s picture

Status: Needs work » Needs review
andypost’s picture

Core issues merged to 10.2 so the issue unblocked!

andypost’s picture