PHP code style fixes.
This commit is contained in:
parent
8a4371df8b
commit
3f23efa076
|
@ -134,7 +134,7 @@ class Acl
|
|||
*/
|
||||
public function userAllowed(?Entity\User $user = null, array|string $action, $stationId = null): bool
|
||||
{
|
||||
if (!($user instanceof Entity\User)) {
|
||||
if (null === $user) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,7 @@ class AppFactory
|
|||
return $app;
|
||||
}
|
||||
|
||||
/** @noinspection SummerTimeUnsafeTimeManipulationInspection */
|
||||
public static function buildContainer(
|
||||
$autoloader = null,
|
||||
$appEnvironment = [],
|
||||
|
@ -137,8 +138,6 @@ class AppFactory
|
|||
|
||||
$diDefinitions[Plugins::class] = $plugins;
|
||||
$diDefinitions = $plugins->registerServices($diDefinitions);
|
||||
} else {
|
||||
$plugins = null;
|
||||
}
|
||||
|
||||
$containerBuilder = new DI\ContainerBuilder();
|
||||
|
|
|
@ -32,7 +32,7 @@ class Assets
|
|||
protected bool $is_sorted = true;
|
||||
|
||||
/** @var string A randomly generated number-used-once (nonce) for inline CSP. */
|
||||
protected $csp_nonce;
|
||||
protected string $csp_nonce;
|
||||
|
||||
/** @var array The loaded domains that should be included in the CSP header. */
|
||||
protected array $csp_domains;
|
||||
|
@ -47,26 +47,25 @@ class Assets
|
|||
) {
|
||||
$this->request = $request;
|
||||
|
||||
$libraries = $config->get('assets');
|
||||
foreach ($libraries as $library_name => $library) {
|
||||
foreach ($config->get('assets') as $library_name => $library) {
|
||||
$this->addLibrary($library, $library_name);
|
||||
}
|
||||
|
||||
$versioned_files = [];
|
||||
$assets_file = $environment->getBaseDirectory() . '/web/static/assets.json';
|
||||
if (file_exists($assets_file)) {
|
||||
if (is_file($assets_file)) {
|
||||
$versioned_files = json_decode(file_get_contents($assets_file), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
$this->versioned_files = $versioned_files;
|
||||
|
||||
$vueComponents = [];
|
||||
$assets_file = $environment->getBaseDirectory() . '/web/static/webpack.json';
|
||||
if (file_exists($assets_file)) {
|
||||
if (is_file($assets_file)) {
|
||||
$vueComponents = json_decode(file_get_contents($assets_file), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
$this->addVueComponents($vueComponents);
|
||||
|
||||
$this->csp_nonce = preg_replace('/[^A-Za-z0-9\+\/=]/', '', base64_encode(random_bytes(18)));
|
||||
$this->csp_nonce = (string)preg_replace('/[^A-Za-z0-9\+\/=]/', '', base64_encode(random_bytes(18)));
|
||||
$this->csp_domains = [];
|
||||
}
|
||||
|
||||
|
@ -196,7 +195,7 @@ class Assets
|
|||
|
||||
// Check if a library is "replaced" by other libraries already loaded.
|
||||
$is_replaced = false;
|
||||
foreach ($this->loaded as $loaded_name => $loaded_item) {
|
||||
foreach ($this->loaded as $loaded_item) {
|
||||
if (!empty($loaded_item['replace']) && in_array($name, (array)$loaded_item['replace'], true)) {
|
||||
$is_replaced = true;
|
||||
break;
|
||||
|
|
|
@ -25,7 +25,7 @@ class Config
|
|||
{
|
||||
$path = $this->getPath($name);
|
||||
|
||||
if (file_exists($path)) {
|
||||
if (is_file($path)) {
|
||||
unset($name);
|
||||
extract($inject_vars, EXTR_OVERWRITE);
|
||||
unset($inject_vars);
|
||||
|
|
|
@ -12,9 +12,7 @@ class OptimizeTablesCommand extends CommandAbstract
|
|||
{
|
||||
$io->title('Optimizing Database Tables...');
|
||||
|
||||
$tables = $db->fetchAllAssociative('SHOW TABLES');
|
||||
|
||||
foreach ($tables as $tableRow) {
|
||||
foreach ($db->fetchAllAssociative('SHOW TABLES') as $tableRow) {
|
||||
$table = reset($tableRow);
|
||||
|
||||
$io->listing([$table]);
|
||||
|
|
|
@ -4,10 +4,10 @@ namespace App\Console\Command;
|
|||
|
||||
use App\Environment;
|
||||
use App\Version;
|
||||
use OpenApi\Generator;
|
||||
use OpenApi\Util;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
use function OpenApi\scan;
|
||||
|
||||
class GenerateApiDocsCommand extends CommandAbstract
|
||||
{
|
||||
public function __invoke(
|
||||
|
@ -18,20 +18,21 @@ class GenerateApiDocsCommand extends CommandAbstract
|
|||
define('AZURACAST_API_NAME', 'AzuraCast Public Demo Server');
|
||||
define('AZURACAST_VERSION', Version::FALLBACK_VERSION);
|
||||
|
||||
$oa = scan([
|
||||
$environment->getBaseDirectory() . '/util/openapi.php',
|
||||
$environment->getBaseDirectory() . '/src/Entity',
|
||||
$environment->getBaseDirectory() . '/src/Controller/Api',
|
||||
], [
|
||||
'exclude' => [
|
||||
$finder = Util::finder(
|
||||
[
|
||||
$environment->getBaseDirectory() . '/util/openapi.php',
|
||||
$environment->getBaseDirectory() . '/src/Entity',
|
||||
$environment->getBaseDirectory() . '/src/Controller/Api',
|
||||
],
|
||||
[
|
||||
'bootstrap',
|
||||
'locale',
|
||||
'templates',
|
||||
],
|
||||
]);
|
||||
]
|
||||
);
|
||||
|
||||
$yaml_path = $environment->getBaseDirectory() . '/web/static/api/openapi.yml';
|
||||
$yaml = $oa->toYaml();
|
||||
$yaml = (Generator::scan($finder))->toYaml();
|
||||
|
||||
file_put_contents($yaml_path, $yaml);
|
||||
|
||||
|
|
|
@ -22,12 +22,10 @@ class SftpAuthCommand extends CommandAbstract
|
|||
$password = getenv('SFTPGO_AUTHD_PASSWORD');
|
||||
$pubKey = getenv('SFTPGO_AUTHD_PUBLIC_KEY');
|
||||
|
||||
$sftpRepo = $em->getRepository(SftpUser::class);
|
||||
$sftpUser = $sftpRepo->findOneBy(['username' => $username]);
|
||||
$sftpUser = $em->getRepository(SftpUser::class)->findOneBy(['username' => $username]);
|
||||
|
||||
if ($sftpUser instanceof SftpUser && $sftpUser->authenticate($password, $pubKey)) {
|
||||
$station = $sftpUser->getStation();
|
||||
$storageLocation = $station->getMediaStorageLocation();
|
||||
$storageLocation = $sftpUser->getStation()->getMediaStorageLocation();
|
||||
|
||||
$quotaRaw = $storageLocation->getStorageQuotaBytes();
|
||||
$quota = ($quotaRaw instanceof BigInteger)
|
||||
|
|
|
@ -45,9 +45,7 @@ class SftpEventCommand extends CommandAbstract
|
|||
);
|
||||
|
||||
// Determine which station the username belongs to.
|
||||
$userRepo = $em->getRepository(Entity\SftpUser::class);
|
||||
|
||||
$sftpUser = $userRepo->findOneBy(
|
||||
$sftpUser = $em->getRepository(Entity\SftpUser::class)->findOneBy(
|
||||
[
|
||||
'username' => $username,
|
||||
]
|
||||
|
@ -58,8 +56,7 @@ class SftpEventCommand extends CommandAbstract
|
|||
return 1;
|
||||
}
|
||||
|
||||
$station = $sftpUser->getStation();
|
||||
$storageLocation = $station->getMediaStorageLocation();
|
||||
$storageLocation = $sftpUser->getStation()->getMediaStorageLocation();
|
||||
|
||||
if (!$storageLocation->isLocal()) {
|
||||
$this->logger->error(sprintf('Storage location "%s" is not local.', (string)$storageLocation));
|
||||
|
|
|
@ -14,24 +14,24 @@ class MigrateConfigCommand extends CommandAbstract
|
|||
$envSettings = [];
|
||||
|
||||
$iniPath = $environment->getBaseDirectory() . '/env.ini';
|
||||
if (file_exists($iniPath)) {
|
||||
if (is_file($iniPath)) {
|
||||
$envSettings = (array)parse_ini_file($iniPath);
|
||||
}
|
||||
|
||||
// Migrate from existing legacy config files.
|
||||
$legacyIniPath = $environment->getBaseDirectory() . '/app/env.ini';
|
||||
if (file_exists($legacyIniPath)) {
|
||||
if (is_file($legacyIniPath)) {
|
||||
$iniSettings = parse_ini_file($legacyIniPath);
|
||||
$envSettings = array_merge($envSettings, (array)$iniSettings);
|
||||
}
|
||||
|
||||
$legacyAppEnvFile = $environment->getBaseDirectory() . '/app/.env';
|
||||
if (file_exists($legacyAppEnvFile)) {
|
||||
if (is_file($legacyAppEnvFile)) {
|
||||
$envSettings[Environment::APP_ENV] ??= file_get_contents($legacyAppEnvFile);
|
||||
}
|
||||
|
||||
$legacyDbConfFile = $environment->getBaseDirectory() . '/app/config/db.conf.php';
|
||||
if (file_exists($legacyDbConfFile)) {
|
||||
if (is_file($legacyDbConfFile)) {
|
||||
$dbConf = include($legacyDbConfFile);
|
||||
|
||||
$envSettings[Environment::DB_PASSWORD] ??= $dbConf['password'];
|
||||
|
|
|
@ -22,9 +22,7 @@ class ListCommand extends CommandAbstract
|
|||
$rows = [];
|
||||
|
||||
$settings = $settingsTableRepo->readSettings();
|
||||
$all_settings = $settingsTableRepo->toArray($settings);
|
||||
|
||||
foreach ($all_settings as $setting_key => $setting_value) {
|
||||
foreach ($settingsTableRepo->toArray($settings) as $setting_key => $setting_value) {
|
||||
$value = print_r($setting_value, true);
|
||||
$value = Utilities\Strings::truncateText($value, 600);
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@ class SetupCommand extends CommandAbstract
|
|||
$io->note(__('Running in update mode.'));
|
||||
}
|
||||
|
||||
$em = $di->get(EntityManagerInterface::class);
|
||||
$conn = $em->getConnection();
|
||||
$conn = $di->get(EntityManagerInterface::class)->getConnection();
|
||||
|
||||
$io->newLine();
|
||||
$io->section(__('Running Database Migrations'));
|
||||
|
|
|
@ -21,7 +21,7 @@ abstract class AbstractLogViewerController
|
|||
): ResponseInterface {
|
||||
clearstatcache();
|
||||
|
||||
if (!file_exists($log_path)) {
|
||||
if (!is_file($log_path)) {
|
||||
throw new NotFoundException('Log file not found!');
|
||||
}
|
||||
|
||||
|
|
|
@ -38,10 +38,8 @@ class BackupsController extends AbstractLogViewerController
|
|||
$backups = [];
|
||||
$storageLocations = $this->storageLocationRepo->findAllByType(Entity\StorageLocation::TYPE_BACKUP);
|
||||
foreach ($storageLocations as $storageLocation) {
|
||||
$fs = $storageLocation->getFilesystem();
|
||||
|
||||
/** @var StorageAttributes $file */
|
||||
foreach ($fs->listContents('', true) as $file) {
|
||||
foreach ($storageLocation->getFilesystem()->listContents('', true) as $file) {
|
||||
if ($file->isDir()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ class DebugController extends AbstractLogViewerController
|
|||
ServerRequest $request,
|
||||
Response $response
|
||||
): ResponseInterface {
|
||||
[$resultCode, $resultOutput] = $this->console->runCommandWithArgs(
|
||||
[, $resultOutput] = $this->console->runCommandWithArgs(
|
||||
'cache:clear'
|
||||
);
|
||||
|
||||
|
@ -182,7 +182,7 @@ class DebugController extends AbstractLogViewerController
|
|||
$args['queue'] = $queue;
|
||||
}
|
||||
|
||||
[$resultCode, $resultOutput] = $this->console->runCommandWithArgs('queue:clear', $args);
|
||||
[, $resultOutput] = $this->console->runCommandWithArgs('queue:clear', $args);
|
||||
|
||||
// Flash an update to ensure the session is recreated.
|
||||
$request->getFlash()->addMessage($resultOutput, Flash::SUCCESS);
|
||||
|
|
|
@ -50,7 +50,7 @@ class IndexController
|
|||
$spaceUsed = $spaceTotal->minus($spaceFree);
|
||||
|
||||
// Get memory info.
|
||||
$meminfoRaw = explode("\n", file_get_contents("/proc/meminfo"));
|
||||
$meminfoRaw = file("/proc/meminfo", FILE_IGNORE_NEW_LINES);
|
||||
$meminfo = [];
|
||||
foreach ($meminfoRaw as $line) {
|
||||
if (str_contains($line, ':')) {
|
||||
|
|
|
@ -54,7 +54,7 @@ class InstallShoutcastController
|
|||
|
||||
if (UPLOAD_ERR_OK === $import_file->getError()) {
|
||||
$sc_tgz_path = $sc_base_dir . '/sc_serv.tar.gz';
|
||||
if (file_exists($sc_tgz_path)) {
|
||||
if (is_file($sc_tgz_path)) {
|
||||
unlink($sc_tgz_path);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class UsersController extends AbstractAdminCrudController
|
|||
|
||||
return $response->withRedirect($request->getRouter()->named('admin:users:index'));
|
||||
}
|
||||
} catch (UniqueConstraintViolationException $e) {
|
||||
} catch (UniqueConstraintViolationException) {
|
||||
$request->getFlash()->addMessage(
|
||||
__('Another user already exists with this e-mail address. Please update the e-mail address.'),
|
||||
Flash::ERROR
|
||||
|
|
|
@ -138,9 +138,7 @@ class RelaysController
|
|||
}
|
||||
|
||||
// Iterate through all remotes that *should* exist.
|
||||
$stations = $this->getManageableStations($request);
|
||||
|
||||
foreach ($stations as $station) {
|
||||
foreach ($this->getManageableStations($request) as $station) {
|
||||
$station_id = $station->getId();
|
||||
|
||||
foreach ($station->getMounts() as $mount) {
|
||||
|
|
|
@ -20,8 +20,7 @@ class ChartsAction
|
|||
CacheInterface $cache,
|
||||
Entity\Repository\SettingsRepository $settingsRepo
|
||||
): ResponseInterface {
|
||||
$settings = $settingsRepo->readSettings();
|
||||
$analyticsLevel = $settings->getAnalytics();
|
||||
$analyticsLevel = $settingsRepo->readSettings()->getAnalytics();
|
||||
if ($analyticsLevel === Entity\Analytics::LEVEL_NONE) {
|
||||
return $response->withStatus(403, 'Forbidden')
|
||||
->withJson(new Entity\Api\Error(403, 'Analytics are disabled for this installation.'));
|
||||
|
|
|
@ -74,7 +74,6 @@ class StationsAction
|
|||
$viewStations = array_reverse($viewStations);
|
||||
}
|
||||
|
||||
$paginator = Paginator::fromArray($viewStations, $request);
|
||||
return $paginator->write($response);
|
||||
return Paginator::fromArray($viewStations, $request)->write($response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,15 +110,15 @@ class NowplayingController implements EventSubscriberInterface
|
|||
|
||||
// If unauthenticated, hide non-public stations from full view.
|
||||
if ($request->getAttribute('user') === null) {
|
||||
$np = array_filter(
|
||||
$np,
|
||||
static function ($np_row) {
|
||||
return $np_row->station->is_public;
|
||||
}
|
||||
);
|
||||
|
||||
// Prevent NP array from returning as an object.
|
||||
$np = array_values($np);
|
||||
$np = array_values(
|
||||
array_filter(
|
||||
$np,
|
||||
static function ($np_row) {
|
||||
return $np_row->station->is_public;
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($np as $np_row) {
|
||||
|
|
|
@ -6,10 +6,10 @@ use App\Environment;
|
|||
use App\Http\Response;
|
||||
use App\Http\ServerRequest;
|
||||
use App\Version;
|
||||
use OpenApi\Generator;
|
||||
use OpenApi\Util;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use function OpenApi\scan;
|
||||
|
||||
class OpenApiController
|
||||
{
|
||||
public function __construct(
|
||||
|
@ -20,28 +20,27 @@ class OpenApiController
|
|||
|
||||
public function __invoke(ServerRequest $request, Response $response): ResponseInterface
|
||||
{
|
||||
$router = $request->getRouter();
|
||||
|
||||
$api_base_url = $router->fromHere(null, [], [], true);
|
||||
$api_base_url = $request->getRouter()->fromHere(null, [], [], true);
|
||||
$api_base_url = str_replace('/openapi.yml', '', $api_base_url);
|
||||
|
||||
define('AZURACAST_API_URL', $api_base_url);
|
||||
define('AZURACAST_API_NAME', 'This AzuraCast Installation');
|
||||
define('AZURACAST_VERSION', $this->version->getVersion());
|
||||
|
||||
$oa = scan([
|
||||
$this->environment->getBaseDirectory() . '/util/openapi.php',
|
||||
$this->environment->getBaseDirectory() . '/src/Entity',
|
||||
$this->environment->getBaseDirectory() . '/src/Controller/Api',
|
||||
], [
|
||||
'exclude' => [
|
||||
$finder = Util::finder(
|
||||
[
|
||||
$this->environment->getBaseDirectory() . '/util/openapi.php',
|
||||
$this->environment->getBaseDirectory() . '/src/Entity',
|
||||
$this->environment->getBaseDirectory() . '/src/Controller/Api',
|
||||
],
|
||||
[
|
||||
'bootstrap',
|
||||
'locale',
|
||||
'templates',
|
||||
],
|
||||
]);
|
||||
]
|
||||
);
|
||||
|
||||
$yaml = $oa->toYaml();
|
||||
$yaml = (Generator::scan($finder))->toYaml();
|
||||
|
||||
$response->getBody()->write($yaml);
|
||||
return $response->withHeader('Content-Type', 'text/x-yaml');
|
||||
|
|
|
@ -32,8 +32,7 @@ abstract class AbstractScheduledEntityController extends AbstractStationApiCrudC
|
|||
array $scheduleItems,
|
||||
callable $rowRender
|
||||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
$tz = $station->getTimezoneObject();
|
||||
$tz = $request->getStation()->getTimezoneObject();
|
||||
|
||||
$params = $request->getQueryParams();
|
||||
|
||||
|
|
|
@ -104,8 +104,7 @@ abstract class AbstractStationApiCrudController extends AbstractApiCrudControlle
|
|||
*/
|
||||
protected function getRecord(Entity\Station $station, int|string $id): ?object
|
||||
{
|
||||
$repo = $this->em->getRepository($this->entityClass);
|
||||
return $repo->findOneBy(
|
||||
return $this->em->getRepository($this->entityClass)->findOneBy(
|
||||
[
|
||||
'station' => $station,
|
||||
'id' => $id,
|
||||
|
|
|
@ -44,13 +44,12 @@ class GetArtAction
|
|||
): ResponseInterface {
|
||||
$station = $request->getStation();
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
$defaultArtRedirect = $response->withRedirect($stationRepo->getDefaultAlbumArtUrl($station), 302);
|
||||
|
||||
// If a timestamp delimiter is added, strip it automatically.
|
||||
$media_id = explode('-', $media_id)[0];
|
||||
$media_id = explode('-', $media_id, 2)[0];
|
||||
|
||||
if (Entity\StationMedia::UNIQUE_ID_LENGTH === strlen($media_id)) {
|
||||
$response = $response->withCacheLifetime(Response::CACHE_ONE_YEAR);
|
||||
|
|
|
@ -39,8 +39,7 @@ class BatchAction
|
|||
$station = $request->getStation();
|
||||
$storageLocation = $station->getMediaStorageLocation();
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
$result = match ($request->getParam('do')) {
|
||||
'delete' => $this->doDelete($request, $station, $storageLocation, $fsMedia),
|
||||
|
@ -157,7 +156,7 @@ class BatchAction
|
|||
|
||||
$this->em->flush();
|
||||
|
||||
foreach ($playlists as $playlistId => $playlistRecord) {
|
||||
foreach ($playlists as $playlistRecord) {
|
||||
$playlist = $this->em->refetchAsReference($playlistRecord);
|
||||
|
||||
$playlistWeights[$playlist->getId()]++;
|
||||
|
@ -166,7 +165,7 @@ class BatchAction
|
|||
$this->playlistMediaRepo->addMediaToPlaylist($media, $playlist, $weight);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$errors[] = $media->getPath() . ': ' . $e->getMessage();
|
||||
$result->errors[] = $media->getPath() . ': ' . $e->getMessage();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@ class DownloadAction
|
|||
set_time_limit(600);
|
||||
|
||||
$station = $request->getStation();
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
$path = $request->getParam('file');
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ class ListAction
|
|||
$station = $request->getStation();
|
||||
$storageLocation = $station->getMediaStorageLocation();
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fs = $fsStation->getMediaFilesystem();
|
||||
$fs = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
$currentDir = $request->getParam('currentDirectory', '');
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@ class ListDirectoriesAction
|
|||
|
||||
$currentDir = $request->getParam('currentDirectory', '');
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
$protectedPaths = [Entity\StationMedia::DIR_ALBUM_ART, Entity\StationMedia::DIR_WAVEFORMS];
|
||||
|
||||
|
|
|
@ -25,8 +25,7 @@ class MakeDirectoryAction
|
|||
|
||||
$station = $request->getStation();
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
$newDir = $currentDir . '/' . $newDirName;
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@ class PlayAction
|
|||
->withJson(new Entity\Api\Error(404, 'Not Found'));
|
||||
}
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
return $response->streamFilesystemFile($fsMedia, $media->getPath());
|
||||
}
|
||||
|
|
|
@ -36,8 +36,7 @@ class RenameAction
|
|||
$station = $request->getStation();
|
||||
$storageLocation = $station->getMediaStorageLocation();
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
$fsMedia->move($from, $to);
|
||||
|
||||
|
|
|
@ -128,8 +128,7 @@ class FilesController extends AbstractStationApiCrudController
|
|||
*/
|
||||
public function listAction(ServerRequest $request, Response $response): ResponseInterface
|
||||
{
|
||||
$station = $this->getStation($request);
|
||||
$storageLocation = $station->getMediaStorageLocation();
|
||||
$storageLocation = $this->getStation($request)->getMediaStorageLocation();
|
||||
|
||||
$query = $this->em->createQuery(
|
||||
<<<'DQL'
|
||||
|
@ -200,8 +199,7 @@ class FilesController extends AbstractStationApiCrudController
|
|||
$playlists = $data['playlists'] ?? null;
|
||||
unset($data['custom_fields'], $data['playlists']);
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
$record = $this->fromArray(
|
||||
$data,
|
||||
|
@ -315,8 +313,7 @@ class FilesController extends AbstractStationApiCrudController
|
|||
$mediaStorage = $station->getMediaStorageLocation();
|
||||
$repo = $this->em->getRepository($this->entityClass);
|
||||
|
||||
$fieldsToCheck = ['id', 'unique_id', 'song_id'];
|
||||
foreach ($fieldsToCheck as $field) {
|
||||
foreach (['id', 'unique_id', 'song_id'] as $field) {
|
||||
$record = $repo->findOneBy(
|
||||
[
|
||||
'storage_location' => $mediaStorage,
|
||||
|
@ -353,10 +350,8 @@ class FilesController extends AbstractStationApiCrudController
|
|||
}
|
||||
|
||||
// Delete the media file off the filesystem.
|
||||
$affected_playlists = $this->mediaRepo->remove($record, true);
|
||||
|
||||
// Write new PLS playlist configuration.
|
||||
foreach ($affected_playlists as $playlist_id => $playlist) {
|
||||
foreach ($this->mediaRepo->remove($record, true) as $playlist_id => $playlist) {
|
||||
$backend = $this->adapters->getBackendAdapter($playlist->getStation());
|
||||
if ($backend instanceof Liquidsoap) {
|
||||
// Instruct the message queue to start a new "write playlist to file" task.
|
||||
|
|
|
@ -100,9 +100,7 @@ class HistoryController
|
|||
'Streamer',
|
||||
];
|
||||
|
||||
$iterator = BatchIteratorAggregate::fromQuery($qb->getQuery(), 100);
|
||||
|
||||
foreach ($iterator as $sh) {
|
||||
foreach (BatchIteratorAggregate::fromQuery($qb->getQuery(), 100) as $sh) {
|
||||
/** @var Entity\SongHistory $sh */
|
||||
$datetime = CarbonImmutable::createFromTimestamp($sh->getTimestampStart(), $station_tz);
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ class ListenersAction
|
|||
}
|
||||
|
||||
if ($groupByUnique) {
|
||||
foreach ($listenersByHash as $hash => $listenerInfo) {
|
||||
foreach ($listenersByHash as $listenerInfo) {
|
||||
$intervals = (array)$listenerInfo['intervals'];
|
||||
|
||||
$startTime = $now->getTimestamp();
|
||||
|
|
|
@ -31,8 +31,7 @@ class DownloadAction
|
|||
->withJson(new Entity\Api\Error(404, __('File not found.')));
|
||||
}
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
set_time_limit(600);
|
||||
return $response->streamFilesystemFile($fsMedia, $media->getPath());
|
||||
|
|
|
@ -60,8 +60,7 @@ class ListAction
|
|||
'playlist',
|
||||
];
|
||||
|
||||
$customFields = array_keys($this->customFieldRepo->getFieldIds());
|
||||
foreach ($customFields as $customField) {
|
||||
foreach (array_keys($this->customFieldRepo->getFieldIds()) as $customField) {
|
||||
$searchFields[] = 'media_custom_fields_' . $customField;
|
||||
}
|
||||
|
||||
|
@ -88,8 +87,7 @@ class ListAction
|
|||
$trackList = $trackList->matching($criteria);
|
||||
}
|
||||
|
||||
$paginator = Paginator::fromCollection($trackList, $request);
|
||||
return $paginator->write($response);
|
||||
return Paginator::fromCollection($trackList, $request)->write($response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,9 +121,7 @@ class ListAction
|
|||
DQL
|
||||
)->setParameter('playlist_id', $playlist['id']);
|
||||
|
||||
$iterator = BatchIteratorAggregate::fromQuery($query, 50);
|
||||
|
||||
foreach ($iterator as $media) {
|
||||
foreach (BatchIteratorAggregate::fromQuery($query, 50) as $media) {
|
||||
/** @var Entity\StationMedia $media */
|
||||
$row = new Entity\Api\StationOnDemand();
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@ abstract class AbstractPlaylistsAction
|
|||
|
||||
protected function requireRecord(Entity\Station $station, int $id): Entity\StationPlaylist
|
||||
{
|
||||
$repo = $this->em->getRepository(Entity\StationPlaylist::class);
|
||||
|
||||
$record = $repo->findOneBy(
|
||||
$record = $this->em->getRepository(Entity\StationPlaylist::class)->findOneBy(
|
||||
[
|
||||
'station' => $station,
|
||||
'id' => $id,
|
||||
|
|
|
@ -28,8 +28,6 @@ class GetQueueAction extends AbstractPlaylistsAction
|
|||
}
|
||||
|
||||
$queue = $spmRepo->getQueue($record);
|
||||
$paginator = Paginator::fromArray($queue, $request);
|
||||
|
||||
return $paginator->write($response);
|
||||
return Paginator::fromArray($queue, $request)->write($response);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,7 @@ class ImportAction extends AbstractPlaylistsAction
|
|||
$foundPaths = 0;
|
||||
|
||||
if (!empty($paths)) {
|
||||
$station = $request->getStation();
|
||||
$storageLocation = $station->getMediaStorageLocation();
|
||||
$storageLocation = $request->getStation()->getMediaStorageLocation();
|
||||
|
||||
// Assemble list of station media to match against.
|
||||
$media_lookup = [];
|
||||
|
|
|
@ -359,7 +359,7 @@ class PodcastEpisodesController extends AbstractApiCrudController
|
|||
$fsStations = new StationFilesystems($request->getStation());
|
||||
$fsTemp = $fsStations->getTempFilesystem();
|
||||
|
||||
$originalName = basename($media->getClientFilename()) ?? $record->getId() . '.mp3';
|
||||
$originalName = basename($media->getClientFilename()) ?? ($record->getId() . '.mp3');
|
||||
$originalExt = pathinfo($originalName, PATHINFO_EXTENSION);
|
||||
|
||||
$tempPath = $fsTemp->getLocalPath($record->getId() . '.' . $originalExt);
|
||||
|
|
|
@ -22,12 +22,11 @@ class GetArtAction
|
|||
$station = $request->getStation();
|
||||
|
||||
// If a timestamp delimiter is added, strip it automatically.
|
||||
$podcast_id = explode('|', $podcast_id)[0];
|
||||
$podcast_id = explode('|', $podcast_id, 2)[0];
|
||||
|
||||
$podcastPath = Entity\Podcast::getArtPath($podcast_id);
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsPodcasts = $fsStation->getPodcastsFilesystem();
|
||||
$fsPodcasts = (new StationFilesystems($station))->getPodcastsFilesystem();
|
||||
|
||||
if ($fsPodcasts->fileExists($podcastPath)) {
|
||||
return $response->withCacheLifetime(Response::CACHE_ONE_YEAR)
|
||||
|
|
|
@ -22,12 +22,11 @@ class GetArtAction
|
|||
$station = $request->getStation();
|
||||
|
||||
// If a timestamp delimiter is added, strip it automatically.
|
||||
$episode_id = explode('|', $episode_id)[0];
|
||||
$episode_id = explode('|', $episode_id, 2)[0];
|
||||
|
||||
$episodeArtPath = Entity\PodcastEpisode::getArtPath($episode_id);
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsPodcasts = $fsStation->getPodcastsFilesystem();
|
||||
$fsPodcasts = (new StationFilesystems($station))->getPodcastsFilesystem();
|
||||
|
||||
if ($fsPodcasts->fileExists($episodeArtPath)) {
|
||||
return $response->withCacheLifetime(Response::CACHE_ONE_YEAR)
|
||||
|
|
|
@ -27,8 +27,7 @@ class DownloadAction
|
|||
$podcastMedia = $episode->getMedia();
|
||||
|
||||
if ($podcastMedia instanceof Entity\PodcastMedia) {
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsPodcasts = $fsStation->getPodcastsFilesystem();
|
||||
$fsPodcasts = (new StationFilesystems($station))->getPodcastsFilesystem();
|
||||
|
||||
$path = $podcastMedia->getPath();
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class ProfileController
|
|||
$apiResponse->schedule = $scheduleRepo->getUpcomingSchedule($station);
|
||||
|
||||
$apiResponse->update();
|
||||
$apiResponse->resolveUrls($baseUri = $request->getRouter()->getBaseUrl());
|
||||
$apiResponse->resolveUrls($request->getRouter()->getBaseUrl());
|
||||
|
||||
return $response->withJson($apiResponse);
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ class BestAndWorstAction
|
|||
$station_tz = $station->getTimezoneObject();
|
||||
|
||||
// Get current analytics level.
|
||||
$settings = $settingsRepo->readSettings();
|
||||
$analytics_level = $settings->getAnalytics();
|
||||
$analytics_level = $settingsRepo->readSettings()->getAnalytics();
|
||||
|
||||
if ($analytics_level === Entity\Analytics::LEVEL_NONE) {
|
||||
return $response->withStatus(400)
|
||||
|
@ -57,7 +56,7 @@ class BestAndWorstAction
|
|||
|
||||
foreach ($rawStats as $category => $rawRows) {
|
||||
$stats[$category] = array_map(
|
||||
function ($row) use ($songApiGenerator, $station, $baseUrl) {
|
||||
static function ($row) use ($songApiGenerator, $station, $baseUrl) {
|
||||
$song = ($songApiGenerator)(Entity\Song::createFromArray($row), $station);
|
||||
$song->resolveUrls($baseUrl);
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@ class ChartsAction
|
|||
$station_tz = $station->getTimezoneObject();
|
||||
|
||||
// Get current analytics level.
|
||||
$settings = $settingsRepo->readSettings();
|
||||
$analytics_level = $settings->getAnalytics();
|
||||
$analytics_level = $settingsRepo->readSettings()->getAnalytics();
|
||||
|
||||
if ($analytics_level === Entity\Analytics::LEVEL_NONE) {
|
||||
return $response->withStatus(400)
|
||||
|
|
|
@ -22,8 +22,7 @@ class MostPlayedAction
|
|||
$station_tz = $station->getTimezoneObject();
|
||||
|
||||
// Get current analytics level.
|
||||
$settings = $settingsRepo->readSettings();
|
||||
$analytics_level = $settings->getAnalytics();
|
||||
$analytics_level = $settingsRepo->readSettings()->getAnalytics();
|
||||
|
||||
if ($analytics_level === Entity\Analytics::LEVEL_NONE) {
|
||||
return $response->withStatus(400)
|
||||
|
@ -50,7 +49,7 @@ class MostPlayedAction
|
|||
$baseUrl = $request->getRouter()->getBaseUrl();
|
||||
|
||||
$stats = array_map(
|
||||
function ($row) use ($songApiGenerator, $station, $baseUrl) {
|
||||
static function ($row) use ($songApiGenerator, $station, $baseUrl) {
|
||||
$song = ($songApiGenerator)(Entity\Song::createFromArray($row), $station);
|
||||
$song->resolveUrls($baseUrl);
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ class RequestsController
|
|||
|
||||
try {
|
||||
$user = $request->getUser();
|
||||
} catch (Exception\InvalidRequestAttribute $e) {
|
||||
} catch (Exception\InvalidRequestAttribute) {
|
||||
$user = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ class ServicesController
|
|||
default:
|
||||
try {
|
||||
$frontend->stop($station);
|
||||
} catch (NotRunningException $e) {
|
||||
} catch (NotRunningException) {
|
||||
}
|
||||
|
||||
$frontend->write($station);
|
||||
|
@ -202,7 +202,7 @@ class ServicesController
|
|||
default:
|
||||
try {
|
||||
$backend->stop($station);
|
||||
} catch (NotRunningException $e) {
|
||||
} catch (NotRunningException) {
|
||||
}
|
||||
|
||||
$backend->write($station);
|
||||
|
|
|
@ -64,8 +64,7 @@ class BroadcastsController extends AbstractApiCrudController
|
|||
$is_bootgrid = $paginator->isFromBootgrid();
|
||||
$router = $request->getRouter();
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsRecordings = $fsStation->getRecordingsFilesystem();
|
||||
$fsRecordings = (new StationFilesystems($station))->getRecordingsFilesystem();
|
||||
|
||||
$paginator->setPostprocessor(
|
||||
function ($row) use ($id, $is_bootgrid, $router, $fsRecordings) {
|
||||
|
@ -156,8 +155,7 @@ class BroadcastsController extends AbstractApiCrudController
|
|||
|
||||
$filename = basename($recordingPath);
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsRecordings = $fsStation->getRecordingsFilesystem();
|
||||
$fsRecordings = (new StationFilesystems($station))->getRecordingsFilesystem();
|
||||
|
||||
return $response->streamFilesystemFile(
|
||||
$fsRecordings,
|
||||
|
@ -184,8 +182,7 @@ class BroadcastsController extends AbstractApiCrudController
|
|||
$recordingPath = $broadcast->getRecordingPath();
|
||||
|
||||
if (!empty($recordingPath)) {
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsRecordings = $fsStation->getRecordingsFilesystem();
|
||||
$fsRecordings = (new StationFilesystems($station))->getRecordingsFilesystem();
|
||||
|
||||
$fsRecordings->delete($recordingPath);
|
||||
|
||||
|
|
|
@ -159,9 +159,7 @@ class StreamersController extends AbstractScheduledEntityController
|
|||
$return = parent::viewRecord($record, $request);
|
||||
|
||||
$isInternal = ('true' === $request->getParam('internal', 'false'));
|
||||
$router = $request->getRouter();
|
||||
|
||||
$return['links']['broadcasts'] = $router->fromHere(
|
||||
$return['links']['broadcasts'] = $request->getRouter()->fromHere(
|
||||
'api:stations:streamer:broadcasts',
|
||||
['id' => $record->getId()],
|
||||
[],
|
||||
|
|
|
@ -22,11 +22,10 @@ class GetWaveformAction
|
|||
|
||||
$station = $request->getStation();
|
||||
|
||||
$fsStation = new StationFilesystems($station);
|
||||
$fsMedia = $fsStation->getMediaFilesystem();
|
||||
$fsMedia = (new StationFilesystems($station))->getMediaFilesystem();
|
||||
|
||||
// If a timestamp delimiter is added, strip it automatically.
|
||||
$media_id = explode('-', $media_id)[0];
|
||||
$media_id = explode('-', $media_id, 2)[0];
|
||||
|
||||
if (StationMedia::UNIQUE_ID_LENGTH === strlen($media_id)) {
|
||||
$waveformPath = StationMedia::getWaveformPath($media_id);
|
||||
|
|
|
@ -31,7 +31,7 @@ class ForgotPasswordAction
|
|||
if ($request->isPost()) {
|
||||
try {
|
||||
$rateLimit->checkRequestRateLimit($request, 'forgot', 30, 3);
|
||||
} catch (RateLimitExceededException $e) {
|
||||
} catch (RateLimitExceededException) {
|
||||
$flash->addMessage(
|
||||
sprintf(
|
||||
'<b>%s</b><br>%s',
|
||||
|
|
|
@ -49,7 +49,7 @@ class LoginAction
|
|||
if ($request->isPost()) {
|
||||
try {
|
||||
$rateLimit->checkRequestRateLimit($request, 'login', 30, 5);
|
||||
} catch (RateLimitExceededException $e) {
|
||||
} catch (RateLimitExceededException) {
|
||||
$flash->addMessage(
|
||||
sprintf(
|
||||
'<b>%s</b><br>%s',
|
||||
|
@ -69,6 +69,7 @@ class LoginAction
|
|||
$session = $request->getSession();
|
||||
if ($session instanceof SessionCookiePersistenceInterface) {
|
||||
$rememberMe = (bool)$request->getParam('remember', 0);
|
||||
/** @noinspection SummerTimeUnsafeTimeManipulationInspection */
|
||||
$session->persistSessionFor(($rememberMe) ? 86400 * 14 : 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,7 @@ class DashboardAction
|
|||
$acl = $request->getAcl();
|
||||
|
||||
// Detect current analytics level.
|
||||
$settings = $settingsRepo->readSettings();
|
||||
$analyticsLevel = $settings->getAnalytics();
|
||||
$analyticsLevel = $settingsRepo->readSettings()->getAnalytics();
|
||||
$showCharts = $analyticsLevel !== Entity\Analytics::LEVEL_NONE;
|
||||
|
||||
// Avatars
|
||||
|
|
|
@ -82,9 +82,7 @@ class ServiceWorkerAction
|
|||
$assets->load('minimal')
|
||||
->load('Vue_PublicFullPlayer');
|
||||
|
||||
$loadedFiles = $assets->getLoadedFiles();
|
||||
|
||||
foreach ($loadedFiles as $file) {
|
||||
foreach ($assets->getLoadedFiles() as $file) {
|
||||
if (!str_starts_with($file, 'http')) {
|
||||
$cacheFiles[] = $file;
|
||||
}
|
||||
|
@ -103,7 +101,7 @@ class ServiceWorkerAction
|
|||
$cacheFiles[] = $environment->getAssetUrl() . '/' . $file->getRelativePathname();
|
||||
}
|
||||
|
||||
$replaceString = 'const cacheFiles = ' . json_encode($cacheFiles) . ';';
|
||||
$replaceString = 'const cacheFiles = ' . json_encode($cacheFiles, JSON_THROW_ON_ERROR) . ';';
|
||||
|
||||
$swContents = str_replace($findString, $replaceString, $swContents);
|
||||
|
||||
|
|
|
@ -70,8 +70,7 @@ class EnableTwoFactorAction
|
|||
new BaconQrCode\Renderer\RendererStyle\RendererStyle(300),
|
||||
new BaconQrCode\Renderer\Image\SvgImageBackEnd()
|
||||
);
|
||||
$writer = new BaconQrCode\Writer($renderer);
|
||||
$qr_code = $writer->writeString($totp_uri);
|
||||
$qr_code = (new BaconQrCode\Writer($renderer))->writeString($totp_uri);
|
||||
|
||||
return $request->getView()->renderToResponse($response, 'frontend/profile/enable_two_factor', [
|
||||
'form' => $form,
|
||||
|
|
|
@ -17,7 +17,7 @@ class PlayerAction
|
|||
Entity\ApiGenerator\NowPlayingApiGenerator $npApiGenerator,
|
||||
Entity\Repository\CustomFieldRepository $customFieldRepo,
|
||||
Entity\Repository\StationRepository $stationRepo,
|
||||
$embed = false
|
||||
?string $embed = null
|
||||
): ResponseInterface {
|
||||
// Override system-wide iframe refusal
|
||||
$response = $response
|
||||
|
|
|
@ -36,8 +36,7 @@ class PlaylistAction
|
|||
];
|
||||
}
|
||||
|
||||
$remotes = $request->getStationRemotes();
|
||||
foreach ($remotes as $remote_proxy) {
|
||||
foreach ($request->getStationRemotes() as $remote_proxy) {
|
||||
$adapter = $remote_proxy->getAdapter();
|
||||
$remote = $remote_proxy->getRemote();
|
||||
|
||||
|
|
|
@ -207,8 +207,7 @@ class PodcastFeedController
|
|||
|
||||
protected function buildRssImageForPodcast(Podcast $podcast, Station $station): RssImage
|
||||
{
|
||||
$stationFilesystems = new StationFilesystems($station);
|
||||
$podcastsFilesystem = $stationFilesystems->getPodcastsFilesystem();
|
||||
$podcastsFilesystem = (new StationFilesystems($station))->getPodcastsFilesystem();
|
||||
|
||||
$rssImage = new RssImage();
|
||||
|
||||
|
@ -316,8 +315,7 @@ class PodcastFeedController
|
|||
|
||||
protected function buildItunesImageForEpisode(PodcastEpisode $episode, Station $station): string
|
||||
{
|
||||
$stationFilesystems = new StationFilesystems($station);
|
||||
$podcastsFilesystem = $stationFilesystems->getPodcastsFilesystem();
|
||||
$podcastsFilesystem = (new StationFilesystems($station))->getPodcastsFilesystem();
|
||||
|
||||
$episodeArtworkSrc = (string)UriResolver::resolve(
|
||||
$this->router->getBaseUrl(),
|
||||
|
|
|
@ -18,8 +18,7 @@ class ListenersController
|
|||
): ResponseInterface {
|
||||
$view = $request->getView();
|
||||
|
||||
$settings = $settingsRepo->readSettings();
|
||||
$analytics_level = $settings->getAnalytics();
|
||||
$analytics_level = $settingsRepo->readSettings()->getAnalytics();
|
||||
|
||||
if ($analytics_level !== Entity\Analytics::LEVEL_ALL) {
|
||||
return $view->renderToResponse($response, 'stations/reports/restricted');
|
||||
|
|
|
@ -15,8 +15,7 @@ class OverviewController
|
|||
Entity\Repository\SettingsRepository $settingsRepo
|
||||
): ResponseInterface {
|
||||
// Get current analytics level.
|
||||
$settings = $settingsRepo->readSettings();
|
||||
$analytics_level = $settings->getAnalytics();
|
||||
$analytics_level = $settingsRepo->readSettings()->getAnalytics();
|
||||
|
||||
if ($analytics_level === Entity\Analytics::LEVEL_NONE) {
|
||||
// The entirety of the dashboard can't be shown, so redirect user to the profile page.
|
||||
|
|
|
@ -34,11 +34,7 @@ class PerformanceController
|
|||
$report_data = array_filter(
|
||||
$report_data,
|
||||
static function ($media) {
|
||||
if (empty($media['playlists'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return !(empty($media['playlists']));
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -94,8 +94,7 @@ class SoundExchangeController
|
|||
$history_rows_by_id = array_column($history_rows, null, 'media_id');
|
||||
|
||||
// Remove any reference to the "Stream Offline" song.
|
||||
$offlineSong = Entity\Song::createOffline();
|
||||
$offline_song_hash = $offlineSong->getSongId();
|
||||
$offline_song_hash = Entity\Song::createOffline()->getSongId();
|
||||
unset($history_rows_by_id[$offline_song_hash]);
|
||||
|
||||
// Assemble report items
|
||||
|
@ -174,7 +173,7 @@ class SoundExchangeController
|
|||
}
|
||||
}
|
||||
return null;
|
||||
} catch (Throwable $e) {
|
||||
} catch (Throwable) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,7 @@ class WebhooksController extends AbstractStationCrudController
|
|||
/** @var Entity\StationWebhook $record */
|
||||
$record = $this->getRecord($station, $id);
|
||||
|
||||
$handler_response = $this->dispatcher->testDispatch($station, $record);
|
||||
$log_records = $handler_response->getRecords();
|
||||
$log_records = $this->dispatcher->testDispatch($station, $record)->getRecords();
|
||||
|
||||
return $request->getView()->renderToResponse($response, 'system/log_view', [
|
||||
'title' => __('Web Hook Test Output'),
|
||||
|
|
|
@ -190,7 +190,7 @@ final class BatchIteratorAggregate implements IteratorAggregate
|
|||
get_class($object),
|
||||
spl_object_hash($object),
|
||||
$metadata->getName(),
|
||||
json_encode($metadata->getIdentifierValues($object))
|
||||
json_encode($metadata->getIdentifierValues($object), JSON_THROW_ON_ERROR)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -88,8 +88,7 @@ class AuditLog implements EventSubscriber
|
|||
}
|
||||
|
||||
// Ensure the property isn't ignored.
|
||||
$property = $reflectionClass->getProperty($changeField);
|
||||
$ignoreAttr = $property->getAttributes(AuditIgnore::class);
|
||||
$ignoreAttr = $reflectionClass->getProperty($changeField)->getAttributes(AuditIgnore::class);
|
||||
if (!empty($ignoreAttr)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -51,8 +51,9 @@ class StationRequiresRestart implements EventSubscriber
|
|||
// Look for the @AuditIgnore annotation on a property.
|
||||
$class_reflection = new ReflectionObject($entity);
|
||||
foreach ($changes as $change_field => $changeset) {
|
||||
$property = $class_reflection->getProperty($change_field);
|
||||
$ignoreAttr = $property->getAttributes(AuditIgnore::class);
|
||||
$ignoreAttr = $class_reflection->getProperty($change_field)->getAttributes(
|
||||
AuditIgnore::class
|
||||
);
|
||||
if (!empty($ignoreAttr)) {
|
||||
unset($changes[$change_field]);
|
||||
}
|
||||
|
|
|
@ -94,8 +94,7 @@ class Repository
|
|||
// Assemble select values and, if necessary, call $display callback.
|
||||
foreach ((array)$results as $result) {
|
||||
$key = $result[$pk];
|
||||
$value = ($display === null) ? $result['name'] : $display($result);
|
||||
$select[$key] = $value;
|
||||
$select[$key] = ($display === null) ? $result['name'] : $display($result);
|
||||
}
|
||||
|
||||
return $select;
|
||||
|
|
|
@ -97,8 +97,7 @@ class Analytics
|
|||
public function getMomentInStationTimeZone(): CarbonImmutable
|
||||
{
|
||||
$tz = $this->station->getTimezoneObject();
|
||||
$timestamp = CarbonImmutable::parse($this->moment, $tz);
|
||||
return $timestamp->shiftTimezone($tz);
|
||||
return CarbonImmutable::parse($this->moment, $tz)->shiftTimezone($tz);
|
||||
}
|
||||
|
||||
public function getNumberMin(): int
|
||||
|
|
|
@ -43,15 +43,15 @@ class SongApiGenerator
|
|||
bool $allowRemoteArt = false
|
||||
): Entity\Api\Song {
|
||||
$response = new Entity\Api\Song();
|
||||
$response->id = (string)$song->getSongId();
|
||||
$response->text = (string)$song->getText();
|
||||
$response->artist = (string)$song->getArtist();
|
||||
$response->title = (string)$song->getTitle();
|
||||
$response->id = $song->getSongId();
|
||||
$response->text = $song->getText() ?? '';
|
||||
$response->artist = $song->getArtist() ?? '';
|
||||
$response->title = $song->getTitle() ?? '';
|
||||
|
||||
if ($song instanceof Entity\StationMedia) {
|
||||
$response->album = (string)$song->getAlbum();
|
||||
$response->genre = (string)$song->getGenre();
|
||||
$response->lyrics = (string)$song->getLyrics();
|
||||
$response->album = $song->getAlbum() ?? '';
|
||||
$response->genre = $song->getGenre() ?? '';
|
||||
$response->lyrics = $song->getLyrics() ?? '';
|
||||
|
||||
$response->custom_fields = $this->getCustomFields($song->getId());
|
||||
} else {
|
||||
|
|
|
@ -87,7 +87,7 @@ class AuditLog
|
|||
*/
|
||||
public static function setCurrentUser(?User $user = null): void
|
||||
{
|
||||
self::$currentUser = ($user instanceof User)
|
||||
self::$currentUser = (null !== $user)
|
||||
? (string)$user
|
||||
: null;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@ class PodcastEpisode extends AbstractFixture implements DependentFixtureInterfac
|
|||
/** @var Entity\Podcast $podcast */
|
||||
$podcast = $this->getReference('podcast');
|
||||
|
||||
$storageLocation = $podcast->getStorageLocation();
|
||||
$fs = $storageLocation->getFilesystem();
|
||||
$fs = $podcast->getStorageLocation()->getFilesystem();
|
||||
|
||||
$finder = (new Finder())
|
||||
->files()
|
||||
|
|
|
@ -10,8 +10,7 @@ class Settings extends AbstractFixture
|
|||
{
|
||||
public function load(ObjectManager $em): void
|
||||
{
|
||||
$existingSettings = $em->getRepository(Entity\Settings::class)->findAll();
|
||||
foreach ($existingSettings as $row) {
|
||||
foreach ($em->getRepository(Entity\Settings::class)->findAll() as $row) {
|
||||
$em->remove($row);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ use App\Entity;
|
|||
use App\Radio\Adapters;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use RuntimeException;
|
||||
|
||||
class Station extends AbstractFixture
|
||||
{
|
||||
|
|
|
@ -21,28 +21,32 @@ final class Version20161117000718 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$all_stations = $this->connection->fetchAll('SELECT * FROM station');
|
||||
foreach ($this->connection->fetchAllAssociative('SELECT * FROM station') as $station) {
|
||||
$this->connection->insert(
|
||||
'station_mounts',
|
||||
[
|
||||
'station_id' => $station['id'],
|
||||
'name' => '/radio.mp3',
|
||||
'is_default' => 1,
|
||||
'fallback_mount' => '/autodj.mp3',
|
||||
'enable_streamers' => 1,
|
||||
'enable_autodj' => 0,
|
||||
]
|
||||
);
|
||||
|
||||
foreach ($all_stations as $station) {
|
||||
$this->connection->insert('station_mounts', [
|
||||
'station_id' => $station['id'],
|
||||
'name' => '/radio.mp3',
|
||||
'is_default' => 1,
|
||||
'fallback_mount' => '/autodj.mp3',
|
||||
'enable_streamers' => 1,
|
||||
'enable_autodj' => 0,
|
||||
]);
|
||||
|
||||
$this->connection->insert('station_mounts', [
|
||||
'station_id' => $station['id'],
|
||||
'name' => '/autodj.mp3',
|
||||
'is_default' => 0,
|
||||
'fallback_mount' => '/error.mp3',
|
||||
'enable_streamers' => 0,
|
||||
'enable_autodj' => 1,
|
||||
'autodj_format' => 'mp3',
|
||||
'autodj_bitrate' => 128,
|
||||
]);
|
||||
$this->connection->insert(
|
||||
'station_mounts',
|
||||
[
|
||||
'station_id' => $station['id'],
|
||||
'name' => '/autodj.mp3',
|
||||
'is_default' => 0,
|
||||
'fallback_mount' => '/error.mp3',
|
||||
'enable_streamers' => 0,
|
||||
'enable_autodj' => 1,
|
||||
'autodj_format' => 'mp3',
|
||||
'autodj_bitrate' => 128,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@ final class Version20170412210654 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$all_stations = $this->connection->fetchAll("SELECT * FROM station WHERE frontend_type='shoutcast2'");
|
||||
$all_stations = $this->connection->fetchAllAssociative(
|
||||
"SELECT * FROM station WHERE frontend_type='shoutcast2'"
|
||||
);
|
||||
|
||||
foreach ($all_stations as $station) {
|
||||
$this->connection->insert('station_mounts', [
|
||||
|
|
|
@ -20,16 +20,18 @@ final class Version20170510082607 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$all_stations = $this->connection->fetchAll('SELECT * FROM station');
|
||||
|
||||
foreach ($all_stations as $station) {
|
||||
$this->connection->update('station', [
|
||||
'radio_media_dir' => $station['radio_base_dir'] . '/media',
|
||||
'radio_playlists_dir' => $station['radio_base_dir'] . '/playlists',
|
||||
'radio_config_dir' => $station['radio_base_dir'] . '/config',
|
||||
], [
|
||||
'id' => $station['id'],
|
||||
]);
|
||||
foreach ($this->connection->fetchAllAssociative('SELECT * FROM station') as $station) {
|
||||
$this->connection->update(
|
||||
'station',
|
||||
[
|
||||
'radio_media_dir' => $station['radio_base_dir'] . '/media',
|
||||
'radio_playlists_dir' => $station['radio_base_dir'] . '/playlists',
|
||||
'radio_config_dir' => $station['radio_base_dir'] . '/config',
|
||||
],
|
||||
[
|
||||
'id' => $station['id'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,16 @@ final class Version20170510085226 extends AbstractMigration
|
|||
|
||||
public function postdown(Schema $schema): void
|
||||
{
|
||||
$all_stations = $this->connection->fetchAll('SELECT * FROM station');
|
||||
|
||||
foreach ($all_stations as $station) {
|
||||
$this->connection->update('station', [
|
||||
'radio_base_dir' => str_replace('/media', '', $station['radio_media_dir']),
|
||||
], [
|
||||
'id' => $station['id'],
|
||||
]);
|
||||
foreach ($this->connection->fetchAllAssociative('SELECT * FROM station') as $station) {
|
||||
$this->connection->update(
|
||||
'station',
|
||||
[
|
||||
'radio_base_dir' => str_replace('/media', '', $station['radio_media_dir']),
|
||||
],
|
||||
[
|
||||
'id' => $station['id'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,16 @@ final class Version20170510091820 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$all_stations = $this->connection->fetchAll('SELECT * FROM station');
|
||||
|
||||
foreach ($all_stations as $station) {
|
||||
$this->connection->update('station', [
|
||||
'radio_base_dir' => str_replace('/media', '', $station['radio_media_dir']),
|
||||
], [
|
||||
'id' => $station['id'],
|
||||
]);
|
||||
foreach ($this->connection->fetchAllAssociative('SELECT * FROM station') as $station) {
|
||||
$this->connection->update(
|
||||
'station',
|
||||
[
|
||||
'radio_base_dir' => str_replace('/media', '', $station['radio_media_dir']),
|
||||
],
|
||||
[
|
||||
'id' => $station['id'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,9 @@ final class Version20170719045113 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$this->connection->exec('UPDATE song_history SET sent_to_autodj=1 WHERE timestamp_cued != 0 AND timestamp_cued IS NOT NULL');
|
||||
$this->connection->executeStatement(
|
||||
'UPDATE song_history SET sent_to_autodj=1 WHERE timestamp_cued != 0 AND timestamp_cued IS NOT NULL'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,14 +20,16 @@ final class Version20171104014701 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$all_records = $this->connection->fetchAll('SELECT * FROM station_media');
|
||||
|
||||
foreach ($all_records as $record) {
|
||||
$this->connection->update('station_media', [
|
||||
'unique_id' => bin2hex(random_bytes(12)),
|
||||
], [
|
||||
'id' => $record['id'],
|
||||
]);
|
||||
foreach ($this->connection->fetchAllAssociative('SELECT * FROM station_media') as $record) {
|
||||
$this->connection->update(
|
||||
'station_media',
|
||||
[
|
||||
'unique_id' => bin2hex(random_bytes(12)),
|
||||
],
|
||||
[
|
||||
'id' => $record['id'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,14 +20,16 @@ final class Version20171208093239 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$all_records = $this->connection->fetchAll('SELECT * FROM station');
|
||||
|
||||
foreach ($all_records as $record) {
|
||||
$this->connection->update('station', [
|
||||
'short_name' => Station::getStationShortName($record['name']),
|
||||
], [
|
||||
'id' => $record['id'],
|
||||
]);
|
||||
foreach ($this->connection->fetchAllAssociative('SELECT * FROM station') as $record) {
|
||||
$this->connection->update(
|
||||
'station',
|
||||
[
|
||||
'short_name' => Station::getStationShortName($record['name']),
|
||||
],
|
||||
[
|
||||
'id' => $record['id'],
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ final class Version20171214104226 extends AbstractMigration
|
|||
public function preup(Schema $schema): void
|
||||
{
|
||||
// Deleting duplicate user accounts to avoid constraint errors in subsequent update
|
||||
$users = $this->connection->fetchAll('SELECT * FROM users ORDER BY uid ASC');
|
||||
$users = $this->connection->fetchAllAssociative('SELECT * FROM users ORDER BY uid ASC');
|
||||
$emails = [];
|
||||
|
||||
foreach ($users as $row) {
|
||||
|
|
|
@ -15,7 +15,9 @@ final class Version20180320052444 extends AbstractMigration
|
|||
public function preup(Schema $schema): void
|
||||
{
|
||||
// Avoid FK errors with station art
|
||||
$this->connection->exec('DELETE FROM station_media_art WHERE media_id NOT IN (SELECT id FROM station_media)');
|
||||
$this->connection->executeStatement(
|
||||
'DELETE FROM station_media_art WHERE media_id NOT IN (SELECT id FROM station_media)'
|
||||
);
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
|
|
|
@ -19,7 +19,7 @@ final class Version20180324053351 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$this->connection->exec('UPDATE station SET is_enabled=1');
|
||||
$this->connection->executeStatement('UPDATE station SET is_enabled=1');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
|
|
|
@ -20,10 +20,14 @@ final class Version20180909035413 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$stations = $this->connection->fetchAll("SELECT id, frontend_config FROM station WHERE frontend_type = 'remote'");
|
||||
$stations = $this->connection->fetchAllAssociative(
|
||||
"SELECT id, frontend_config FROM station WHERE frontend_type = 'remote'"
|
||||
);
|
||||
|
||||
foreach ($stations as $station) {
|
||||
$mounts = $this->connection->fetchAll('SELECT * FROM station_mounts WHERE station_id = ' . $station['id']);
|
||||
$mounts = $this->connection->fetchAllAssociative(
|
||||
'SELECT * FROM station_mounts WHERE station_id = ' . $station['id']
|
||||
);
|
||||
|
||||
if (count($mounts) === 0) {
|
||||
$settings = json_decode($station['frontend_config'], true, 512, JSON_THROW_ON_ERROR);
|
||||
|
|
|
@ -19,7 +19,7 @@ final class Version20180909060758 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$stations = $this->connection->fetchAll("SELECT id FROM station WHERE frontend_type = 'remote'");
|
||||
$stations = $this->connection->fetchAllAssociative("SELECT id FROM station WHERE frontend_type = 'remote'");
|
||||
|
||||
foreach ($stations as $station) {
|
||||
$this->connection->delete('station_mounts', [
|
||||
|
|
|
@ -20,7 +20,7 @@ final class Version20181016144143 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$shuffled_playlists = $this->connection->fetchAll(
|
||||
$shuffled_playlists = $this->connection->fetchAllAssociative(
|
||||
'SELECT sp.* FROM station_playlists AS sp WHERE sp.playback_order = :order',
|
||||
[
|
||||
'order' => 'shuffle',
|
||||
|
@ -28,7 +28,7 @@ final class Version20181016144143 extends AbstractMigration
|
|||
);
|
||||
|
||||
foreach ($shuffled_playlists as $playlist) {
|
||||
$all_media = $this->connection->fetchAll(
|
||||
$all_media = $this->connection->fetchAllAssociative(
|
||||
'SELECT spm.* FROM station_playlist_media AS spm WHERE spm.playlist_id = :playlist_id ORDER BY RAND()',
|
||||
[
|
||||
'playlist_id' => $playlist['id'],
|
||||
|
|
|
@ -16,9 +16,7 @@ final class Version20181202180617 extends AbstractMigration
|
|||
{
|
||||
public function preup(Schema $schema): void
|
||||
{
|
||||
$stations = $this->connection->fetchAll('SELECT s.* FROM station AS s');
|
||||
|
||||
foreach ($stations as $station) {
|
||||
foreach ($this->connection->fetchAllAssociative('SELECT s.* FROM station AS s') as $station) {
|
||||
$this->write('Migrating album art for station "' . $station['name'] . '"...');
|
||||
|
||||
$base_dir = $station['radio_base_dir'];
|
||||
|
@ -27,12 +25,16 @@ final class Version20181202180617 extends AbstractMigration
|
|||
throw new RuntimeException(sprintf('Directory "%s" was not created', $art_dir));
|
||||
}
|
||||
|
||||
$stmt = $this->connection->executeQuery('SELECT sm.unique_id, sma.art
|
||||
$stmt = $this->connection->executeQuery(
|
||||
'SELECT sm.unique_id, sma.art
|
||||
FROM station_media AS sm
|
||||
JOIN station_media_art sma on sm.id = sma.media_id
|
||||
WHERE sm.station_id = ?', [$station['id']], [ParameterType::INTEGER]);
|
||||
WHERE sm.station_id = ?',
|
||||
[$station['id']],
|
||||
[ParameterType::INTEGER]
|
||||
);
|
||||
|
||||
while ($art_row = $stmt->fetch()) {
|
||||
while ($art_row = $stmt->fetchAssociative()) {
|
||||
$art_path = $art_dir . '/' . $art_row['unique_id'] . '.jpg';
|
||||
file_put_contents($art_path, $art_row['art']);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ final class Version20190429025906 extends AbstractMigration
|
|||
|
||||
public function postup(Schema $schema): void
|
||||
{
|
||||
$playlists = $this->connection->fetchAll('SELECT sp.* FROM station_playlists AS sp');
|
||||
$playlists = $this->connection->fetchAllAssociative('SELECT sp.* FROM station_playlists AS sp');
|
||||
|
||||
foreach ($playlists as $playlist) {
|
||||
$backend_options = [];
|
||||
|
|
|
@ -27,7 +27,7 @@ final class Version20190513163051 extends AbstractMigration
|
|||
public function postup(Schema $schema): void
|
||||
{
|
||||
// Use the system setting for "global timezone" to set the station timezones.
|
||||
$global_tz = $this->connection->fetchColumn('SELECT setting_value FROM settings WHERE setting_key="timezone"');
|
||||
$global_tz = $this->connection->fetchOne('SELECT setting_value FROM settings WHERE setting_key="timezone"');
|
||||
|
||||
if (!empty($global_tz)) {
|
||||
$global_tz = json_decode($global_tz, true, 512, JSON_THROW_ON_ERROR);
|
||||
|
@ -54,7 +54,9 @@ final class Version20190513163051 extends AbstractMigration
|
|||
$offset_hours = (int)floor($offset / 3600);
|
||||
|
||||
if (0 !== $offset_hours) {
|
||||
$playlists = $this->connection->fetchAll('SELECT sp.* FROM station_playlists AS sp WHERE sp.type = "scheduled"');
|
||||
$playlists = $this->connection->fetchAllAssociative(
|
||||
'SELECT sp.* FROM station_playlists AS sp WHERE sp.type = "scheduled"'
|
||||
);
|
||||
|
||||
foreach ($playlists as $playlist) {
|
||||
$this->connection->update('station_playlists', [
|
||||
|
@ -73,6 +75,7 @@ final class Version20190513163051 extends AbstractMigration
|
|||
* @param int $offset_hours
|
||||
*
|
||||
* @return int
|
||||
* @noinspection SummerTimeUnsafeTimeManipulationInspection
|
||||
*/
|
||||
protected function applyOffset(mixed $time_code, int $offset_hours): int
|
||||
{
|
||||
|
|
|
@ -21,9 +21,7 @@ final class Version20191024185005 extends AbstractMigration
|
|||
|
||||
public function postUp(Schema $schema): void
|
||||
{
|
||||
$stations = $this->connection->fetchAll('SELECT s.* FROM station AS s');
|
||||
|
||||
foreach ($stations as $station) {
|
||||
foreach ($this->connection->fetchAllAssociative('SELECT s.* FROM station AS s') as $station) {
|
||||
$this->write('Migrating album art for station "' . $station['name'] . '"...');
|
||||
|
||||
$baseDir = $station['radio_base_dir'];
|
||||
|
@ -38,7 +36,7 @@ final class Version20191024185005 extends AbstractMigration
|
|||
$mediaRowsTotal = 0;
|
||||
$mediaRowsToUpdate = [];
|
||||
|
||||
while ($row = $getMediaQuery->fetch()) {
|
||||
while ($row = $getMediaQuery->fetchAssociative()) {
|
||||
$mediaRowsTotal++;
|
||||
$artPath = $artDir . '/' . $row['unique_id'] . '.jpg';
|
||||
|
||||
|
@ -49,7 +47,7 @@ final class Version20191024185005 extends AbstractMigration
|
|||
|
||||
$this->write('Album art exists for ' . count($mediaRowsToUpdate) . ' of ' . $mediaRowsTotal . ' media.');
|
||||
|
||||
$this->connection->executeUpdate(
|
||||
$this->connection->executeStatement(
|
||||
'UPDATE station_media SET art_updated_at=UNIX_TIMESTAMP() WHERE unique_id IN (?)',
|
||||
[$mediaRowsToUpdate],
|
||||
[Connection::PARAM_STR_ARRAY]
|
||||
|
|
|
@ -21,7 +21,7 @@ final class Version20191101065730 extends AbstractMigration
|
|||
|
||||
public function postUp(Schema $schema): void
|
||||
{
|
||||
$playlists = $this->connection->fetchAll(
|
||||
$playlists = $this->connection->fetchAllAssociative(
|
||||
'SELECT sp.* FROM station_playlists AS sp WHERE sp.type = ?',
|
||||
['scheduled'],
|
||||
[PDO::PARAM_STR]
|
||||
|
|
|
@ -22,7 +22,9 @@ final class Version20200129010322 extends AbstractMigration
|
|||
public function preUp(Schema $schema): void
|
||||
{
|
||||
// Deleting duplicate streamers to avoid constraint errors in subsequent update
|
||||
$streamers = $this->connection->fetchAll('SELECT * FROM station_streamers ORDER BY station_id, id ASC');
|
||||
$streamers = $this->connection->fetchAllAssociative(
|
||||
'SELECT * FROM station_streamers ORDER BY station_id, id ASC'
|
||||
);
|
||||
$accounts = [];
|
||||
|
||||
foreach ($streamers as $row) {
|
||||
|
@ -46,7 +48,9 @@ final class Version20200129010322 extends AbstractMigration
|
|||
public function postUp(Schema $schema): void
|
||||
{
|
||||
// Hash DJ passwords that are currently stored in plaintext.
|
||||
$streamers = $this->connection->fetchAll('SELECT * FROM station_streamers ORDER BY station_id, id ASC');
|
||||
$streamers = $this->connection->fetchAllAssociative(
|
||||
'SELECT * FROM station_streamers ORDER BY station_id, id ASC'
|
||||
);
|
||||
|
||||
foreach ($streamers as $row) {
|
||||
$this->connection->update('station_streamers', [
|
||||
|
|
|
@ -24,7 +24,7 @@ final class Version20200604075356 extends AbstractMigration
|
|||
|
||||
public function postUp(Schema $schema): void
|
||||
{
|
||||
$this->connection->executeUpdate('UPDATE station_playlists SET avoid_duplicates=1');
|
||||
$this->connection->executeStatement('UPDATE station_playlists SET avoid_duplicates=1');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
|
|
|
@ -19,8 +19,8 @@ final class Version20200816092130 extends AbstractMigration
|
|||
|
||||
public function preUp(Schema $schema): void
|
||||
{
|
||||
$this->connection->query('DELETE FROM song_history WHERE timestamp_start = 0');
|
||||
$this->connection->query('UPDATE station SET nowplaying=null, nowplaying_timestamp=0');
|
||||
$this->connection->executeStatement('DELETE FROM song_history WHERE timestamp_start = 0');
|
||||
$this->connection->executeStatement('UPDATE station SET nowplaying=null, nowplaying_timestamp=0');
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
|
|
|
@ -44,7 +44,7 @@ final class Version20201027130504 extends AbstractMigration
|
|||
);
|
||||
|
||||
// Migrate existing directories to new StorageLocation paradigm.
|
||||
$stations = $this->connection->fetchAll(
|
||||
$stations = $this->connection->fetchAllAssociative(
|
||||
'SELECT id, radio_base_dir, radio_media_dir, storage_quota FROM station WHERE media_storage_location_id IS NULL ORDER BY id ASC'
|
||||
);
|
||||
|
||||
|
|
|
@ -27,13 +27,12 @@ final class Version20210419043231 extends AbstractMigration
|
|||
|
||||
foreach ($oldSettingsRaw as $row) {
|
||||
$key = $row['setting_key'];
|
||||
$key = preg_replace('~(?<=\\w)([A-Z])~u', '_$1', $key);
|
||||
$key = mb_strtolower($key);
|
||||
$key = mb_strtolower(preg_replace('~(?<=\\w)([A-Z])~u', '_$1', $key));
|
||||
|
||||
$value = $row['setting_value'];
|
||||
$value = ($value === null || $value === '')
|
||||
? null
|
||||
: json_decode($value, true);
|
||||
: json_decode($value, true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
$oldSettings[$key] = $value;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue