Liveblog Drupal 11 Fatal Error Issue

Created on 30 May 2025, 2 months ago

Problem/Motivation

The Liveblog module is experiencing a fatal PHP error when running on Drupal 11 due to an incorrect type declaration in the LiveblogAjaxResponseAttachmentsProcessor class. This appears to be a compatibility issue where the module hasn't been updated to match Drupal 11's stricter type requirements.

Fatal error: Type of Drupal\liveblog\LiveblogAjaxResponseAttachmentsProcessor::$assetResolver must be Drupal\Core\Asset\AssetResolverInterface (as in class Drupal\Core\Ajax\AjaxResponseAttachmentsProcessor) in /var/www/html/web/modules/contrib/liveblog/src/LiveblogAjaxResponseAttachmentsProcessor.php on line 29

Root Cause: Drupal 11 enforces stricter type declarations and the Liveblog module's $assetResolver property declaration doesn't match the required AssetResolverInterface type from the parent class.

Steps to reproduce

  1. Set up a Drupal 11 site
  2. Install the Liveblog module via Composer: composer require drupal/liveblog
  3. Enable the Liveblog module through the admin interface or drush: drush en liveblog
  4. Navigate to any page on the site
  5. Observe the fatal error preventing page load
  6. Check error logs to confirm the type declaration mismatch

Proposed resolution

The issue requires updating the Liveblog module to be compatible with Drupal 11's type system requirements. The immediate fix involves correcting the property type declaration.

Immediate Fix:

Update the $assetResolver property declaration in LiveblogAjaxResponseAttachmentsProcessor.php:

// Current (incorrect) declaration:
protected $assetResolver;

// Correct declaration for Drupal 11:
protected AssetResolverInterface $assetResolver;

Long-term Solution:

  • Update the entire Liveblog module for Drupal 11 compatibility
  • Add proper type hints throughout the codebase
  • Test against Drupal 11's requirements
  • Update composer.json to indicate Drupal 11 support

Remaining tasks

  • Fix the immediate type declaration in LiveblogAjaxResponseAttachmentsProcessor.php
  • Review all class properties and methods for Drupal 11 compatibility
  • Update use statements and imports as needed
  • Test the module functionality on Drupal 11
  • Run automated tests to ensure no regressions
  • Update module's composer.json to support Drupal 11
  • Update module documentation for Drupal 11
  • Create a patch or update the module repository

User interface changes

No user interface changes are expected from this compatibility fix. The changes are purely backend code corrections to resolve the fatal error and ensure the module functions properly on Drupal 11.

API changes

No breaking API changes are expected. The fix maintains backward compatibility while ensuring forward compatibility with Drupal 11. The changes involve:

  • Adding proper type declarations to match parent class interfaces
  • Ensuring method signatures comply with Drupal 11 standards
  • Maintaining existing functionality and method behaviors

Data model changes

No data model changes are required for this compatibility fix. This is purely a code-level correction to resolve type declaration mismatches introduced by Drupal 11's stricter type enforcement requirements.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇮🇳India abhinesh

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024