Skip to content
Snippets Groups Projects
Verified Commit 48814794 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3437178 by immaculatexavier, quietone, smustgrave, alexpott: Simplify...

Issue #3437178 by immaculatexavier, quietone, smustgrave, alexpott: Simplify getLegacyDrupalVersion()
parent c5365987
No related branches found
No related tags found
No related merge requests found
......@@ -206,27 +206,23 @@ public static function getLegacyDrupalVersion(Connection $connection) {
// 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.
$version_string = FALSE;
if ($connection->schema()->tableExists('system')) {
try {
$legacy_version_string = $connection
$version_string = $connection
->query('SELECT [schema_version] FROM {system} WHERE [name] = :module', [':module' => 'system'])
->fetchField();
if ($legacy_version_string && $legacy_version_string[0] == '1') {
if ((int) $legacy_version_string >= 1000) {
$version_string = '5';
}
}
else {
$version_string = substr($legacy_version_string, 0, 1);
}
}
catch (DatabaseExceptionWrapper $e) {
// All database errors return FALSE.
}
}
return $version_string;
return match (TRUE) {
!isset($version_string) => FALSE,
(int) $version_string >= 6000 => substr($version_string, 0, 1),
(int) $version_string >= 1000 => '5',
default => FALSE,
};
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment