‪TYPO3CMS  ‪main
Sqlite.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Doctrine\DBAL\Platforms\SQLitePlatform as DoctrineSQLitePlatform;
27 
32 {
40  {
41  $defaultConnection = GeneralUtility::makeInstance(ConnectionPool::class)
42  ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
43  $platform = $defaultConnection->getDatabasePlatform();
44  if (!($platform instanceof DoctrineSQLitePlatform)) {
46  }
47 
48  $this->‪checkDefaultDatabaseCharset($defaultConnection);
49  $this->‪checkDefaultDatabaseServerCharset($defaultConnection);
50  $this->‪checkDatabaseName($defaultConnection);
51 
53  }
59  public function ‪checkDefaultDatabaseCharset(‪Connection $connection): void
60  {
61  // TODO: Implement getDefaultDatabaseCharset() method.
62  }
63 
69  public function ‪checkDefaultDatabaseServerCharset(‪Connection $connection): void
70  {
71  // TODO: Implement getDefaultDatabaseServerCharset() method.
72  }
73 
79  public static function ‪isValidDatabaseName(string $databaseName): bool
80  {
81  return (bool)preg_match('/^[A-Za-z_\/][a-zA-Z0-9\$\/_.-]*$/', $databaseName);
82  }
83 
84  protected function ‪checkDatabaseName(‪Connection $connection): void
85  {
86  if (static::isValidDatabaseName((string)$connection->getDatabase())) {
87  return;
88  }
89 
90  $this->messageQueue->enqueue(
91  new ‪FlashMessage(
92  'The given database name must consist solely of basic latin letters (a-z), digits (0-9)'
93  . ' and underscores (_).',
94  'Database name not valid',
95  ContextualFeedbackSeverity::ERROR
96  )
97  );
98  }
99 }
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\Sqlite\checkDefaultDatabaseCharset
‪checkDefaultDatabaseCharset(Connection $connection)
Definition: Sqlite.php:59
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\Sqlite
Definition: Sqlite.php:32
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\Sqlite\getStatus
‪getStatus()
Definition: Sqlite.php:39
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\Sqlite\checkDatabaseName
‪checkDatabaseName(Connection $connection)
Definition: Sqlite.php:84
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform
Definition: AbstractPlatform.php:29
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\Sqlite\isValidDatabaseName
‪static isValidDatabaseName(string $databaseName)
Definition: Sqlite.php:79
‪TYPO3\CMS\Core\Type\ContextualFeedbackSeverity
‪ContextualFeedbackSeverity
Definition: ContextualFeedbackSeverity.php:25
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform
Definition: AbstractPlatform.php:18
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\AbstractPlatform\$messageQueue
‪FlashMessageQueue $messageQueue
Definition: AbstractPlatform.php:32
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:41
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:27
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Messaging\FlashMessageQueue
Definition: FlashMessageQueue.php:29
‪TYPO3\CMS\Install\SystemEnvironment\DatabaseCheck\Platform\Sqlite\checkDefaultDatabaseServerCharset
‪checkDefaultDatabaseServerCharset(Connection $connection)
Definition: Sqlite.php:69