d7_import
# D7 Content Import
A Drupal 11 module for importing content exported from Drupal 7 sites.
## Overview
This module provides a way to migrate content from Drupal 7 to Drupal 11 without going through the standard D7 → D8 → D9 → D10 → D11 migration path. It works by:
1. Exporting content from D7 as XML files (using the included export script)
2. Importing the XML files into D11 (using this module)
## Features
- Preserves node IDs (NIDs), term IDs (TIDs), and file IDs (FIDs) — auto-increment sequences are repaired after forced IDs so new entities don't collide
- Auto-creates vocabularies and content types from the import data
- Auto-creates fields based on D7 field types, including cardinality inferred from actual usage and `allowed_values` collected from list fields
- Automatically registers every imported field as a component on the default form and view displays
- Resolves `entity_reference` target types (node / taxonomy_term / user) and handler settings from the originating D7 field type
- Imports taxonomy terms with full hierarchy, using topological ordering so parents exist before children (cycles and orphans attach at the root with a warning)
- Imports files and file references, resolving `public://`, `private://` and `temporary://` source URIs; missing source files are skipped with a warning rather than creating
broken managed-file rows
- Imports menus and menu links
- Imports URL aliases
## Installation
1. Copy the `d7_import` folder to your D11 site's `modules/custom` directory
2. Enable the module: `drush en d7_import`
3. Access the import form at `/admin/content/d7-import`
## D7 Export
Before importing, you need to export your D7 content:
1. Copy `d7_export_script/export_content.php` to your D7 site root
2. Run with Drush (for multisite, specify the site):
```bash
drush -l yoursite.com php-script export_content.php
3. Find the exported XML files in sites/default/files/export/[site_name]/
Import Process
The import should be done in order:
1. Vocabularies - Creates empty vocabulary entities
2. Terms - Populates terms with preserved TIDs (topologically ordered by parent)
3. Content Types/Fields - Creates node types, field configurations, and default form/view display components
4. Files - Creates file entities with preserved FIDs
5. Nodes - Creates nodes with preserved NIDs
6. Aliases - Creates URL path aliases
7. Menus - Creates menus and menu links
Drush Commands
drush d7-import:all /path/to/export/ # Run the full import
drush d7-import:vocabularies /path/to/taxonomy.xml
drush d7-import:terms /path/to/taxonomy.xml
drush d7-import:content-types /path/to/nodes.xml
drush d7-import:files /path/to/files.xml --source-files=/path/to/d7/files
drush d7-import:nodes /path/to/nodes.xml
drush d7-import:aliases /path/to/aliases.xml
drush d7-import:menus /path/to/menus.xml
drush d7-import:purge --all # or --nodes / --terms / --files / --menus / --aliases / --vocabularies
d7-import:all accepts --skip-* flags for each stage, plus --source-files to copy managed files.
Field Type Mapping
┌─────────────────────────┬──────────────────────────────────────────┐
│ D7 Field Type │ D11 Field Type │
├─────────────────────────┼──────────────────────────────────────────┤
│ text │ string │
├─────────────────────────┼──────────────────────────────────────────┤
│ text_long │ text_long │
├─────────────────────────┼──────────────────────────────────────────┤
│ text_with_summary │ text_with_summary │
├─────────────────────────┼──────────────────────────────────────────┤
│ image │ image │
├─────────────────────────┼──────────────────────────────────────────┤
│ file │ file │
├─────────────────────────┼──────────────────────────────────────────┤
│ taxonomy_term_reference │ entity_reference (target: taxonomy_term) │
├─────────────────────────┼──────────────────────────────────────────┤
│ entityreference │ entity_reference (target: node) │
├─────────────────────────┼──────────────────────────────────────────┤
│ node_reference │ entity_reference (target: node) │
├─────────────────────────┼──────────────────────────────────────────┤
│ user_reference │ entity_reference (target: user) │
├─────────────────────────┼──────────────────────────────────────────┤
│ link_field │ link │
├─────────────────────────┼──────────────────────────────────────────┤
│ date/datetime/datestamp │ datetime │
├─────────────────────────┼──────────────────────────────────────────┤
│ list_text │ list_string │
├─────────────────────────┼──────────────────────────────────────────┤
│ list_integer │ list_integer │
├─────────────────────────┼──────────────────────────────────────────┤
│ list_boolean │ boolean │
├─────────────────────────┼──────────────────────────────────────────┤
│ number_integer │ integer │
├─────────────────────────┼──────────────────────────────────────────┤
│ number_decimal │ decimal │
├─────────────────────────┼──────────────────────────────────────────┤
│ number_float │ float │
├─────────────────────────┼──────────────────────────────────────────┤
│ email │ email │
├─────────────────────────┼──────────────────────────────────────────┤
│ telephone / phone │ telephone │
├─────────────────────────┼──────────────────────────────────────────┤
│ video_embed_field │ video_embed_field │
├─────────────────────────┼──────────────────────────────────────────┤
│ geofield │ geofield │
├─────────────────────────┼──────────────────────────────────────────┤
│ addressfield │ address │
└─────────────────────────┴──────────────────────────────────────────┘
List fields (list_string, list_integer) collect their allowed_values from the D7 field definition when available.
Source Files Path
If you want to copy the actual files (images, documents, etc.) during import, provide the path to your D7 files directory in the import form. For example:
/var/www/d7site/sites/default/files
Leave empty to only create file entities without copying files.
Limitations
- Users are not imported (nodes are assigned to UID 1 if original user doesn't exist)
- Revisions are not imported
- Some complex field types may need manual handling
- Text format names must match between D7 and D11 (or will default to basic_html)
Troubleshooting
Entity ID conflicts
If you get errors about duplicate IDs, the import will skip those items. Run the import again to retry failed items. After forced IDs are written, the auto-increment
sequences on node, taxonomy_term_* and file_managed are repaired so subsequent entity creation will not collide.
Field type not supported
Check the logs for "unknown type" messages. You may need to extend FieldTypeMapper.php for custom field types.
Missing source files
When a source-files path is provided but an individual file cannot be found, the importer logs a warning and skips the row rather than creating a managed-file entity that
points at a non-existent URI.
Orphan or cyclic taxonomy parents
Terms whose parent cannot be resolved (missing or part of a cycle) are attached to the vocabulary root and a warning is logged.
Memory issues with large imports
For sites with thousands of nodes, consider importing in batches or increasing PHP memory limit. The alias importer resets the entity cache every 500 rows to keep memory
bounded.
Contributing
This module is intended to be contributed to Drupal.org. Feedback and patches welcome!
License
GPL-2.0-or-later