Skip to content

Commit 44d9c38

Browse files
committed
TASK: Remove JSON_THROW_ON_ERROR for PHP 7.2 compatibility
1 parent cbd99b2 commit 44d9c38

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

Classes/Command/NodeIndexCommandController.php

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ class NodeIndexCommandController extends CommandController
158158
* @throws RuntimeException
159159
* @throws SubProcessException
160160
* @throws \Flowpack\ElasticSearch\Exception
161-
* @throws \JsonException
162161
*/
163162
public function indexNodeCommand(string $identifier, string $workspace = null, string $postfix = null): void
164163
{
@@ -180,13 +179,13 @@ public function indexNodeCommand(string $identifier, string $workspace = null, s
180179
$node = $context->getNodeByIdentifier($identifier);
181180

182181
if ($node === null) {
183-
return [$workspace->getName(), '-', json_encode($dimensions, JSON_THROW_ON_ERROR), 'not found'];
182+
return [$workspace->getName(), '-', json_encode($dimensions), 'not found'];
184183
}
185184

186185
$this->nodeIndexer->setDimensions($dimensions);
187186
$this->nodeIndexer->indexNode($node);
188187

189-
return [$workspace->getName(), $node->getNodeType()->getName(), json_encode($dimensions, JSON_THROW_ON_ERROR), '<success>indexed</success>'];
188+
return [$workspace->getName(), $node->getNodeType()->getName(), json_encode($dimensions), '<success>indexed</success>'];
190189
};
191190

192191
$indexInWorkspace = function ($identifier, Workspace $workspace) use ($indexNode) {
@@ -227,7 +226,7 @@ public function indexNodeCommand(string $identifier, string $workspace = null, s
227226

228227
foreach ($combinations as $combination) {
229228
$this->executeInternalCommand('aliasInternal', [
230-
'dimensionsValues' => json_encode($combination, JSON_THROW_ON_ERROR),
229+
'dimensionsValues' => json_encode($combination),
231230
'postfix' => $postfix,
232231
'update' => false
233232
]);
@@ -268,7 +267,7 @@ public function buildCommand(int $limit = null, bool $update = false, string $wo
268267

269268
$createIndicesAndApplyMapping = function (array $dimensionsValues) use ($update, $postfix) {
270269
$this->executeInternalCommand('createInternal', [
271-
'dimensionsValues' => json_encode($dimensionsValues, JSON_THROW_ON_ERROR),
270+
'dimensionsValues' => json_encode($dimensionsValues),
272271
'update' => $update,
273272
'postfix' => $postfix,
274273
]);
@@ -280,14 +279,14 @@ public function buildCommand(int $limit = null, bool $update = false, string $wo
280279

281280
$refresh = function (array $dimensionsValues) use ($postfix) {
282281
$this->executeInternalCommand('refreshInternal', [
283-
'dimensionsValues' => json_encode($dimensionsValues, JSON_THROW_ON_ERROR),
282+
'dimensionsValues' => json_encode($dimensionsValues),
284283
'postfix' => $postfix,
285284
]);
286285
};
287286

288287
$updateAliases = function (array $dimensionsValues) use ($update, $postfix) {
289288
$this->executeInternalCommand('aliasInternal', [
290-
'dimensionsValues' => json_encode($dimensionsValues, JSON_THROW_ON_ERROR),
289+
'dimensionsValues' => json_encode($dimensionsValues),
291290
'postfix' => $postfix,
292291
'update' => $update,
293292
]);
@@ -353,7 +352,6 @@ private function aliasesExist(): bool
353352
* @throws Exception
354353
* @throws RuntimeException
355354
* @throws SubProcessException
356-
* @throws \JsonException
357355
*/
358356
private function build(array $dimensionsValues, ?string $workspace = null, ?string $postfix = null, ?int $limit = null): void
359357
{
@@ -368,7 +366,7 @@ private function build(array $dimensionsValues, ?string $workspace = null, ?stri
368366
$buildWorkspaceCommandOptions = static function ($workspace, array $dimensionsValues, ?int $limit, ?string $postfix) {
369367
return [
370368
'workspace' => $workspace instanceof Workspace ? $workspace->getName() : $workspace,
371-
'dimensionsValues' => json_encode($dimensionsValues, JSON_THROW_ON_ERROR),
369+
'dimensionsValues' => json_encode($dimensionsValues),
372370
'postfix' => $postfix,
373371
'limit' => $limit,
374372
];
@@ -414,13 +412,13 @@ public function createInternalCommand(string $dimensionsValues, bool $update = f
414412
if ($update === true) {
415413
$this->logger->warning('!!! Update Mode (Development) active!', LogEnvironment::fromMethodName(__METHOD__));
416414
} else {
417-
$dimensionsValuesArray = $this->configureNodeIndexer(json_decode($dimensionsValues, true, 512, JSON_THROW_ON_ERROR), $postfix);
415+
$dimensionsValuesArray = $this->configureNodeIndexer(json_decode($dimensionsValues, true, 512), $postfix);
418416
if ($this->nodeIndexer->getIndex()->exists() === true) {
419417
$this->logger->warning(sprintf('Deleted index with the same postfix (%s)!', $postfix), LogEnvironment::fromMethodName(__METHOD__));
420418
$this->nodeIndexer->getIndex()->delete();
421419
}
422420
$this->nodeIndexer->getIndex()->create();
423-
$this->logger->info('Created index ' . $this->nodeIndexer->getIndexName() . ' with dimensions ' . json_encode($dimensionsValuesArray, JSON_THROW_ON_ERROR), LogEnvironment::fromMethodName(__METHOD__));
421+
$this->logger->info('Created index ' . $this->nodeIndexer->getIndexName() . ' with dimensions ' . json_encode($dimensionsValuesArray), LogEnvironment::fromMethodName(__METHOD__));
424422
}
425423

426424
$this->applyMapping();
@@ -434,17 +432,16 @@ public function createInternalCommand(string $dimensionsValues, bool $update = f
434432
* @param int|null $limit
435433
* @return void
436434
* @Flow\Internal
437-
* @throws \JsonException
438435
*/
439436
public function buildWorkspaceInternalCommand(string $workspace, string $dimensionsValues, string $postfix, int $limit = null): void
440437
{
441-
$dimensionsValuesArray = $this->configureNodeIndexer(json_decode($dimensionsValues, true, 512, JSON_THROW_ON_ERROR), $postfix);
438+
$dimensionsValuesArray = $this->configureNodeIndexer(json_decode($dimensionsValues, true, 512), $postfix);
442439

443440
$workspaceLogger = function ($workspaceName, $indexedNodes, $dimensions) {
444441
if ($dimensions === []) {
445442
$message = 'Workspace "' . $workspaceName . '" without dimensions done. (Indexed ' . $indexedNodes . ' nodes)';
446443
} else {
447-
$message = 'Workspace "' . $workspaceName . '" and dimensions "' . json_encode($dimensions, JSON_THROW_ON_ERROR) . '" done. (Indexed ' . $indexedNodes . ' nodes)';
444+
$message = 'Workspace "' . $workspaceName . '" and dimensions "' . json_encode($dimensions) . '" done. (Indexed ' . $indexedNodes . ' nodes)';
448445
}
449446
$this->outputLine($message);
450447
};
@@ -463,12 +460,11 @@ public function buildWorkspaceInternalCommand(string $workspace, string $dimensi
463460
* @throws \Flowpack\ElasticSearch\Exception
464461
* @throws \Neos\Flow\Http\Exception
465462
* @throws ConfigurationException
466-
* @throws \JsonException
467463
* @Flow\Internal
468464
*/
469465
public function refreshInternalCommand(string $dimensionsValues, string $postfix): void
470466
{
471-
$this->configureNodeIndexer(json_decode($dimensionsValues, true, 512, JSON_THROW_ON_ERROR), $postfix);
467+
$this->configureNodeIndexer(json_decode($dimensionsValues, true, 512), $postfix);
472468

473469
$this->logger->info(vsprintf('Refreshing index %s', [$this->nodeIndexer->getIndexName()]), LogEnvironment::fromMethodName(__METHOD__));
474470
$this->nodeIndexer->getIndex()->refresh();
@@ -484,15 +480,14 @@ public function refreshInternalCommand(string $dimensionsValues, string $postfix
484480
* @throws \Flowpack\ElasticSearch\Exception
485481
* @throws ApiException
486482
* @throws ConfigurationException
487-
* @throws \JsonException
488483
* @Flow\Internal
489484
*/
490485
public function aliasInternalCommand(string $dimensionsValues, string $postfix, bool $update = false): void
491486
{
492487
if ($update === true) {
493488
return;
494489
}
495-
$this->configureNodeIndexer(json_decode($dimensionsValues, true, 512, JSON_THROW_ON_ERROR), $postfix);
490+
$this->configureNodeIndexer(json_decode($dimensionsValues, true, 512), $postfix);
496491

497492
$this->logger->info(vsprintf('Update alias for index %s', [$this->nodeIndexer->getIndexName()]), LogEnvironment::fromMethodName(__METHOD__));
498493
$this->nodeIndexer->updateIndexAlias();
@@ -517,7 +512,6 @@ private function configureNodeIndexer(array $dimensionsValues, string $postfix):
517512
* @return void
518513
* @throws ConfigurationException
519514
* @throws Exception
520-
* @throws \JsonException
521515
*/
522516
public function cleanupCommand(): void
523517
{
@@ -534,7 +528,7 @@ public function cleanupCommand(): void
534528
}
535529
} catch (ApiException $exception) {
536530
$exception->getResponse()->getBody()->rewind();
537-
$response = json_decode($exception->getResponse()->getBody()->getContents(), false, 512, JSON_THROW_ON_ERROR);
531+
$response = json_decode($exception->getResponse()->getBody()->getContents(), false, 512);
538532
$message = sprintf('Nothing removed. ElasticSearch responded with status %s', $response->status);
539533

540534
if (isset($response->error->type)) {
@@ -565,7 +559,6 @@ private function outputErrorHandling(): void
565559
* @return string
566560
* @throws RuntimeException
567561
* @throws SubProcessException
568-
* @throws \JsonException
569562
*/
570563
private function executeInternalCommand(string $command, array $arguments): string
571564
{
@@ -576,7 +569,7 @@ private function executeInternalCommand(string $command, array $arguments): stri
576569
$status = Scripts::executeCommand($commandIdentifier, $this->flowSettings, true, array_filter($arguments));
577570

578571
if ($status !== true) {
579-
throw new RuntimeException(vsprintf('Command: %s with parameters: %s', [$commandIdentifier, json_encode($arguments, JSON_THROW_ON_ERROR)]), 1426767159);
572+
throw new RuntimeException(vsprintf('Command: %s with parameters: %s', [$commandIdentifier, json_encode($arguments)]), 1426767159);
580573
}
581574
} else {
582575
$commandIdentifier = $command . 'Command';

0 commit comments

Comments
 (0)