fatal error on `update` module enable on composer-managed D11.1.0 instance

Created on 22 December 2024, 2 days ago

my D11 site is composer installed/managed,

drush status | grep -i version
	Drupal version   : 11.1.0
	PHP version      : 8.4.2
	Drush version    : 13.3.3.0

served up on a linux instance of nginx/1.27.3.

it's got a few added modules installed, and some dummy content populating it.
so, a real-world use case, but not a _large_ install by any stretch.

as advised here

https://www.drupal.org/docs/develop/core-modules-and-themes/core-modules...

"If you installed Drupal with Composer, you will need to update with Composer ( https://www.drupal.org/docs/develop/using-composer/manage-dependencies )"

all good, that's the goal; `update_manager` module is DISabled.

but, a site status check reports:

"Update notifications are not enabled. It is highly recommended that you install the Update Manager module from the module administration page in order to stay up-to-date on new releases. For more information, Update status handbook page."

the site _seems_ to be behaving without it through install and inital use.
until _after_ i enable update_manager.

enabling is fine; but subsequently any site access sees this FATAL error:

The website encountered an unexpected error. Try again later.

TypeError: Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\update\ProjectCoreCompatibility->getPossibleCoreUpdateVersions() (line 83 of core/modules/update/src/ProjectCoreCompatibility.php).

Drupal\update\ProjectCoreCompatibility->__construct(Array, Array, Array) (Line: 106)
update_calculate_project_data(Array) (Line: 40)
update_requirements('runtime')
call_user_func_array('\update_requirements', Array) (Line: 355)
Drupal\Core\Extension\ModuleHandler->{closure:Drupal\Core\Extension\ModuleHandler::invokeAll():354}('\update_requirements', 'update') (Line: 307)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('requirements', Object) (Line: 354)
Drupal\Core\Extension\ModuleHandler->invokeAll('requirements', Array) (Line: 109)
Drupal\system\SystemManager->listRequirements() (Line: 93)
Drupal\system\SystemManager->checkRequirements() (Line: 122)
Drupal\system\Controller\SystemController->overview('system.admin_config')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}() (Line: 593)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 53)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle(Object, 1, 1) (Line: 116)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 90)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 36)
Drupal\Core\StackMiddleware\AjaxPageState->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 709)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

simply DISabling (drush pm:uninstall udpate) fixes the issue, and the site's immediately accessible & functional as before.

i suspect (?), but don't yet know, this is due to php version 8.4.2, which i understand Drupal is NOT compatible with.
yet.
but IS on the roadmap.
there's not specific indication of a php problem -- that i've found so far.

not sure if this

Hide and restrict package_manager (and update_manager) behind a dev/prod toggle so that they can be alpha stability in tagged releases
https://www.drupal.org/project/drupal/issues/3483481 📌 Restrict package_manager (and update_manager) behind a dev/prod toggle Active

includes an option to disable the complaint (?).

🐛 Bug report
Status

Active

Version

11.1 🔥

Component

update.module

Created by

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

Merge Requests

Comments & Activities

  • Issue created by @pgndrupal
  • re: 3135663, i'm not on a dev release of core (that was the only option I had in the dropdown). rather i'm on 11.1.0 *release*.

    i _do_ keep bumping into these TypeError issues -- so far, somewhat randomly & intermittently (e.g., https://www.drupal.org/project/drupal/issues/3467538#comment-15901089 🐛 Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\update\ProjectCoreCompatibility->getPossibleCoreUpdateVersions Active ).

    atm, in my current state, _this_ is fully repeatable/reproducible, here.

    dunno what specific info's helpful; can grab if asked.

  • This, I think is the same error as 🐛 fatal error on `update` module enable on composer-managed D11.1.0 instance Active . 🐛 fatal error on `update` module enable on composer-managed D11.1.0 instance Active doesn't have a stack trace so I don't know if this is quite the same. My investment in this right now is just determining if we have a duplicate issue.

  • @cliefen

    > 3495587 ... doesn't have a stack trace

    the OP here is with
    ```
    error_reporting(E_ALL);
    ini_set('display_errors', TRUE);
    ini_set('display_startup_errors', TRUE);
    $config['system.logging']['error_level'] = 'verbose';
    ```
    what specifically are you looking for beyond that? an `strace`? other?

  • I am seeking to understand if this issue duplicates the previously-reported 🐛 Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\update\ProjectCoreCompatibility->getPossibleCoreUpdateVersions Active . That is all. I wrongly referred back to this very issue in comment 4. Sorry for that confusing comment.

    This issue has a stack trace. The other does not. Both issues describe the bug reproduction environment, which I am beginning to think does not influence the bug occurring. Neither has steps to reproduce. There must be some steps to reproduce, even insomuch as an element of the environment may be the reproduction.

    The stack trace indicates that $this->existingCoreVersion is an object when it should be a string. How this is happening is a bit of a mystery.

  • > This issue has a stack trace. The other does not.

    +1

    > Neither has steps to reproduce.

    the `drush pm:install update` step is all that's needed to reproduce the behavior, _here_. leaving it UNINSTALLED (i.e., disabled) cures it here ...

    i understand you're looking for something that can be reproduced _elsewhere_; i don't have that atm.

    i notice that `TranslatableMarkup` seems to be common, at least in some. no idea yet if that's a red-herring or not.

  • Are there contributed or custom modules present in the Drupal installation that produces this bug?

  • yes, there are.
    no, i've not been able to bisect.
    fwiw, in this specific instance here:

      Core                              Announcements (announcements_feed)                                                  Enabled    11.1.0
      Core                              BigPipe (big_pipe)                                                                  Enabled    11.1.0
      Core                              Block (block)                                                                       Enabled    11.1.0
      Core                              Block Content (block_content)                                                       Enabled    11.1.0
      Core                              Breakpoint (breakpoint)                                                             Enabled    11.1.0
      Core                              CKEditor 5 (ckeditor5)                                                              Enabled    11.1.0
      Core                              Comment (comment)                                                                   Enabled    11.1.0
      Core                              Configuration Manager (config)                                                      Enabled    11.1.0
      Core                              Contact (contact)                                                                   Enabled    11.1.0
      Core                              Contextual Links (contextual)                                                       Enabled    11.1.0
      Field types                       Datetime (datetime)                                                                 Enabled    11.1.0
      Core                              Database Logging (dblog)                                                            Enabled    11.1.0
      Core                              Internal Dynamic Page Cache (dynamic_page_cache)                                    Enabled    11.1.0
      Core                              Text Editor (editor)                                                                Enabled    11.1.0
      Core                              Field (field)                                                                       Enabled    11.1.0
      Core                              Field UI (field_ui)                                                                 Enabled    11.1.0
      Field types                       File (file)                                                                         Enabled    11.1.0
      Core                              Filter (filter)                                                                     Enabled    11.1.0
      Core                              Help (help)                                                                         Enabled    11.1.0
      Core                              History (history)                                                                   Enabled    11.1.0
      Field types                       Image (image)                                                                       Enabled    11.1.0
      Field types                       Link (link)                                                                         Enabled    11.1.0
      Core                              Custom Menu Links (menu_link_content)                                               Enabled    11.1.0
      Core                              Menu UI (menu_ui)                                                                   Enabled    11.1.0
      Core                              MySQL (mysql)                                                                       Enabled    11.1.0
      Core                              Node (node)                                                                         Enabled    11.1.0
      Field types                       Options (options)                                                                   Enabled    11.1.0
      Core                              Internal Page Cache (page_cache)                                                    Enabled    11.1.0
      Core                              Path (path)                                                                         Enabled    11.1.0
      Core                              Path alias (path_alias)                                                             Enabled    11.1.0
      Core                              Search (search)                                                                     Enabled    11.1.0
      Core                              Shortcut (shortcut)                                                                 Enabled    11.1.0
      Core                              System (system)                                                                     Enabled    11.1.0
      Core                              Taxonomy (taxonomy)                                                                 Enabled    11.1.0
      Field types                       Text (text)                                                                         Enabled    11.1.0
      Core                              Toolbar (toolbar)                                                                   Enabled    11.1.0
      Core                              Update Manager (update)                                                             Disabled   11.1.0
      Core                              User (user)                                                                         Enabled    11.1.0
      Core                              Views (views)                                                                       Enabled    11.1.0
      Core                              Views UI (views_ui)                                                                 Enabled    11.1.0
      Administration                    Admin Toolbar (admin_toolbar)                                                       Enabled    3.5.1
      Administration                    Admin Toolbar Search (admin_toolbar_search)                                         Enabled    3.5.1
      Administration                    Admin Toolbar Extra Tools (admin_toolbar_tools)                                     Enabled    3.5.1
      Other                             Composer Deploy (composer_deploy)                                                   Enabled    8.x-1.10
      Development                       Devel (devel)                                                                       Enabled    5.3.1
      Encryption                        Encrypt (encrypt)                                                                   Enabled    8.x-3.2
      Spam control                      Honeypot (honeypot)                                                                 Enabled    2.2.0
      Security                          Key (key)                                                                           Enabled    8.x-1.19
      Mail                              Mail System (mailsystem)                                                            Enabled    8.x-4.5
      Other                             Pathauto (pathauto)                                                                 Enabled    8.x-1.13
      Other                             Redirect (redirect)                                                                 Enabled    8.x-1.10
      Performance                       Redis (redis)                                                                       Enabled    8.x-1.8+3-dev
      Security                          Security Review (security_review)                                                   Enabled    3.1.1
      Mail                              SMTP Authentication Support (smtp)                                                  Enabled    8.x-1.4
      Security                          Sodium (sodium)                                                                     Enabled    3.0.0
      Security                          Two-factor Authentication (TFA) (tfa)                                               Enabled    8.x-1.9
      Other                             Token (token)                                                                       Enabled    8.x-1.15
      Webform                           Webform Devel (webform_devel)                                                       Enabled    6.3.0-alpha3+7-dev
      Webform                           Webform UI (webform_ui)                                                             Enabled    6.3.0-alpha3+7-dev
      Webform                           Webform (webform)                                                                   Enabled    6.3.0-alpha3+7-dev
      Core                              Claro (claro)                                                                       Enabled    11.1.0
      Core                              Olivero (olivero)                                                                   Enabled    11.1.0
    

    with _that_ simply enabling `udpate` causes the error.
    the only logs i've seen, i've shared.

  • At a glance it may be composer_deploy, because it modifies update information. I would try uninstalling it first.

  • it was already happening prior to `composer_deploy` installation; i'd installed that while attempting to deal with this.

    that said, specifically,

    drush pm:uninstall composer_deploy
    drush pm:install composer_deploy
    

    and, immediately, at nav to `https://dev.pgnetwork.net/admin/config`

    The website encountered an unexpected error. Try again later.
    
    TypeError: Cannot access offset of type Drupal\Core\StringTranslation\TranslatableMarkup in isset or empty in Drupal\update\ProjectCoreCompatibility->getPossibleCoreUpdateVersions() (line 83 of core/modules/update/src/ProjectCoreCompatibility.php). 
    ...
    
  • Is it still the case when the module code is not present? Update manager looks at all present extensions.

  • For what it's worth that site doesn't have any particularly rare modules. I am trying to remember whether (and where) update data is cached...

  • as above

    drush pm:install update
    drush pm:uninstall composer_deploy
    

    *AND*

    composer remove composer_deploy
    drush cr
    
    composer show | grep -iE "deploy|update"
    	(empty)
    drush pm:list  | grep -iE "deploy|update"
    	Core         Update Manager (update)            Enabled    11.1.0
    

    now, NO WSOD error at /admin/*; poking around the site, can't atm get it to replicate.

    if not a fluke, `drush pm:install` does not seem sufficient?

    also, now, checking status report @ https://example.com/admin/reports/status#warning ,

    1 warning

    Drupal core update status
    	No update data available
    	No update information available. Run cron or check manually.
    
    Cron maintenance tasks
    	Last run 3 seconds ago
    	(more information)
    

    re-exec'ing cron doesn't cure.

    i can't find it in my scribbled notes atm, but iirc, composer_deploy was supposed to solve for the missing update info in a composer-installed Drupal instance

  • The TypeError exception is being thrown at this line:
    if (!isset($core_releases[$this->existingCoreVersion])) {

    $this->existingCoreVersion is set in the class constructor like so: $this->existingCoreVersion = $core_data['existing_version'];.

    AFAICT, the only time in core that the 'existing_version' property can be set to TranslatableMarkup is in core/modules/update/update.compare.inc:

    if (isset($info['version'])) {
      <snip ...>
    }
    else {
      // No version info available at all.
      $install_type = 'unknown';
      $info['version'] = t('Unknown');
      $info['major'] = -1;
    }
    
    // Finally, save the results we care about into the $projects array.
    $projects[$key]['existing_version'] = $info['version'];
    

    I'm not sure how to get in a state where version info for Drupal core itself would be missing, but it's possible that the composer_deploy module touches some of that metadata, so there might be something in there that causes the version to get unset.

    Nevertheless, the code in ProjectCoreCompatibility can be hardened to detect whether the existing version is not a string, using logic similar to what Package Manager does:

    if ($existing_version instanceof TranslatableMarkup && $existing_version->getUntranslatedString() === 'Unknown') {
    

    So in ProjectCoreCompatibility, it could look something like:

      public function __construct(array $core_data, array $core_releases, array $supported_branches) {
        if (isset($core_data['existing_version'])) {
          $this->existingCoreVersion = $core_data['existing_version'] instanceof TranslatableMarkup ? $core_data['existing_version']->getUntranslatedString() ? $core_data['existing_version'];
          $this->possibleCoreUpdateVersions = $this->getPossibleCoreUpdateVersions($core_releases, $supported_branches);
        }
      }
    

    Alternatively, probably should consider enforcing version to be a string (making it translatable doesn't make much sense IMHO), so
    changing $info['version'] = t('Unknown'); to $info['version'] = 'Unknown'; might be a good place to start. That code dates back a long way (at least to 2007?), though, so not sure if there'd be any side effects from doing that.

  • Pipeline finished with Canceled
    about 2 hours ago
    #378007
  • For a workaround until someone identifies the bug in Composer Deploy or there's consensus on a fix otherwise, I put up MR 10669 with the ProjectCoreCompatibility constructor change mentioned in #15. The diff can be downloaded and applied locally as a patch.

  • fwiw, confirming

    drush core-status | grep -i version
    	Drupal version   : 11.1.0 <--- release, not dev branch
    	PHP version      : 8.4.2
    	Drush version    : 13.3.3.0
    
    pushd web
    curl -s https://git.drupalcode.org/project/drupal/-/merge_requests/10669.diff |  patch -p1
    	patching file core/modules/update/src/ProjectCoreCompatibility.php
    
    popd
    
    composer require drupal/composer_deploy
    drush pm:install composer_deploy
    
    drush pm:list | grep -iE "deploy|update"
      Core                              Update Manager (update)                     Enabled    11.1.0
      Other                             Composer Deploy (composer_deploy)           Enabled    8.x-1.10
    

    no more FATAL error, so far. the two mods can coexist.

    @ status report, i DO see now/still,

    Warnings found
    	Drupal core update status
    	No update data available
    	No update information available. Run cron or check manually.
    
Production build 0.71.5 2024