connectionPool ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); $platform = $defaultConnection->getDatabasePlatform(); if (!($platform instanceof DoctrineSQLitePlatform)) { return $this->messageQueue; } $this->checkDefaultDatabaseCharset($defaultConnection); $this->checkDefaultDatabaseServerCharset($defaultConnection); $this->checkDatabaseName($defaultConnection); return $this->messageQueue; } /** * Checks the character set of the database and reports an error if it is not utf-8. * * @param Connection $connection to the database to be checked */ public function checkDefaultDatabaseCharset(Connection $connection): void { // TODO: Implement getDefaultDatabaseCharset() method. } /** * Checks the character set of the database server and reports an info if it is not utf-8. * * @param Connection $connection to the database to be checked */ public function checkDefaultDatabaseServerCharset(Connection $connection): void { // TODO: Implement getDefaultDatabaseServerCharset() method. } /** * Validate the database name * SQLite does not have any limitation for the length of the database name, * but must start with a letter or _ */ public static function isValidDatabaseName(string $databaseName): bool { return (bool)preg_match('/^[A-Za-z_\/][a-zA-Z0-9\$\/_.-]*$/', $databaseName); } protected function checkDatabaseName(Connection $connection): void { if (static::isValidDatabaseName((string)$connection->getDatabase())) { return; } $this->messageQueue->enqueue( new FlashMessage( 'The given database name must consist solely of basic latin letters (a-z), digits (0-9)' . ' and underscores (_).', 'Database name not valid', ContextualFeedbackSeverity::ERROR ) ); } }