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, and SchedulerHooks).
  • Adding Drupal 10 procedural bridges for attribute-based hooks that Drupal 10 does not discover: a #[LegacyHook] hook_theme() bridge (so theme hooks such as ai_context_overview render instead of returning HTTP 500), and extending the hook_modules_installed() bridge to also invoke SchedulerHooks (so Scheduler setup and Content Moderation sync run).
  • Adding cross-version entity original-value handling.
  • Repairing NULL revision 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 @group annotations required by Drupal 10 test discovery across the main module and the ai_context_document_loader submodule.

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

  1. Install beta2 on a Drupal 10.5+ project.
  2. Update to beta3.
  3. Switch to this fork or create a patch from it.
  4. 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

Edited by Kristen Pol

Merge request reports

Loading