function MigrationConfigurationTrait::getLegacyDrupalVersion
Same name in other branches
- 9 core/modules/migrate_drupal/src/MigrationConfigurationTrait.php \Drupal\migrate_drupal\MigrationConfigurationTrait::getLegacyDrupalVersion()
- 8.9.x 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()
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.
6 calls to MigrationConfigurationTrait::getLegacyDrupalVersion()
- CredentialForm::validateForm in core/
modules/ migrate_drupal_ui/ src/ Form/ CredentialForm.php - Form validation handler.
- CredentialFormTest::getDestinationSiteCredentials in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ CredentialFormTest.php - Creates an array of destination site credentials for the Credential form.
- CredentialFormTest::getSourceBasePath in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ CredentialFormTest.php - Gets the source base path for the concrete test.
- MigrateUpgradeTestBase::assertUpgrade in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ MigrateUpgradeTestBase.php - Asserts the upgrade completed successfully.
- MigrateUpgradeTestBase::getCredentials in core/
modules/ migrate_drupal_ui/ tests/ src/ Functional/ MigrateUpgradeTestBase.php - Creates an array of credentials for the Credential form.
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();
} catch (DatabaseExceptionWrapper) {
// All database errors return FALSE.
}
}
return match (TRUE) { !isset($version_string) => FALSE,
(int) $version_string >= 6000 => substr($version_string, 0, 1),
(int) $version_string >= 1000 => '5',
default => FALSE,
};
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.