add an empty post-update hook to force a container rebuild

Created on 23 April 2025, 2 months ago

Problem/Motivation

2.0.x introduces breaking changes that require a few changes to the module to get past.

πŸ“Œ Task
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada joseph.olstad

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

Merge Requests

Comments & Activities

  • Issue created by @joseph.olstad
  • First commit to issue fork.
  • Merge request !28Add post-update hook β†’ (Open) created by phenaproxima
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    ok that helps, however now that there's no more drush exception, the website throws a WSOD and dblog didn't catch it, I had to go into the error.log to find this:

    Got error 'PHP message: PHP Fatal error: Cannot redeclare Drupal\\layout_builder_st\\Element\\LayoutBuilder::layout() in /docroot/html/modules/contrib/layout_builder_st/src/Element/LayoutBuilder.php on line 74'

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Ok this change makes no difference, I patched 2.0.x, still unable to rebuild cache with drush without a massive exception.

    drush version: 13.3.3.0
    php version 8.3.20

    ╰❯ $ cat !$
    cat layout_builder_st.post_update.php

    /**
     * @file
     * Contains post-update hooks for layout_builder_st.
     */
    
    declare(strict_types=1);
    
    /**
     * Rebuilds the container for updating layout_builder_st to v2.0.0.
     */
    function layout_builder_st_rebuild_container_for_v2(): void {
      // Empty post-update hook to force a container rebuild.
    }
    

    ╭─◀ β˜• ryzen β–Ά /docroot/html/modules/contrib/layout_builder_st β–Ά πŸ“‚3 πŸ“ƒ10 πŸ”—0 β–Ά πŸ”€ 2.0.x β–Ά
    ╰❯ $ drush cr;
    [error] TypeError: Drupal\layout_builder_st\DependencyInjection\ClassResolver::__construct(): Argument #1 ($decorated) must be of type Drupal\Core\DependencyInjection\ClassResolverInterface, Drupal\Core\DependencyInjection\Container given, called in /var/www/clients/client1/web1/web/docroot/html/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 in Drupal\layout_builder_st\DependencyInjection\ClassResolver->__construct() (line 14 of /var/www/clients/client1/web1/web/docroot/html/modules/contrib/layout_builder_st/src/DependencyInjection/ClassResolver.php) #0 /var/www/clients/client1/web1/web/docroot/html/core/lib/Drupal/Component/DependencyInjection/Container.php(259): Drupal\layout_builder_st\DependencyInjection\ClassResolver->__construct()

    Only way past this is to truncate all cache tables.

    once I truncate all cache tables, the site appears to work.

    Surely there's a way to make this a lovely experience for everyone involved without having to truncate all cache_* tables manually?

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Hmmm...well, the post-update has to run first, before the container is rebuilt. Did you do drush updb first?

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    this magical function here:

    function layout_builder_st_rebuild_container_for_v2(): void {
      // Empty post-update hook to force a container rebuild.
    }
    

    what is this for_v2? This can't possibly be a hook, how would this ever get called? Is this part of a mystery API for core?

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    ah ok ya drush updb, ok I'll try that now

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    It's a post-update hook. They're run as part of normal database updates (update.php, or drush updb). The _for_v2 suffix is just the arbitrary name assigned to the hook, that's how they work: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    You know...I just realized that I mis-named the hook. Let me push a correction there...

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Adjusting credit, since you've been helping me test this out.

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Ok ya, this works

  • Pipeline finished with Skipped
    2 months ago
    #480697
  • Pipeline finished with Skipped
    2 months ago
    #480698
  • Pipeline finished with Skipped
    2 months ago
    #480699
  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    With the latest change, it comes through.

    Thanks!

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Merged into 2.0.x.

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    Please tag an rc release or something.

    alpha, beta or rc, any of the above would be good.

    suggested tags:

    2.0.0-alpha
    2.0.0-beta
    2.0.0-rc1

    I would suggest that this qualifies for at least a beta. This module is way past alpha stage.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024