Export images uploaded via CKEditor

Created on 9 February 2024, 5 months ago
Updated 8 March 2024, 4 months ago

Problem/Motivation

Drupal core's Standard profile ships CKEditor configured to allow uploading images by the click of a CKEditor button. Those images are currently not exported, therefore cannot be imported either.

Steps to reproduce

  1. Install core with the Standard profile.
  2. Create a Basic page node, with an image uploaded using the CKEditor button.
  3. Export the node.
  4. Reinstall the site, making sure that the uploaded file was deleted (or use a completely different environment for importing).
  5. Import the zip.

Expected behavior: image uploaded using the CKEditor button gets exported, therefore gets imported as well.

Actual behavior (as of 1.4.4): image uploaded using the CKEditor button is NOT exported, therefore cannot be imported either.

Proposed resolution

Add code that supports this.

Remaining tasks

Review, commit, release.

User interface changes

None.

API changes

None. Exporting file entities also became possible.

Data model changes

None.

✨ Feature request
Status

Needs review

Version

1.4

Component

Code

Created by

πŸ‡­πŸ‡ΊHungary Boobaa

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

Comments & Activities

  • Issue created by @Boobaa
  • Status changed to Needs review 5 months ago
  • πŸ‡­πŸ‡ΊHungary Boobaa

    Attached patch provides this feature, based on already-existing examples.

  • πŸ‡­πŸ‡ΊHungary mxr576 Hungary
    $this->privateTempStore->get('export.assets')
    

    What is going to flush out things stored in this storage after the export is done? I see that whatever is stored there gets overridden every time. By the way, due to this user-specific but shared storage, isn't there a slight chance for unexpected behaviors when the same user executes multiple exports at the same time?

  • πŸ‡­πŸ‡ΊHungary Boobaa

    @mxr576: While your comment is asking a proper question, it does not belong to this particular patch/issue. The race condition you mentioned is also present without this patch, as this user-specific but shared storage is also used elsewhere already during the export process. Because of that, I think a different issue should handle that problem – if at all, because I also think that this is quite a corner case: I just cannot really imagine myself executing another export while the first one also started by myself is still running. IOW, this is theoretically possible for sure, but practically? I'm not that sure.

  • πŸ‡­πŸ‡ΊHungary mxr576 Hungary

    roger :) thanks for the detailed answer

  • πŸ‡ΊπŸ‡ΈUnited States rprager

    The patch in #2 didn't work for me. I received an error when trying to export. I changed line 45 from

    public function mapBaseFieldsValues(array $values, FieldableEntityInterface $entity): array {

    to

    public function mapBaseFieldsValues(array $values): array {

    and that worked for me.

Production build 0.69.0 2024