TYPO3

Importing content from TYPO3 7.6 into v14 with a script

6 min read

From 7.6 to v14 by script

Hi folks,

My own website hoja.in was running on TYPO3 7.6 in classic mode until this year. Flux and fluidpages for the page templates, realurl for the URLs, powermail for the contact form. It worked, but nobody should run 7.6 in 2026. So I moved it to TYPO3 14.3 in a fresh Composer project with DDEV. In this post I share the part which surprised me the most: upgrading the old database would have been much more work than simply importing its content with a script.

Problems I faced

The normal way is an in-place upgrade, one LTS at a time. For 7.6 that means 7.6 → 8.7 → 9.5 → 10.4 → 11.5 → 12.4 → 13.4 → 14.3. Seven hops, each with its own PHP version, its own Composer setup and its own upgrade wizards. And for my site, several extensions had no future at all:

  • flux, fluidpages, fluidcontent and vhs were carrying the page templates and backend layouts.
  • realurl never got a release for TYPO3 9 or later; core site configuration and slugs replaced it.
  • powermail had no release for v14 at the time, so the contact form had to become an EXT:form form.
  • The page type “External URL” used the field pages.url. In v14 this field is removed (Breaking-17406) and the renamed page type “Link” uses pages.link.

Then I counted the real content. The live site had 19 pages in the tree from the site root down, 10 content elements which the one-page template really rendered, and 6 file references. For such a small amount of data, walking it through seven hops just to throw away flux at the end was not sensible. I was like a person carrying a sofa up seven floors to throw it out of the window on the top floor 🙂

So the decision was: fresh TYPO3 14.3 Composer project, a new sitepackage with PAGEVIEW and a site set, and a one-off script that copies the content over.

Solution

Step 1: put the old database next to the new one

DDEV can hold more than one database on the same server. I added a post-start hook in a separate .ddev/config.myport.yaml that creates a scratch database called legacy, and imported the live dump into it:

hooks:
  post-start:
    - exec: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS legacy CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL ON legacy.* TO 'db'@'%';"
      service: db
ddev restart
ddev import-db --database=legacy --file=hojain5_hojain.sql

Now the v14 installation uses the database db as usual, and the old 7.6 data sits read-only in legacy.

Step 2: a plain PHP script that boots TYPO3

I did not write a Symfony command for this. The import runs a few times during the migration and then never again, so I did not want it to live inside the sitepackage forever. The script sits in .project-migration/import/import-legacy.php, boots TYPO3 in CLI mode, and opens the old database with a second, plain mysqli connection:

<?php

declare(strict_types=1);

use TYPO3CMSCoreCoreBootstrap;
use TYPO3CMSCoreCoreSystemEnvironmentBuilder;
use TYPO3CMSCoreDatabaseConnectionPool;
use TYPO3CMSCoreUtilityGeneralUtility;

$classLoader = require dirname(__DIR__, 2) . '/vendor/autoload.php';
SystemEnvironmentBuilder::run(0, SystemEnvironmentBuilder::REQUESTTYPE_CLI);
Bootstrap::init($classLoader);

const ROOT_PAGE = 6;

$legacy = new mysqli('db', 'db', 'db', 'legacy');
$legacy->set_charset('utf8mb4');
$pool = GeneralUtility::makeInstance(ConnectionPool::class);

It runs with ddev exec php .project-migration/import/import-legacy.php. After Bootstrap::init() the whole v14 API is available: ConnectionPool, TCA, SlugHelper, the FAL storage. If the import grows or a team needs it again, a proper command with #[AsCommand] would be the cleaner home. For a one-off, a script was enough.

Step 3: collect the page tree and copy pages with their uids

The script walks the tree below the old site root (page 6) level by level, then inserts every page with its original uid. Keeping the uids was important for me: internal links of the form t3://page?uid=… in bodytext and link fields keep pointing to the right page without any rewriting. The interesting line is the Breaking-17406 migration:

foreach ($legacyPages as $p) {
    $url = $p['url'];
    if ((int)$p['doktype'] === 3 && str_contains($url, 'blog.hoja.in')) {
        // The blog moves from the subdomain into /blog of this installation
        $url = '/blog/';
    }
    $pages->insert('pages', [
        'uid' => (int)$p['uid'],
        'pid' => (int)$p['pid'],
        'title' => $p['title'],
        'doktype' => (int)$p['doktype'],
        'hidden' => (int)$p['hidden'],
        'sorting' => (int)$p['sorting'],
        'is_siteroot' => (int)$p['uid'] === ROOT_PAGE ? 1 : 0,
        // Breaking-17406: pages.url was replaced by the typolink field "link"
        'link' => $url,
        'backend_layout' => (int)$p['uid'] === ROOT_PAGE ? 'pagets__Default' : '',
        // ... more fields, shortened here
    ]);
}

In an in-place upgrade the wizard “Migrate links of pages of type link” would do this. Since I was not upgrading, I had to do it myself. The old blog link page pointed to blog.hoja.in, and the blog now lives under /blog/ on the same domain, so it became a relative link.

Slugs did not exist in 7.6. Instead of inventing them, the script uses the core SlugHelper with the TCA configuration of pages.slug, exactly as the backend would do it, and makes them unique with buildSlugForUniqueInSite().

Step 4: content, the contact form and files

Content elements are copied field by field with their uids too. Two rules matter here. First, the flux carousel in colPos 18181 is skipped, because it never rendered on the live site (my smoke baseline proved this). Second, the powermail plugin is replaced by the EXT:form plugin, and any other plugin stops the import instead of silently disappearing:

if ((int)$c['uid'] === POWERMAIL_CONTENT_UID) {
    $row['CType'] = 'form_formframework';
    $row['pi_flexform'] = $formFlexForm; // points to EXT:sitepackage/Resources/Private/Forms/contact.form.yaml
} elseif ($c['CType'] === 'list') {
    throw new RuntimeException('Unmapped plugin ' . $c['list_type'] . ' in tt_content:' . $c['uid']);
}

For files, the script creates the fileadmin storage if needed, looks up each old file by its identifier with $storage->getFile() and writes new sys_file_reference rows against the new sys_file uids. Old image paths in bodytext (/html/assets/img/) are rewritten to /fileadmin/portfolio/ with a simple strtr().

Why not DataHandler?

I thought about writing everything through DataHandler. It gives you history, reference index updates and all hooks. But DataHandler assigns new uids, and I wanted the original ones. It also needs a backend user context and would log 35 “record created” entries for content that already existed for years. For a fresh, empty installation the direct inserts through ConnectionPool were simpler and easier to check. The price is that the reference index does not know about the new rows until you update it, so that belongs on the checklist after the import (ddev typo3 referenceindex:update).

If you import into an installation that already has editors and content, my advice is the opposite: use DataHandler, accept new uids, and keep a uid map for link rewriting.

Re-runnable, and honest about what it skips

The script truncates pages, tt_content and sys_file_reference at the start. That makes it re-runnable, which helped a lot while I fixed details. It also makes it dangerous, so I took a database dump before every run. The AI agent I used for the legwork (Claude Code with my project migration plugin) even had a guard hook that blocks database writes without a fresh dump. Good habit, even when you work alone.

A review of the first version found real problems. The pages were owned by the _cli_ user instead of my admin account, so the script now looks up the first real admin. I also wrote down every field I did not copy (starttime, endtime, fe_group and others) and checked that they were empty or default on every imported row. A script that skips data silently is worse than no script.

At the end it prints one summary line, so every run shows at a glance whether something went missing:

Imported 19 pages, 10 content elements, 6 file references.

The final proof was the smoke test: the URLs captured from the old 7.6 site before the migration returned the same status and the same content on v14.

If your old site is small and full of dead extensions, try counting your content before planning seven hops. Sometimes the boring script is the shortest road. Cheers!

Further reading

Leave a comment

Your email address will not be published.