INTEREST JOURNAL DRUPAL & WEB

Drupal 12 beta2 Database Updates: Web Workflow, Restore and a Limited PHP Fallback

About 1,000 words 5 min read

Japanese ↗
On this page

Checking database updates without Drush

The previous CLI comparison found working core status and cache commands, but no registered updatedb command in this Drupal 12.0.0-beta2 environment. This follow-up tests the documented web updater and a narrowly scoped PHP fallback experiment.

Authenticated web updates succeeded. A controlled failure and restoration from backup were also verified. The custom PHP experiment is not an officially recommended update procedure or a general-purpose updater.

A separate copy with synthetic pending updates

Checks took place on November 7, 2026 with Drupal 12.0.0-beta2 and PHP 8.5.12 in DDEV on a MacBook. The database was exported from interest-dr12, with code and files copied into a separate interest-dr12-db-lab project. Database updates ran only in the copy.

The source database had no pending updates or post-updates. Simply seeing “no updates” would not test execution. A synthetic cli_db_lab module was therefore installed only in the copy. After installation, update 12001 was added to create a test table, along with a post-update completion marker. Later fixtures added a deliberately failing 12002, a dependent field addition in 12003 and another post-update.

This was not an upgrade from an older core release. Synthetic hooks tested execution, tracking, stopping and restoration.

Documented route: authenticated update.php

The official core-update instructions ↗ describe Drush and web-based update.php routes for database updates. The copied site’s updater rejected anonymous access. After administrator authentication, the browser could review requirements, select updates, execute them and display results. update_free_access was not enabled.

The first run displayed two fixture operations. After execution, the test table existed, its module schema version was 12001, the post-update marker was set and no updates remained pending.

What remains after a failure?

Update 12002 then inserted one test row and deliberately threw an exception. The web result reported failure. Schema version remained 12001; updates 12002 and 12003 stayed pending. The dependent field and second post-update did not run.

The row written before the failure remained. This did not roll back the entire update workflow. Retrying without understanding partial writes may duplicate work. Advancing schema history manually would hide an unfinished operation rather than complete it.

This failure was created in test code. It is not a report of the same defect in core or a real contributed module.

Recovery: restore the pre-update backup

The copied database was restored from its pre-update SQL backup. The test table disappeared, schema version returned to 8000 and the first post-update became pending again. Node and user counts remained 60 and 2.

These are illustrative paths. Confirm the project and an existing destination outside the web root before running equivalent commands.

# Confirm the target DDEV project.
ddev describe

# Save outside the web root.
ddev export-db --file=/path/outside-web/db-before.sql.gz

# Replaces the target database; performed only in the copy here.
ddev import-db --file=/path/outside-web/db-before.sql.gz

SQL backups do not restore code or uploaded files. Recovery also requires matching versions of those files. Core stayed fixed in this experiment, with copied code and fixture versions tracked separately. See DDEV commands and official database-update troubleshooting ↗ .

Custom PHP fallback: not an officially recommended procedure

A custom PHP implementation explored what a fallback would require if browser access and Drush were unavailable.

This is this site’s limited experiment, not an officially recommended update procedure or a supported general-purpose CLI. It is not presented as code to apply directly to production or arbitrary module updates.

The script lives outside the web root and refuses other projects, core versions and unreviewed hooks. Its allowlist includes only fixture updates 12001–12003 and two known post-updates. It rejects unreviewed dependencies and requirement errors or warnings, and offers a plan before execution.

Components used in the experiment

The custom script ran on PHP 8.5.12 using components already included with Drupal. No additional library was installed.

  • Composer’s autoloader loads Drupal and dependency classes.
  • Symfony HttpFoundation’s Request represents the target site URL for Drupal initialization.
  • Drupal core’s update APIs use UpdateKernel for the update environment and DatabaseUpdate::doOne() and related processing for the fixture updates and post-updates.

The previously discussed vendor/bin/dr uses Symfony Console. This custom PHP script was not implemented as a Console command.

It does not directly edit schema history or mark failed operations complete. Using core internals does not establish the coverage, compatibility or maintainability of the documented workflow.

The first implementation stopped because it referenced the old REQUIREMENT_ERROR constant, which was undefined in this beta2. It was corrected to use the included RequirementSeverity enum. This also illustrates why older PHP examples cannot be assumed compatible.

The corrected runner stopped with exit code 1 on the intentional fixture failure, without running later updates or post-updates. After reviewing and correcting the failing fixture to account for its partial write, another run completed the remaining updates and both post-updates.

Final checks showed schema version 12003, one test row, the dependent field, and no pending updates or post-updates. A subsequent run planned and executed zero hooks.

On failure the custom runner leaves maintenance enabled. After successful checks, maintenance was explicitly disabled. Long-running batches, complex dependencies, concurrent operations, other databases and service changes during real updates remain outside this small fixture’s coverage.

Results and limits by method

Method Observed result Role and limits
Web update.php Update and post-update succeeded; controlled failure reported Documented route, with authentication and required permissions retained
Core CLI updatedb Not registered in the previous inspection Describes this environment, not all Drupal 12 installations
Drush updatedb Not executed Drush is absent; this is not a new compatibility assessment
DDEV database restore Successfully returned to the pre-update state Recovery, not an updater; matching code and files also matter
Custom PHP fixture runner Verified stopping, success after correcting the cause, and a zero-hook rerun Unofficial experiment, not a general-purpose replacement

The practical findings are that the authenticated web route worked in this beta2 and a backup could restore the copied database after failure. The PHP experiment explores responsibilities involved in implementing an alternative.

Drupal 11 and 12 checks and samples · CLI comparison · Drupal 12 beta record

Drupal 11 & 12 checks and samples ↗