Argument #1 ($entity) must be of type Drupal\Core\Config\Entity\ConfigEntityInterface

Created on 20 February 2023, over 2 years ago

Problem/Motivation

[error] Drupal\Core\Config\Entity\ConfigEntityStorage::updateFromStorageRecord(): Argument #1 ($entity) must be of type Drupal\Core\Config\Entity\ConfigEntityInterface, null given, called in /app/html/modules/contrib/update_helper/src/Updater.php on line 433

Steps to reproduce

While running updb with php8

Proposed resolution

Validate if entity exists

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇮🇳India nikhilesh gupta Hyderabad

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

Comments & Activities

  • Issue created by @nikhilesh gupta
  • Status changed to Needs review over 2 years ago
  • 🇮🇳India TanujJain-TJ

    Reviewed patch #2 the patch applied successfully. tested with drupal:10.1.

  • 🇺🇸United States SocialNicheGuru

    this happens if you have update_helper installed. It does not if it is not.

    What happens during updates:

    - update_helper loads the entity (line 432 in Updater.php)
    - Compares it against expected_config
    - If it matches, proceeds with update_actions
    - If it doesn't match or entity is null, it fails safely

    The original empty {} was problematic because:
    - It allowed null entities to pass validation
    - Caused the fatal error when trying to call updateFromStorageRecord() on null
    - Essentially bypassed the safety checks

    There is a patch to make the updates more robust.

    And there is this patch for update_helper:

     "drupal/update_helper":{
                "Argument #1 ($entity) must be of type Drupal\Core\Config\Entity\ConfigEntityInterface":"https://www.drupal.org/files/issues/2023-02-20/entity-3343140-2.patch"
            },

    I saw the patch above which matches the update error that I saw.
    I created the patch and tested it and it seems to work.

    patch file: 3536078-fix-extension-list-module-getpath-comprehensive.patch

    This patch includes fixes for:
    - social_course_update_8305.yml (3 views)
    - social_course_update_8307.yml (1 view)
    - social_course_statistics_update_13001.yml (2 views)

    It was successfully tested on social_course 6.2.4 and applies cleanly.

Production build 0.71.5 2024