1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Identify platforms by their class

This commit is contained in:
Yassine Guedidi 2023-08-05 18:35:09 +01:00
parent c2bfc0f359
commit f48f982025
23 changed files with 185 additions and 100 deletions

View file

@ -4,6 +4,9 @@ namespace Wallabag\CoreBundle\Command;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
@ -138,7 +141,7 @@ class InstallCommand extends Command
$help = '';
// now check if MySQL isn't too old to handle utf8mb4
if ($conn->isConnected() && 'mysql' === $conn->getDatabasePlatform()->getName()) {
if ($conn->isConnected() && $conn->getDatabasePlatform() instanceof MySQLPlatform) {
$version = $conn->query('select version()')->fetchOne();
$minimalVersion = '5.5.4';
@ -150,7 +153,7 @@ class InstallCommand extends Command
}
// testing if PostgreSQL > 9.1
if ($conn->isConnected() && 'postgresql' === $conn->getDatabasePlatform()->getName()) {
if ($conn->isConnected() && $conn->getDatabasePlatform() instanceof PostgreSQLPlatform) {
// return version should be like "PostgreSQL 9.5.4 on x86_64-apple-darwin15.6.0, compiled by Apple LLVM version 8.0.0 (clang-800.0.38), 64-bit"
$version = $conn->query('SELECT version();')->fetchOne();
@ -391,7 +394,7 @@ class InstallCommand extends Command
}
// custom verification for sqlite, since `getListDatabasesSQL` doesn't work for sqlite
if ('sqlite' === $schemaManager->getDatabasePlatform()->getName()) {
if ($connection->getDatabasePlatform() instanceof SqlitePlatform) {
$params = $connection->getParams();
if (isset($params['path']) && file_exists($params['path'])) {

View file

@ -2,6 +2,7 @@
namespace Wallabag\CoreBundle\Doctrine;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
@ -49,7 +50,7 @@ abstract class WallabagMigration extends AbstractMigration implements ContainerA
}
// escape table name is handled using " on postgresql
if ('postgresql' === $this->connection->getDatabasePlatform()->getName()) {
if ($this->connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
return '"' . $table . '"';
}