Preemptive changes to prepare for Doctrine ORM 3.0.
This commit is contained in:
parent
0dea2de081
commit
85991b7546
|
@ -4,7 +4,6 @@ namespace App\Console\Command;
|
|||
use App\Entity\Repository\StationRepository;
|
||||
use App\Entity\Station;
|
||||
use App\Radio\Configuration;
|
||||
use App\Console\Command\CommandAbstract;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
|
@ -40,13 +39,13 @@ class RestartRadioCommand extends CommandAbstract
|
|||
|
||||
$station->setHasStarted(true);
|
||||
$station->setNeedsRestart(false);
|
||||
|
||||
$em->persist($station);
|
||||
$em->flush($station);
|
||||
|
||||
$io->progressAdvance();
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
|
||||
$io->progressFinish();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ abstract class AbstractApiCrudController
|
|||
}
|
||||
|
||||
$this->em->persist($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
@ -181,6 +181,6 @@ abstract class AbstractApiCrudController
|
|||
}
|
||||
|
||||
$this->em->remove($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ class StationsController extends AbstractAdminApiCrudController
|
|||
}
|
||||
|
||||
$this->em->persist($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
|
||||
if ($create_mode) {
|
||||
return $this->station_repo->create($record);
|
||||
|
|
|
@ -83,7 +83,7 @@ abstract class AbstractScheduledEntityController extends AbstractStationApiCrudC
|
|||
|
||||
if ($record instanceof $this->entityClass) {
|
||||
$this->em->persist($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
|
||||
if (null !== $scheduleItems) {
|
||||
$this->scheduleRepo->setScheduleItems($record, $scheduleItems);
|
||||
|
|
|
@ -73,7 +73,7 @@ class BatchAction
|
|||
}
|
||||
|
||||
$em->remove($media);
|
||||
$em->flush($media);
|
||||
$em->flush();
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$errors[] = $file . ': ' . $e->getMessage();
|
||||
|
@ -102,7 +102,7 @@ class BatchAction
|
|||
}
|
||||
|
||||
$em->persist($station);
|
||||
$em->flush($station);
|
||||
$em->flush();
|
||||
|
||||
// Write new PLS playlist configuration.
|
||||
$backend = $request->getStationBackend();
|
||||
|
@ -250,7 +250,7 @@ class BatchAction
|
|||
}
|
||||
|
||||
$em->persist($media);
|
||||
$em->flush($media);
|
||||
$em->flush();
|
||||
$files_affected++;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
|
@ -274,7 +274,7 @@ class BatchAction
|
|||
|
||||
$newRequest = new Entity\StationRequest($station, $media, true);
|
||||
$em->persist($newRequest);
|
||||
$em->flush($newRequest);
|
||||
$em->flush();
|
||||
$files_affected++;
|
||||
} catch (Exception $e) {
|
||||
$errors[] = $e->getMessage();
|
||||
|
|
|
@ -67,7 +67,7 @@ class RenameAction
|
|||
if ($record instanceof Entity\StationMedia) {
|
||||
$record->setPath($newPath);
|
||||
$em->persist($record);
|
||||
$em->flush($record);
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ class FilesController extends AbstractStationApiCrudController
|
|||
|
||||
if ($record instanceof Entity\StationMedia) {
|
||||
$this->em->persist($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
|
||||
if ($this->media_repo->writeToFile($record)) {
|
||||
$song_info = [
|
||||
|
|
|
@ -19,7 +19,7 @@ class DisableTwoFactorAction
|
|||
$user->setTwoFactorSecret(null);
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush($user);
|
||||
$em->flush();
|
||||
|
||||
$request->getFlash()->addMessage(__('Two-factor authentication disabled.'), Flash::SUCCESS);
|
||||
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
namespace App\Controller\Frontend\Profile;
|
||||
|
||||
use App\Auth;
|
||||
use App\Config;
|
||||
use App\Form\Form;
|
||||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Config;
|
||||
use App\Session\Flash;
|
||||
use AzuraForms\Field\AbstractField;
|
||||
use BaconQrCode;
|
||||
|
@ -51,7 +51,7 @@ class EnableTwoFactorAction
|
|||
$user->setTwoFactorSecret($totp->getProvisioningUri());
|
||||
|
||||
$em->persist($user);
|
||||
$em->flush($user);
|
||||
$em->flush();
|
||||
|
||||
$request->getFlash()->addMessage(__('Two-factor authentication enabled.'), Flash::SUCCESS);
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
namespace App\Controller\Stations;
|
||||
|
||||
use App\Entity\Station;
|
||||
use App\Exception;
|
||||
use App\Exception\CsrfValidationException;
|
||||
use App\Exception\NotFoundException;
|
||||
use App\Form\EntityForm;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Exception;
|
||||
use App\Exception\CsrfValidationException;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\OptimisticLockException;
|
||||
|
@ -45,13 +45,7 @@ abstract class AbstractStationCrudController
|
|||
$this->form->setStation($station);
|
||||
|
||||
$record = $this->_getRecord($station, $id);
|
||||
$result = $this->form->process($request, $record);
|
||||
|
||||
if (false !== $result) {
|
||||
$this->em->refresh($station);
|
||||
}
|
||||
|
||||
return $result;
|
||||
return $this->form->process($request, $record);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -105,9 +105,7 @@ class ProfileController
|
|||
}
|
||||
|
||||
$this->em->persist($station);
|
||||
$this->em->flush($station);
|
||||
|
||||
$this->em->refresh($station);
|
||||
$this->em->flush();
|
||||
|
||||
return $response->withRedirect($request->getRouter()->fromHere('stations:profile:index'));
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
namespace App\Entity\Repository;
|
||||
|
||||
use App\Entity;
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
|
||||
class SettingsRepository extends Repository
|
||||
|
@ -71,7 +71,7 @@ class SettingsRepository extends Repository
|
|||
|
||||
if ($record instanceof Entity\Settings) {
|
||||
$this->em->remove($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
unset(self::$cachedSettings[$key]);
|
||||
|
@ -168,7 +168,7 @@ class SettingsRepository extends Repository
|
|||
|
||||
$record->setSettingValue($value);
|
||||
$this->em->persist($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
|
||||
// Update cached value
|
||||
self::$cachedSettings[$key] = $value;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
namespace App\Entity\Repository;
|
||||
|
||||
use App\Entity;
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
|
||||
class SongRepository extends Repository
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ class SongRepository extends Repository
|
|||
}
|
||||
|
||||
$this->em->persist($obj);
|
||||
$this->em->flush($obj);
|
||||
$this->em->flush();
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ class StationMediaRepository extends Repository
|
|||
|
||||
$media->setArtUpdatedAt(time());
|
||||
$this->em->persist($media);
|
||||
$this->em->flush($media);
|
||||
$this->em->flush();
|
||||
|
||||
return $fs->put($albumArtPath, $albumArt);
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ class StationMediaRepository extends Repository
|
|||
|
||||
$media->setArtUpdatedAt(0);
|
||||
$this->em->persist($media);
|
||||
$this->em->flush($media);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
namespace App\Entity\Repository;
|
||||
|
||||
use App\Entity;
|
||||
use App\Doctrine\Repository;
|
||||
use App\Entity;
|
||||
use Doctrine\ORM\NoResultException;
|
||||
use RuntimeException;
|
||||
|
||||
|
@ -142,7 +142,7 @@ class StationPlaylistMediaRepository extends Repository
|
|||
// Clear the playback queue.
|
||||
$playlist->setQueue(null);
|
||||
$this->em->persist($playlist);
|
||||
$this->em->flush($playlist);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
public function getPlayableMedia(Entity\StationPlaylist $playlist): array
|
||||
|
|
|
@ -165,7 +165,6 @@ class StationRepository extends Repository
|
|||
}
|
||||
|
||||
$this->em->flush();
|
||||
$this->em->refresh($station);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,8 +232,9 @@ class StationRepository extends Repository
|
|||
Utilities::rmdirRecursive($radio_dir);
|
||||
|
||||
// Save changes and continue to the last setup step.
|
||||
$this->em->flush();
|
||||
$this->em->remove($station);
|
||||
$this->em->flush($station);
|
||||
$this->em->flush();
|
||||
|
||||
$this->cache->delete('stations');
|
||||
}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
namespace App\Form;
|
||||
|
||||
use App\Entity\Station;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Settings;
|
||||
use App\Exception;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Normalizer\DoctrineEntityNormalizer;
|
||||
use App\Settings;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use InvalidArgumentException;
|
||||
|
@ -118,7 +118,7 @@ class EntityForm extends Form
|
|||
}
|
||||
|
||||
$this->em->persist($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
|
||||
// Intentionally refresh the station entity in case it didn't refresh elsewhere.
|
||||
if ($this->station instanceof Station && Settings::getInstance()->isTesting()) {
|
||||
|
|
|
@ -100,7 +100,7 @@ class StationForm extends EntityForm
|
|||
}
|
||||
|
||||
$this->em->persist($record);
|
||||
$this->em->flush($record);
|
||||
$this->em->flush();
|
||||
|
||||
if ($create_mode) {
|
||||
return $this->station_repo->create($record);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php
|
||||
namespace App\Form;
|
||||
|
||||
use App\Config;
|
||||
use App\Entity;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Settings;
|
||||
use App\Config;
|
||||
use AzuraForms\Field\AbstractField;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
|
@ -71,7 +71,7 @@ class UserProfileForm extends EntityForm
|
|||
}
|
||||
|
||||
$this->em->persist($user);
|
||||
$this->em->flush($user);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
public function getView(ServerRequest $request): string
|
||||
|
|
|
@ -6,11 +6,13 @@ use App\Normalizer\Annotation\DeepNormalize;
|
|||
use DateTime;
|
||||
use Doctrine\Common\Annotations\Reader;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Inflector\Inflector;
|
||||
use Doctrine\Inflector\Inflector;
|
||||
use Doctrine\Inflector\InflectorFactory;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
|
||||
use Doctrine\ORM\Proxy\Proxy;
|
||||
use InvalidArgumentException;
|
||||
use ProxyManager\Proxy\GhostObjectInterface;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use ReflectionProperty;
|
||||
|
@ -35,14 +37,14 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
|
|||
public const CLASS_METADATA = 'class_metadata';
|
||||
public const ASSOCIATION_MAPPINGS = 'association_mappings';
|
||||
|
||||
/** @var EntityManager */
|
||||
protected $em;
|
||||
|
||||
/** @var SerializerInterface|NormalizerInterface|DenormalizerInterface */
|
||||
protected $serializer;
|
||||
|
||||
/** @var Reader */
|
||||
protected $annotationReader;
|
||||
protected EntityManager $em;
|
||||
|
||||
protected Reader $annotationReader;
|
||||
|
||||
protected Inflector $inflector;
|
||||
|
||||
/**
|
||||
* @param EntityManager $em
|
||||
|
@ -72,6 +74,7 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
|
|||
|
||||
$this->em = $em;
|
||||
$this->annotationReader = $annotationReader;
|
||||
$this->inflector = InflectorFactory::create()->build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -332,7 +335,7 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
|
|||
*/
|
||||
protected function _getMethodName($var, $prefix = ''): string
|
||||
{
|
||||
return Inflector::camelize(($prefix ? $prefix . '_' : '') . $var);
|
||||
return $this->inflector->camelize(($prefix ? $prefix . '_' : '') . $var);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -452,7 +455,7 @@ class DoctrineEntityNormalizer extends AbstractNormalizer
|
|||
protected function _isEntity($class): bool
|
||||
{
|
||||
if (is_object($class)) {
|
||||
$class = ($class instanceof Proxy)
|
||||
$class = ($class instanceof Proxy || $class instanceof GhostObjectInterface)
|
||||
? get_parent_class($class)
|
||||
: get_class($class);
|
||||
} elseif (!is_string($class)) {
|
||||
|
|
|
@ -522,7 +522,7 @@ class AutoDJ implements EventSubscriberInterface
|
|||
break;
|
||||
}
|
||||
|
||||
$this->em->flush($playlist);
|
||||
$this->em->flush();
|
||||
|
||||
if (!$mediaId) {
|
||||
$this->logger->warning(sprintf('Playlist "%s" did not return a playable track.', $playlist->getName()), [
|
||||
|
@ -564,7 +564,7 @@ class AutoDJ implements EventSubscriberInterface
|
|||
// Save the modified cache, sans the now-missing entry.
|
||||
$playlist->setQueue($media_queue);
|
||||
$this->em->persist($playlist);
|
||||
$this->em->flush($playlist);
|
||||
$this->em->flush();
|
||||
|
||||
return ($media_id)
|
||||
? [$media_id, 0]
|
||||
|
|
|
@ -482,7 +482,7 @@ class ConfigWriter implements EventSubscriberInterface
|
|||
|
||||
$mediaBaseDir = $station->getRadioMediaDir() . '/';
|
||||
$playlistFile = [];
|
||||
|
||||
|
||||
$mediaQuery = $this->em->createQuery(/** @lang DQL */ 'SELECT DISTINCT sm
|
||||
FROM App\Entity\StationMedia sm
|
||||
JOIN sm.playlists spm
|
||||
|
|
|
@ -64,7 +64,7 @@ class Configuration
|
|||
if ($regen_auth_key || empty($station->getAdapterApiKey())) {
|
||||
$station->generateAdapterApiKey();
|
||||
$this->em->persist($station);
|
||||
$this->em->flush($station);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
$frontend = $this->adapters->getFrontendAdapter($station);
|
||||
|
@ -162,7 +162,7 @@ class Configuration
|
|||
$station->setNeedsRestart(false);
|
||||
|
||||
$this->em->persist($station);
|
||||
$this->em->flush($station);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ abstract class AbstractFrontend extends AbstractAdapter
|
|||
$mount->setListenersTotal($np['listeners']['total']);
|
||||
$mount->setListenersUnique($np['listeners']['unique']);
|
||||
$this->em->persist($mount);
|
||||
$this->em->flush($mount);
|
||||
$this->em->flush();
|
||||
|
||||
if ($mount->getIsDefault()) {
|
||||
$np_aggregate['current_song'] = $np['current_song'];
|
||||
|
|
|
@ -167,7 +167,7 @@ abstract class AbstractRemote
|
|||
$remote->setListenersTotal($np['listeners']['total']);
|
||||
$remote->setListenersUnique($np['listeners']['unique']);
|
||||
$this->em->persist($remote);
|
||||
$this->em->flush($remote);
|
||||
$this->em->flush();
|
||||
|
||||
if ($np_aggregate['meta']['status'] === 'offline' && $np['meta']['status'] === 'online') {
|
||||
$np_aggregate['current_song'] = $np['current_song'];
|
||||
|
|
|
@ -341,7 +341,7 @@ class NowPlaying extends AbstractTask implements EventSubscriberInterface
|
|||
// Stop Now Playing from processing while doing the steps below.
|
||||
$station->setNowPlayingTimestamp(time());
|
||||
$this->em->persist($station);
|
||||
$this->em->flush($station);
|
||||
$this->em->flush();
|
||||
|
||||
// Process extra metadata sent by Liquidsoap (if it exists).
|
||||
if (!empty($extra_metadata['song_id'])) {
|
||||
|
@ -371,7 +371,7 @@ class NowPlaying extends AbstractTask implements EventSubscriberInterface
|
|||
$sh->sentToAutodj();
|
||||
|
||||
$this->em->persist($sh);
|
||||
$this->em->flush($sh);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,7 +442,7 @@ class NowPlaying extends AbstractTask implements EventSubscriberInterface
|
|||
* Returns the latest live broadcast
|
||||
*
|
||||
* @param Entity\Station $station
|
||||
|
||||
*
|
||||
* @return Entity\StationStreamerBroadcast
|
||||
*/
|
||||
public function getLatestBroadcast(Station $station)
|
||||
|
|
|
@ -83,7 +83,7 @@ class RadioRequests extends AbstractTask
|
|||
$sh->sentToAutodj();
|
||||
|
||||
$this->em->persist($sh);
|
||||
$this->em->flush($sh);
|
||||
$this->em->flush();
|
||||
}
|
||||
|
||||
// Generate full Liquidsoap annotations
|
||||
|
|
|
@ -61,6 +61,9 @@ class Module extends Framework implements DoctrineProvider
|
|||
$_POST = [];
|
||||
$_COOKIE = [];
|
||||
|
||||
$this->em->clear();
|
||||
gc_collect_cycles();
|
||||
|
||||
parent::_after($test);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,6 @@ class Twitter extends AbstractConnector
|
|||
|
||||
$webhook->setMetadataKey('last_message_sent', time());
|
||||
$this->em->persist($webhook);
|
||||
$this->em->flush($webhook);
|
||||
$this->em->flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,16 +37,16 @@ abstract class CestAbstract
|
|||
$auth = $this->di->get(\App\Auth::class);
|
||||
$auth->logout();
|
||||
|
||||
$this->em->clear();
|
||||
|
||||
if ($this->test_station instanceof Entity\Station) {
|
||||
if (!$this->em->contains($this->test_station)) {
|
||||
$this->test_station = $this->em->find(Entity\Station::class, $this->test_station->getId());
|
||||
}
|
||||
$this->test_station = $this->em->find(Entity\Station::class, $this->test_station->getId());
|
||||
|
||||
$this->stationRepo->destroy($this->test_station);
|
||||
$this->test_station = null;
|
||||
}
|
||||
|
||||
$this->em->clear();
|
||||
$this->em->clear();
|
||||
}
|
||||
}
|
||||
|
||||
protected $login_username = 'azuracast@azuracast.com';
|
||||
|
|
Loading…
Reference in New Issue