protected 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.

        // Druppal 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;
            }
        }
        // For Drupal 8 (and we're predicting beyond) the schema version is in the
        // key_value store.
        elseif ($connection->schema()->tableExists('key_value')) {
            $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);
        } else {
            $version_string = false;
        }

        return $version_string ? substr($version_string, 0, 1) : false;
    }
protected 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.

        // Druppal 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;
            }
        }
        // For Drupal 8 (and we're predicting beyond) the schema version is in the
        // key_value store.
        elseif ($connection->schema()->tableExists('key_value')) {
            $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);
        } else {
            $version_string = false;
        }

        return $version_string ? substr($version_string, 0, 1) : false;
    }
protected 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. // Druppal 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 ; } } // For Drupal 8 (and we're predicting beyond) the schema version is in the // key_value store. elseif ( $ connection -> schema ( ) -> tableExists ( 'key_value' ) ) { $ 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 ) ; } else { $ version_string = false ; } return $ version_string ? substr ( $ version_string , 0 , 1 ) : false ; }
Determine what version of Drupal the source database contains, copied from \Drupal\migrate_upgrade\MigrationCreationTrait

@param \Drupal\Core\Database\Connection $connection

@return int|FALSE
Determine what version of Drupal the source database contains copied from \ Drupal \ migrate_upgrade \ MigrationCreationTrait