Add update hook to fix corrupted paragraphs from #3060223

Created on 10 November 2022, about 2 years ago
Updated 31 May 2023, over 1 year ago

Problem/Motivation

In #3060223: Corrupted data on cloning nodes that contain paragraphs , we fixed an issue where cloning a node with paragraphs would mix up paragraph parent_ids. However, this only fixes the issue moving forward. If you had corrupted paragraphs, they would not be fixed. An update hook was proposed but wasn't reviewed by the community (RBTC). This ticket is focused on the update hook.

Steps to reproduce

Have corrupted paragraphs before #3060223: Corrupted data on cloning nodes that contain paragraphs fix.

Proposed resolution

Use update hook.

Remaining tasks

RBTC

User interface changes

N/A

API changes

N/A

Data model changes

N/A

📌 Task
Status

Needs work

Version

1.0

Component

Code

Created by

🇺🇸United States charginghawk

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇸🇰Slovakia coaston

    Hi charginghawk

    after I applied your patch i am getting following issue when trying to reach update.php

    entity_clone module
    Update fix_corrupt_paragraph_parent_ids
    
        Failed: Drupal\Core\Utility\UpdateException: in entity_clone_post_update_fix_corrupt_paragraph_parent_ids() (line 100 of /modules/entity_clone/entity_clone.post_update.php).
    
    

    -it is basically the last row of your patch
    throw new UpdateException();

    Any idea why ?

  • 🇺🇸United States charginghawk

    @coaston Not sure, there's supposed to be more information, per this bit:

    $messenger->addError("{$parent->parent_type}.{$parent->parent_field_name} update failed, corrupt paragraphs: $numFailed")

    I would check your logs, or try again after setting system.logging error_level to verbose.

  • 🇮🇳India shreyal999

    Getting the below error on running the update :

    entity_clone module
    Update fix_corrupt_paragraph_parent_ids

    Failed: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal9.paragraphs_library_item__paragraphs' doesn't exist: SELECT "parent"."entity_id" AS "host_id", "parent"."paragraphs_target_id" AS "target_id", "parent"."paragraphs_target_revision_id" AS "rev_id" FROM "paragraphs_library_item__paragraphs" "parent" INNER JOIN "paragraphs_item_field_data" "paragraph" ON parent.paragraphs_target_id = paragraph.id AND parent.paragraphs_target_revision_id = paragraph.revision_id AND parent.entity_id <> paragraph.parent_id; Array ( ) in entity_clone_post_update_fix_corrupt_paragraph_parent_ids() (line 54 of /app/web/modules/contrib/entity_clone/entity_clone.post_update.php).

  • Status changed to Needs work over 1 year ago
Production build 0.71.5 2024