function MigrationConfigurationTrait::getLegacyDrupalVersion
Same name in other branches
- 9 core/modules/migrate_drupal/src/MigrationConfigurationTrait.php \Drupal\migrate_drupal\MigrationConfigurationTrait::getLegacyDrupalVersion()
- 10 core/modules/migrate_drupal/src/MigrationConfigurationTrait.php \Drupal\migrate_drupal\MigrationConfigurationTrait::getLegacyDrupalVersion()
- 11.x core/modules/migrate_drupal/src/MigrationConfigurationTrait.php \Drupal\migrate_drupal\MigrationConfigurationTrait::getLegacyDrupalVersion()
Determines what version of Drupal the source database contains.
Parameters
\Drupal\Core\Database\Connection $connection: The database connection object.
Return value
string|false A string representing the major branch of Drupal core (e.g. '6' for Drupal 6.x), or FALSE if no valid version is matched.
8 calls to MigrationConfigurationTrait::getLegacyDrupalVersion()
- CredentialForm::validateForm in core/
modules/ migrate_drupal_ui/ src/ Form/ CredentialForm.php - Form validation handler.
- IdConflictTest::testMigrateUpgradeExecute in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ d6/ IdConflictTest.php - Tests ID Conflict form.
- IdConflictTest::testMigrateUpgradeExecute in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ d7/ IdConflictTest.php - Tests ID Conflict form.
- MigrateUpgradeExecuteTestBase::testMigrateUpgradeExecute in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ MigrateUpgradeExecuteTestBase.php - Executes all steps of migrations upgrade.
- migrate_drupal_migration_plugins_alter in core/
modules/ migrate_drupal/ migrate_drupal.module - Implements hook_migration_plugins_alter().
File
-
core/
modules/ migrate_drupal/ src/ MigrationConfigurationTrait.php, line 204
Class
- MigrationConfigurationTrait
- Configures the appropriate migrations for a given source Drupal database.
Namespace
Drupal\migrate_drupalCode
public static function getLegacyDrupalVersion(Connection $connection) {
// Don't assume because a table of that name exists, that it has the columns
// we're querying. Catch exceptions and report that the source database is
// not Drupal.
// Drupal 5/6/7 can be detected by the schema_version in the system table.
if ($connection->schema()
->tableExists('system')) {
try {
$version_string = $connection->query('SELECT schema_version FROM {system} WHERE name = :module', [
':module' => 'system',
])
->fetchField();
if ($version_string && $version_string[0] == '1') {
if ((int) $version_string >= 1000) {
$version_string = '5';
}
else {
$version_string = FALSE;
}
}
} catch (\PDOException $e) {
$version_string = FALSE;
}
}
elseif ($connection->schema()
->tableExists('key_value')) {
try {
$result = $connection->query("SELECT value FROM {key_value} WHERE collection = :system_schema and name = :module", [
':system_schema' => 'system.schema',
':module' => 'system',
])
->fetchField();
$version_string = unserialize($result);
} catch (DatabaseExceptionWrapper $e) {
$version_string = FALSE;
}
}
else {
$version_string = FALSE;
}
return $version_string ? substr($version_string, 0, 1) : FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.