Issue #3586338: Restore Drupal 10 compatibility and repair beta3 upgrades.
Summary
Restores Drupal 10.5+ and PHP 8.1 compatibility after regressions introduced in 1.0.0-beta3. It also repairs context item data left incomplete by failed beta3 database updates, restores Drupal 10 invocation of attribute-based hooks, and expands automated compatibility coverage.
Changes include:
- Restoring explicit Drupal 10 service registration for hook classes (
DiffHooks,DynamicEntityReferenceHooks, andSchedulerHooks). - Adding Drupal 10 procedural bridges for attribute-based hooks that Drupal 10 does not discover: a
#[LegacyHook]hook_theme()bridge (so theme hooks such asai_context_overviewrender instead of returning HTTP 500), and extending thehook_modules_installed()bridge to also invokeSchedulerHooks(so Scheduler setup and Content Moderation sync run). - Adding cross-version entity original-value handling.
- Repairing
NULLrevision pointers through updates 10011 and 10013, and documenting the deliberate idempotent double call of the repair helper. - Removing unrecoverable incomplete context items safely.
- Making list builders, database fetching, configuration import tests, and document loader test helpers compatible across supported versions.
- Adding kernel tests for hook registration (including theme hooks and
SchedulerHooks), revision handling, data repair, invalid records, and idempotency. - Automatically running previous-major CI.
- Adding legacy
@groupannotations required by Drupal 10 test discovery across the main module and theai_context_document_loadersubmodule.
Local linting, PHPStan, PHPCS, and the affected unit and kernel tests pass.
Release note
Drupal 10 upgrade fix and data recovery
1.0.0-beta3 introduced a Drupal 11-only API (getOriginal()) and dropped explicit hook service registration, which broke drush updb on Drupal 10 and could cause context item saves to fail. On Drupal 10, a failed save could commit a NULL revision pointer to the base table, leaving the item's data and prior revisions intact but invisible to the Entity API (it no longer loads).
This release restores Drupal 10.5+ / PHP 8.1 compatibility and automatically repairs affected content:
- Update 10011 repairs recoverable items before its backfill runs.
- Update 10013 re-points such items at their latest default revision and safely removes empty rows left by failed first saves.
Action required: run drush updb (or Admin › Reports › Available updates › Run database updates) after updating. The repair is idempotent and safe to run more than once. If an item cannot be safely recovered, the update stops with an error identifying the affected item IDs so it can be handled manually.
Before manually repairing an affected item, back up the database and inspect the listed item's base, field-data, and revision rows. Restore a verified default revision pointer or remove the incomplete record only after confirming that it cannot be recovered, then rerun database updates.
Previous MR info
Description
Fixes compatibility issues with Drupal 10.
Closes #3586338
Testing instructions
- Install beta2 on a Drupal 10.5+ project.
- Update to beta3.
- Switch to this fork or create a patch from it.
- Run drush updb. The database updates should complete without errors.
Checklist
- I have updated the MR title to use format:
Issue #1234: My issue title. - I have updated the MR description to include:
Closes #1234 - I have performed a self-review of my own code
- I have added or updated tests, or explained in the description why this change is not covered by tests
- I have written testing instructions and verified them locally
- I have noted any required post-merge steps (config imports, cache rebuilds, manual changes)
- This MR contains no breaking API or hook changes, or they are explicitly documented in the description
Not applicable:
- I have updated documentation for any new or changed functionality
AI Compliance
Note
Check the one that best describes your usage, or leave all unchecked if AI was not significantly used.
- AI Assisted Code
Mainly written by a human; AI used for autocomplete or partial generation under full human supervision. - AI Generated Code
Mainly generated by AI, reviewed and approved by a human before this MR was created. - Vibe Coded
Generated by AI and only functionally reviewed before this MR was created.
Closes #3586338