Code changes to support new Doctrine Persistence/DBAL version.
This commit is contained in:
parent
89a62ea32d
commit
bd29e0c4ee
|
@ -24,7 +24,6 @@ return function (CallableEventDispatcherInterface $dispatcher) {
|
|||
|
||||
$helper_set = $console->getHelperSet();
|
||||
$doctrine_helpers = Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($em);
|
||||
$helper_set->set($doctrine_helpers->get('db'), 'db');
|
||||
$helper_set->set($doctrine_helpers->get('em'), 'em');
|
||||
|
||||
$migrationConfigurations = [
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace App\Console\Command\Backup;
|
|||
use App\Console\Command\CommandAbstract;
|
||||
use App\Console\Command\Traits;
|
||||
use App\Entity;
|
||||
use App\Environment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
@ -28,6 +29,7 @@ class BackupCommand extends CommandAbstract
|
|||
use Traits\PassThruProcess;
|
||||
|
||||
public function __construct(
|
||||
protected Environment $environment,
|
||||
protected EntityManagerInterface $em,
|
||||
protected Entity\Repository\StorageLocationRepository $storageLocationRepo,
|
||||
) {
|
||||
|
@ -115,8 +117,7 @@ class BackupCommand extends CommandAbstract
|
|||
|
||||
$path_db_dump = $tmp_dir_mariadb . '/db.sql';
|
||||
|
||||
$conn = $this->em->getConnection();
|
||||
$connParams = $conn->getParams();
|
||||
$connSettings = $this->environment->getDatabaseSettings();
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength
|
||||
$this->passThruProcess(
|
||||
|
@ -124,10 +125,10 @@ class BackupCommand extends CommandAbstract
|
|||
'mysqldump --host=$DB_HOST --user=$DB_USERNAME --password=$DB_PASSWORD --add-drop-table --default-character-set=UTF8MB4 $DB_DATABASE > $DB_DEST',
|
||||
$tmp_dir_mariadb,
|
||||
[
|
||||
'DB_HOST' => $connParams['host'],
|
||||
'DB_DATABASE' => $conn->getDatabase(),
|
||||
'DB_USERNAME' => $connParams['user'],
|
||||
'DB_PASSWORD' => $connParams['password'],
|
||||
'DB_HOST' => $connSettings['host'],
|
||||
'DB_DATABASE' => $connSettings['dbname'],
|
||||
'DB_USERNAME' => $connSettings['user'],
|
||||
'DB_PASSWORD' => $connSettings['password'],
|
||||
'DB_DEST' => $path_db_dump,
|
||||
]
|
||||
);
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace App\Console\Command\Backup;
|
|||
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use App\Console\Command\Traits;
|
||||
use App\Environment;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
|
@ -26,6 +27,7 @@ class RestoreCommand extends CommandAbstract
|
|||
use Traits\PassThruProcess;
|
||||
|
||||
public function __construct(
|
||||
protected Environment $environment,
|
||||
protected EntityManagerInterface $em
|
||||
) {
|
||||
parent::__construct();
|
||||
|
@ -118,7 +120,7 @@ class RestoreCommand extends CommandAbstract
|
|||
}
|
||||
|
||||
$conn = $this->em->getConnection();
|
||||
$connParams = $conn->getParams();
|
||||
$connSettings = $this->environment->getDatabaseSettings();
|
||||
|
||||
// Drop all preloaded tables prior to running a DB dump backup.
|
||||
$conn->executeQuery('SET FOREIGN_KEY_CHECKS = 0');
|
||||
|
@ -127,15 +129,16 @@ class RestoreCommand extends CommandAbstract
|
|||
}
|
||||
$conn->executeQuery('SET FOREIGN_KEY_CHECKS = 1');
|
||||
|
||||
|
||||
$this->passThruProcess(
|
||||
$io,
|
||||
'mysql --host=$DB_HOST --user=$DB_USERNAME --password=$DB_PASSWORD $DB_DATABASE < $DB_DUMP',
|
||||
$tmp_dir_mariadb,
|
||||
[
|
||||
'DB_HOST' => $connParams['host'],
|
||||
'DB_DATABASE' => $conn->getDatabase(),
|
||||
'DB_USERNAME' => $connParams['user'],
|
||||
'DB_PASSWORD' => $connParams['password'],
|
||||
'DB_HOST' => $connSettings['host'],
|
||||
'DB_DATABASE' => $connSettings['dbname'],
|
||||
'DB_USERNAME' => $connSettings['user'],
|
||||
'DB_PASSWORD' => $connSettings['password'],
|
||||
'DB_DUMP' => $path_db_dump,
|
||||
]
|
||||
);
|
||||
|
|
|
@ -54,11 +54,7 @@ class BatchAction
|
|||
};
|
||||
|
||||
if ($this->em->isOpen()) {
|
||||
$this->em->clear(Entity\StationMedia::class);
|
||||
$this->em->clear(Entity\StationPlaylist::class);
|
||||
$this->em->clear(Entity\StationPlaylistMedia::class);
|
||||
$this->em->clear(Entity\UnprocessableMedia::class);
|
||||
$this->em->clear(Entity\StationRequest::class);
|
||||
$this->em->clear();
|
||||
}
|
||||
|
||||
return $response->withJson($result);
|
||||
|
|
|
@ -22,7 +22,7 @@ final class Version20170829030442 extends AbstractMigration
|
|||
|
||||
private function changeCharset(string $charset, string $collate): void
|
||||
{
|
||||
$db_name = $this->connection->getDatabase();
|
||||
$db_name = $this->connection->getDatabase() ?? 'azuracast';
|
||||
|
||||
$sqlLines = [
|
||||
'ALTER TABLE listener CHANGE listener_user_agent listener_user_agent VARCHAR(255) NOT NULL',
|
||||
|
|
|
@ -22,7 +22,7 @@ final class Version20180826043500 extends AbstractMigration
|
|||
|
||||
private function changeCharset(string $charset, string $collate): void
|
||||
{
|
||||
$db_name = $this->connection->getDatabase();
|
||||
$db_name = $this->connection->getDatabase() ?? 'azuracast';
|
||||
|
||||
$tables = [
|
||||
'analytics',
|
||||
|
|
|
@ -31,7 +31,11 @@ class Reader
|
|||
return [];
|
||||
}
|
||||
|
||||
/** @var XMLReader|false $reader */
|
||||
$reader = XMLReader::XML($string, null, \LIBXML_XINCLUDE);
|
||||
if (false === $reader) {
|
||||
return false;
|
||||
}
|
||||
|
||||
set_error_handler(
|
||||
function ($error, $message = '') {
|
||||
|
|
|
@ -8,23 +8,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Xml;
|
||||
|
||||
use Laminas\Config\Exception;
|
||||
use Laminas\Stdlib\ArrayUtils;
|
||||
use Traversable;
|
||||
use XMLWriter;
|
||||
|
||||
class Writer
|
||||
{
|
||||
public static function toString(
|
||||
mixed $config,
|
||||
array $config,
|
||||
string $baseElement = 'xml-config'
|
||||
): string {
|
||||
if ($config instanceof Traversable) {
|
||||
$config = ArrayUtils::iteratorToArray($config);
|
||||
} elseif (!is_array($config)) {
|
||||
throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable config');
|
||||
}
|
||||
|
||||
return self::processConfig($config, $baseElement);
|
||||
}
|
||||
|
||||
|
@ -61,8 +52,11 @@ class Writer
|
|||
return $writer->outputMemory();
|
||||
}
|
||||
|
||||
protected static function addBranch($branchName, array $config, XMLWriter $writer): void
|
||||
{
|
||||
protected static function addBranch(
|
||||
mixed $branchName,
|
||||
array $config,
|
||||
XMLWriter $writer
|
||||
): void {
|
||||
$branchType = null;
|
||||
|
||||
// Ensure attributes come first.
|
||||
|
@ -77,7 +71,7 @@ class Writer
|
|||
$branchType = 'string';
|
||||
}
|
||||
} elseif ($branchType !== (is_numeric($key) ? 'numeric' : 'string')) {
|
||||
throw new Exception\RuntimeException('Mixing of string and numeric keys is not allowed');
|
||||
throw new \RuntimeException('Mixing of string and numeric keys is not allowed');
|
||||
}
|
||||
|
||||
if ($branchType === 'numeric') {
|
||||
|
|
Loading…
Reference in New Issue