Migrating Legacy Drupal 7 to Drupal 10 and 11 (and Fixing “The website encountered an unexpected error”)

Engineering team mapping legacy Drupal 7 content types and URL redirect matrices on a whiteboard
Auditing custom Drupal 7 fields and dead contrib modules before writing a single migration YAML file saves months of rework. Source: Unsplash.

Every few weeks in 2026, an engineering lead opens a ticket with the same realization: their eleven-year-old Drupal 7 site is past official end-of-life, their extended-support vendor just doubled renewal fees, and the first staging run of a Drupal 7 to Drupal 11 migration unexpected error dropped the site onto a blank white page with one terse line: The website encountered an unexpected error. Try again later.

If you’ve lived inside long-term legacy software maintenance, you recognize that moment. Stakeholders still assume moving from Drupal 7 to Drupal 10 or 11 works like a minor security patch. Meanwhile, once engineers spin up a Symfony-backed build, any mismatch between old data assumptions, PHP 8.3 strict typing, and cached service containers triggers the white screen before anyone sees a stack trace.

This guide explains how veteran Drupal teams survive that replatform without porting dead modules, protect search rankings at cutover, and trace that unexpected error in minutes.

Why Moving Off Drupal 7 Is a Replatform, Not an Update

There is no in-place upgrade from Drupal 7 to modern Drupal. You aren’t applying schema patches to an existing codebase; you’re building a new application on Symfony, Twig, strict PHP 8.3, and Composer dependency management, then pulling content out of the old database through the Migrate API.

Drupal 7 ran on procedural hooks, .info files, PHPTemplate .tpl.php overrides, and global state stuffed into the variable table. Updating modules meant unpacking tarballs into sites/all/modules/contrib and hoping update.php finished. Modern Drupal flips that stack: packages resolve through composer.lock, configuration lives in Git-tracked YAML, and requests flow through Symfony’s HttpKernel and compiled dependency injection container.

That break forces an early call: land on Drupal 10.3+ first, or jump straight to Drupal 11?

Stopping at Drupal 10.3 or 10.4 makes sense when a critical contrib module lacks a stable Drupal 11 release, or when your team relies on core migrate_drupal and migrate_drupal_ui alongside older contrib migration helpers. Drupal 10.3+ provides a stable landing pad with Recipes and CKEditor 5; once everything runs cleanly there, moving to Drupal 11 behaves like a normal Composer upgrade.

Going straight to Drupal 11 makes more sense when your content model is clean (nodes, users, taxonomy, media) and you’re writing custom YAML migrations with migrate_plus and migrate_tools anyway. Skipping Drupal 10 avoids a second QA cycle and lands you straight on PHP 8.3+ and Symfony 7. Before committing, decide whether to keep Twig rendering or decouple the frontend using our decoupled Drupal relaunch agency checklist. And if your legacy site is an internal portal nobody wants to maintain, review an open-source intranet CMS comparison before spending six figures replatforming the wrong tool.

Auditing a Decade-Old Drupal 7 Database Before Touching Migrate API

Nothing blows a migration budget faster than migrating ten years of database junk. Half the modules enabled on legacy sites exist because someone followed classic Drupal 7 project checklists in 2014, bolted on three gallery modules in 2017, and never uninstalled the old ones.

Before writing any migration YAML, clone production onto staging and run a blunt SQL inventory for enabled modules, table bloat, and executable PHP buried inside database rows.

SELECT name, schema_version, filename FROM system
WHERE type = 'module' AND status = 1 ORDER BY filename;

SELECT table_name, table_rows,
       ROUND((data_length + index_length) / 1024 / 1024, 2) AS size_mb
FROM information_schema.tables WHERE table_schema = DATABASE()
ORDER BY (data_length + index_length) DESC LIMIT 12;

SELECT entity_id, bundle FROM field_data_body WHERE body_format = 'php_code';
SELECT vid, id FROM views_display WHERE display_options LIKE '%views_php%';

Those last two queries uncover the nastiest legacy landmines. Old Drupal 7 sites are infamous for php_filter blocks and views_php fields where someone pasted raw eval() PHP into a View display in 2016. Drupal 10 and 11 refuse to execute PHP stored in database text fields. Every snippet you find must be rewritten as a Twig template, Views field plugin, or service class.

Next, strip dead weight from your staging copy so Migrate API doesn’t chew through gigabytes of trash. On decade-old sites with default revisioning, node_revision and field_revision_* tables often outnumber live nodes twenty to one. Nobody needs draft revision #412 of a 2015 press release. Truncate watchdog, sessions, batch, and cache_* tables on the source clone, prune zombie drafts, and reconcile file_managed against file_usage so you don’t waste hours migrating orphaned PDFs. Audit rules_config and Field Collections early, too; half the Rules in legacy databases fire on retired content types.

Mapping Legacy Drupal 7 Modules to Drupal 10 and 11

Teams stall when they hunt Packagist for literal one-to-one replacements for every Drupal 7 module. Many old contrib projects moved into core, while others gave way to cleaner schemas. Use this mapping when turning your audit into a modern composer.json.

Legacy Drupal 7 Module Drupal 10 and 11 Replacement Migration Reality Check
Field Collection Paragraphs (with Entity Reference Revisions) Run two passes: import child paragraphs first, then attach target and revision IDs on parent nodes via migration_lookup.
Features Core CMI (drush cex and drush cim) Stop packaging config as custom modules. Commit YAML to Git and handle environment overrides with config_split.
Rules ECA (Event – Condition – Action) or EventSubscribers Rebuild only active workflows. Complex business logic belongs in tested PHP subscribers instead of click-ops UIs.
Panels and Panelizer Core Layout Builder Skip automated Panelizer migrations. Map old page variants cleanly onto Layout Builder section templates.
Node Reference and Entity Reference Core Entity Reference Built into core. Normalize legacy reference fields into standard target-type handlers during migration.
PHP Filter and Views PHP Twig templates, Block plugins, Views field plugins No automated path. Extract every database-stored PHP snippet into version-controlled code.
File Entity and Media 7.x Core Media and Media Library Migrate files into typed Media entities and rewrite inline media tokens with a custom process plugin.
Global Redirect and Pathauto Core path aliases, Redirect, and Pathauto Keep Pathauto for new URLs, then offload bulk legacy 301 maps to Nginx so bots never hammer PHP-FPM.

The hard work isn’t copying body fields; it’s untangling nested structures like Field Collections and inline media tokens. Don’t jam Field Collection conversions into one monolithic PHP plugin. Put child paragraphs in their own migration YAML, verify row counts in SQL, then wire them into parent nodes via sub_process and migration_lookup. When row 18,400 fails validation, isolated migrations let you roll back one piece without wiping the whole run.

Protecting Search Traffic With a Bulletproof Nginx 301 Map

Migrations rarely fail loudly on launch day because a card margin looks wrong. They fail quietly three weeks later when organic traffic craters 40 percent because old URLs started returning 404s. Even with Pathauto configured cleanly on Drupal 11, merging content types, pruning taxonomy vocabularies, or retiring /node/1234 paths creates URL drift.

The zero-downtime URL discipline from our Concrete5 to Concrete CMS migration guide applies directly here: freeze your legacy URL inventory early and test every high-traffic path on staging before touching DNS.

Export every alias from Drupal 7 before retiring the old database:

SELECT CONCAT('/', alias) AS legacy_path, CONCAT('/', source) AS internal_source
FROM url_alias WHERE language IN ('und', 'en') ORDER BY pid ASC
INTO OUTFILE '/tmp/d7_url_aliases.tsv'
FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n';

Reconcile those paths against your new Drupal 11 aliases on staging, and resist stuffing 50,000 rows into Drupal’s redirect table unless editors need to edit them in the UI. Every Drupal-handled redirect wakes PHP-FPM, boots Symfony, queries MySQL, and returns a 301. During post-launch recrawls, that burns CPU for nothing.

Compile static legacy redirects into an Nginx map block inside http instead. Nginx hashes the map in memory and serves 301s in microseconds before PHP wakes up:

map_hash_max_size 131072;
map_hash_bucket_size 128;

map $request_uri $legacy_drupal_redirect {
    default "";
    /products/old-widget-2016 /catalog/widgets/modern-widget;
    /news/press-releases/q4-update /press/q4-update;
    /resources/guide.pdf /sites/default/files/2026-01/guide.pdf;
}

# Inside your server block:
if ($legacy_drupal_redirect != "") {
    return 301 $scheme://$host$legacy_drupal_redirect;
}

Run nginx -t, reload, and crawl your top 1,000 Search Console landing pages against staging. Every URL should return HTTP 200 or a single-hop 301 to a 200 target.

Git repository history and Composer dependency graph during a major CMS upgrade
Clean Composer dependency pinning and Drush migration rollbacks keep Drupal 10/11 upgrades repeatable. Source: Unsplash.

Debugging “The website encountered an unexpected error. Try again later.”

Sooner or later during a Drupal 7 to Drupal 11 migration, right after composer update, drush cim, or enabling a ported module, your browser hits that white screen:

The website encountered an unexpected error. Try again later.

That message isn’t the bug. Drupal catches uncaught PHP Throwable exceptions inside its final exception subscriber and hides stack traces so visitors never see filesystem paths or SQL fragments. The mistake is blindly clearing caches before reading the real exception.

On local or staging hosts, enable verbose logging in web/sites/default/settings.local.php so Drupal prints the exact file, line number, and stack trace to the page:

<?php
$config['system.logging']['error_level'] = 'verbose';
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
$settings['cache']['bins']['render'] = 'cache.backend.null';

Confirm settings.php uncomments its bottom settings.local.php include, and keep settings.local.php in .gitignore so verbose traces never reach production.

On servers where you won’t expose stack traces over HTTP, inspect watchdog over SSH with Drush:

drush ws --severity=Error --count=20 --extended
drush ws --type=php --severity=Error --count=10 --extended

Watch for the bootstrap blind spot: when a crash hits while compiling the Symfony container (a malformed *.services.yml file, missing class autoload, or dead database socket), Drupal never boots far enough to log to watchdog. When drush ws shows nothing new or Drush itself explodes, check PHP-FPM and Nginx logs directly:

tail -n 80 /var/log/php8.3-fpm.log
tail -n 80 /var/log/nginx/error.log

Once you patch the broken code or YAML, run database updates and clear caches in order:

drush updb -y
drush cr

What if drush cr crashes with the exact same error because the compiled container cached in cache_container references a deleted class or renamed service? Break that deadlock by truncating bootstrap caches directly in SQL and regenerating Composer’s classmap:

drush sqlq "TRUNCATE TABLE cache_container; TRUNCATE TABLE cache_bootstrap; TRUNCATE TABLE cache_discovery;"
composer dump-autoload -o
drush cr

If even drush sqlq won’t boot because of a broken Drush plugin, run those three TRUNCATE statements in the plain mysql client, or temporarily set $settings['rebuild_access'] = TRUE; in settings.local.php, visit /core/rebuild.php, and flip rebuild_access straight back to FALSE.

Symfony Container Mismatches, PHP 8.3 Strictness, and Broken Config Splits

Once you pull the stack trace from drush ws or PHP-FPM logs, nearly every post-migration unexpected error falls into four predictable buckets.

Stale Symfony Service Definitions After Composer Updates

Drupal 10 and 11 regularly drop deprecated service IDs and tighten constructor signatures. After composer update, expect ServiceNotFoundException or constructor TypeError failures in custom modules. Common culprits include removed aliases like entity.manager (replaced by entity_type.manager), changed parent constructors in custom controllers or forms, or a mymodule.services.yml passing arguments out of order. Inspect the parent constructor in web/core/, align your create(ContainerInterface $container) factory and service YAML, then run composer dump-autoload -o and drush cr.

PHP 8.3 Type Errors and Runtime Memory Limits

Code ported quickly from Drupal 7 collides with PHP 8.3 strictness. Passing null into strlen(), strpos(), or htmlspecialchars() triggers deprecations or strict TypeError failures, while subclassed methods missing Symfony 7 return types fail at compile time. Silent worker deaths are just as common: compiling a large container alongside deep Paragraphs trees blows past a 128M PHP memory limit fast. The mechanics of diagnosing PHP 8 memory exhaustion errors carry straight across PHP CMS stacks, and before sending live traffic to Drupal 11, spend twenty minutes tuning PHP-FPM worker limits so post-launch crawls don’t starve workers and trigger 502s.

Broken Config Splits and Ghost Modules in core.extension

This failure bites right before launch. Someone runs composer remove on a dev or migration module like migrate_tools or devel without running drush pmu first, or deploys a config_split setup referencing a directory absent on production. On the next cache rebuild or drush cim, Drupal tries to boot services for a module still listed in core.extension.yml whose files are gone, crashing every route.

Don’t hand-edit the database config table unless you’re completely locked out. Re-require the package briefly, uninstall it cleanly so its hooks clear, export config, and remove it again:

composer require drupal/broken_module
drush pmu broken_module -y
drush cex -y
composer remove drupal/broken_module
drush cr

For config_split errors, check state via drush cget config_split.config_split.local and ensure settings.php sets $config['config_split.config_split.local']['status'] = FALSE; on staging and production. One stray TRUE pulling dev modules into a production drush cim drops the site mid-deploy.

Database Schema Drift During Deployment

When drush cim passes locally but throws a DatabaseExceptionWrapper on staging complaining about a missing table or column, a schema update didn’t run before config import. Lock every deploy pipeline to one order: deploy Composer artifacts, run drush updb -y first, run drush cim -y second, and finish with drush cr. Reversing updb and cim guarantees an unexpected error mid-cutover.

Questions Teams Keep Asking Mid-Migration

Should we migrate from Drupal 7 to Drupal 10.3 first or go straight to Drupal 11?

Audit your contrib modules first, not your calendar. If every essential module has a stable Drupal 11 release and you’re writing custom Migrate API YAML anyway, jump straight to Drupal 11 on PHP 8.3. If critical modules still only support Drupal 10, land on Drupal 10.3 or 10.4 first to exit end-of-life Drupal 7 safely, then upgrade to Drupal 11 via Composer once compatible releases ship.

Why does drush cr fail with the exact same unexpected error as the browser?

Drush bootstraps the same Symfony container serving web traffic. When a broken *.services.yml file, missing Composer package, or corrupt container inside cache_container blocks bootstrap, Drush hits the same wall. Truncate cache_container, cache_bootstrap, and cache_discovery in SQL, check /var/log/php8.3-fpm.log for the fatal error, patch the service definition, and run composer dump-autoload -o before retrying drush cr.

Can we reuse our Drupal 7 custom theme and PHPTemplate files on Drupal 11?

No. Drupal 7 used PHPTemplate (.tpl.php), removed in Drupal 8 in favor of Twig (.html.twig). You can keep CSS tokens, brand assets, and layout grids, but templates, preprocess hooks, and library definitions must be rebuilt on a modern base theme like Olivero or a Starterkit subtheme.

How long should we keep the Nginx 301 redirect map after launching Drupal 11?

Keep it active for at least twelve to eighteen months, and there’s little reason to delete it afterward. An in-memory Nginx map with tens of thousands of legacy URLs uses only a few megabytes of RAM and adds negligible latency while rescuing old backlinks and bookmarked PDFs years after launch.

Leave a Comment