diff --git a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php index 5d438d3a5..8b69216b6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/LinkedToPerson/ListActivity.php @@ -152,7 +152,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return 'circle'; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'type_name': @@ -161,7 +161,7 @@ class ListActivity implements ListInterface, GroupedExportInterface return 'activity type'; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; default: diff --git a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php index 0e8b28ab4..fae6ea6a6 100644 --- a/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php +++ b/src/Bundle/ChillActivityBundle/Export/Export/ListActivityHelper.php @@ -179,7 +179,7 @@ class ListActivityHelper } } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); return implode( '|', diff --git a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php index 6bd12a07a..bccf797e5 100644 --- a/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php +++ b/src/Bundle/ChillCustomFieldsBundle/Form/DataTransformer/JsonCustomFieldToArrayTransformer.php @@ -108,7 +108,7 @@ class JsonCustomFieldToArrayTransformer implements DataTransformerInterface //echo json_encode($customFieldsArrayRet); - return json_encode($customFieldsArrayRet); + return json_encode($customFieldsArrayRet, JSON_THROW_ON_ERROR); } public function transform($customFieldsJSON) diff --git a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php index 0f62931b4..c14b67df7 100644 --- a/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php +++ b/src/Bundle/ChillDocGeneratorBundle/GeneratorDriver/RelatorioDriver.php @@ -44,7 +44,7 @@ final class RelatorioDriver implements DriverInterface { $form = new FormDataPart( [ - 'variables' => json_encode($data), + 'variables' => json_encode($data, JSON_THROW_ON_ERROR), 'template' => new DataPart($template, $templateName ?? uniqid('template_'), $resourceType), ] ); @@ -61,7 +61,7 @@ final class RelatorioDriver implements DriverInterface $content = $e->getResponse()->getContent(false); if (400 === $e->getResponse()->getStatusCode()) { - $content = json_decode($content, true); + $content = json_decode($content, true, 512, JSON_THROW_ON_ERROR); $this->logger->error('relatorio: template error', [ 'error' => $content['message'] ?? '_not defined', ]); diff --git a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index 664e7a2aa..4f3cd315f 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php @@ -95,7 +95,7 @@ class StoredObjectType extends AbstractType return null; } - return json_decode($value, true); + return json_decode($value, true, 512, JSON_THROW_ON_ERROR); } public function reverseTransformObject($object) @@ -120,7 +120,7 @@ class StoredObjectType extends AbstractType return null; } - return json_encode($object); + return json_encode($object, JSON_THROW_ON_ERROR); } public function transformObject($object = null) diff --git a/src/Bundle/ChillMainBundle/Controller/ExportController.php b/src/Bundle/ChillMainBundle/Controller/ExportController.php index 686b4cbce..6c4ea0269 100644 --- a/src/Bundle/ChillMainBundle/Controller/ExportController.php +++ b/src/Bundle/ChillMainBundle/Controller/ExportController.php @@ -665,7 +665,7 @@ class ExportController extends AbstractController $this->logger->notice('[export] choices for an export unserialized', [ 'key' => $key, - 'rawData' => json_encode($rawData), + 'rawData' => json_encode($rawData, JSON_THROW_ON_ERROR), ]); return $rawData; diff --git a/src/Bundle/ChillMainBundle/Controller/SearchController.php b/src/Bundle/ChillMainBundle/Controller/SearchController.php index 8592dd2c3..7eec60324 100644 --- a/src/Bundle/ChillMainBundle/Controller/SearchController.php +++ b/src/Bundle/ChillMainBundle/Controller/SearchController.php @@ -109,10 +109,8 @@ class SearchController extends AbstractController ->getHasAdvancedFormSearchServices(); if (count($advancedSearchProviders) === 1) { - reset($advancedSearchProviders); - return $this->redirectToRoute('chill_main_advanced_search', [ - 'name' => key($advancedSearchProviders), + 'name' => array_key_first($advancedSearchProviders), ]); } diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php index c4c18d179..684030ee3 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/Point.php @@ -41,7 +41,7 @@ class Point implements JsonSerializable public static function fromGeoJson(string $geojson): self { - $a = json_decode($geojson); + $a = json_decode($geojson, null, 512, JSON_THROW_ON_ERROR); if (null === $a) { throw PointException::badJsonString($geojson); @@ -96,7 +96,7 @@ class Point implements JsonSerializable { $array = $this->toArrayGeoJson(); - return json_encode($array); + return json_encode($array, JSON_THROW_ON_ERROR); } public function toWKT(): string diff --git a/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php index 6266ce86f..3ee5f20d8 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/AggregateStringHelper.php @@ -29,7 +29,7 @@ class AggregateStringHelper return implode( '|', - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ); }; } diff --git a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php index 9077b501a..c9882f557 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/ExportAddressHelper.php @@ -310,7 +310,7 @@ class ExportAddressHelper return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'isNoAddress': @@ -369,7 +369,7 @@ class ExportAddressHelper return ''; } - $decodedValues = json_decode($value, true); + $decodedValues = json_decode($value, true, 512, JSON_THROW_ON_ERROR); switch (count($decodedValues)) { case 0: diff --git a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php index 44ce2b194..9b49d476b 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/TranslatableStringExportLabelHelper.php @@ -39,7 +39,7 @@ class TranslatableStringExportLabelHelper return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; } @@ -54,7 +54,7 @@ class TranslatableStringExportLabelHelper return ''; } - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); return implode( '|', diff --git a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php index 0e770786d..2821bf1a6 100644 --- a/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php +++ b/src/Bundle/ChillMainBundle/Export/Helper/UserHelper.php @@ -54,7 +54,7 @@ class UserHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return ''; diff --git a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php index 46fa8799f..d4759a794 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php +++ b/src/Bundle/ChillMainBundle/Form/Type/DataTransformer/EntityToJsonTransformer.php @@ -43,7 +43,7 @@ class EntityToJsonTransformer implements DataTransformerInterface public function reverseTransform($value) { - $denormalized = json_decode($value, true); + $denormalized = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ($this->multiple) { if (null === $denormalized) { diff --git a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php index 9ee013b1a..a92db39ce 100644 --- a/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php +++ b/src/Bundle/ChillMainBundle/Phonenumber/PhonenumberHelper.php @@ -224,7 +224,7 @@ final class PhonenumberHelper implements PhoneNumberHelperInterface return null; } - $validation = json_decode($response->getBody()->getContents())->carrier->type; + $validation = json_decode($response->getBody()->getContents(), null, 512, JSON_THROW_ON_ERROR)->carrier->type; $item ->set($validation) diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php index 59adb374a..2b89ec3db 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/PermissionApiControllerTest.php @@ -44,7 +44,7 @@ final class PermissionApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertFalse($data['roles']['FOO_ROLE']); } @@ -67,7 +67,7 @@ final class PermissionApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue($data['roles']['ROLE_USER']); $this->assertFalse($data['roles']['ROLE_ADMIN']); } diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php index 31bfab285..a777be44c 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/PostalCodeApiControllerTest.php @@ -35,7 +35,7 @@ final class PostalCodeApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertEquals('Fontenay Le Comte', $data['results'][0]['name']); diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php index 57800c6cb..ef421020e 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserApiControllerTest.php @@ -47,7 +47,7 @@ final class UserApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(array_key_exists('count', $data)); $this->assertGreaterThan(0, $data['count']); $this->assertTrue(array_key_exists('results', $data)); diff --git a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php index 33198c500..b3bd856ff 100644 --- a/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Services/Import/GeographicalUnitBaseImporterTest.php @@ -64,7 +64,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitname'], 'Layer one'); - $this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer']); + $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((30 20,45 40,10 40,30 20)),((15 5,40 10,10 20,5 10,15 5)))'); @@ -93,7 +93,7 @@ final class GeographicalUnitBaseImporterTest extends KernelTestCase $this->assertEquals($results['unitrefid'], 'layer_one'); $this->assertEquals($results['unitname'], 'Layer one fixed'); - $this->assertEquals(json_decode($results['layername'], true), ['fr' => 'Test Layer fixed']); + $this->assertEquals(json_decode($results['layername'], true, 512, JSON_THROW_ON_ERROR), ['fr' => 'Test Layer fixed']); $this->assertEquals($results['layerrefid'], 'test'); $this->assertEquals($results['geom'], 'MULTIPOLYGON(((130 120,45 40,10 40,130 120)),((0 0,15 5,40 10,10 20,0 0)))'); } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php b/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php index 5da4509bf..1c410970b 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20180709181423.php @@ -49,18 +49,18 @@ final class Version20180709181423 extends AbstractMigration $this->addSql('CREATE UNIQUE INDEX UNIQ_1483A5E9885281E ON users (emailCanonical)'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN - UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; - END IF; + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_user_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.username <> OLD.username OR NEW.email <> OLD.email OR OLD.emailcanonical IS NULL OR OLD.usernamecanonical IS NULL THEN + UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; + END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL - SQL + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL +SQL_WRAP ); $this->addSql( @@ -74,16 +74,16 @@ final class Version20180709181423 extends AbstractMigration ); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS - $BODY$ - BEGIN - UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_user_on_insert() RETURNS TRIGGER AS + $BODY$ + BEGIN + UPDATE users SET usernamecanonical=LOWER(UNACCENT(NEW.username)), emailcanonical=LOWER(UNACCENT(NEW.email)) WHERE id=NEW.id; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( diff --git a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php index 5b2de9f65..bafc4b1cb 100644 --- a/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php +++ b/src/Bundle/ChillPersonBundle/Controller/ReassignAccompanyingPeriodController.php @@ -120,7 +120,7 @@ class ReassignAccompanyingPeriodController extends AbstractController $assignForm->handleRequest($request); if ($assignForm->isSubmitted() && $assignForm->isValid()) { - $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true); + $assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true, 512, JSON_THROW_ON_ERROR); $userTo = $assignForm->get('userTo')->getData(); $userFrom = $assignForm->get('userFrom')->getData(); @@ -179,7 +179,7 @@ class ReassignAccompanyingPeriodController extends AbstractController { $defaultData = [ 'userFrom' => $userFrom, - 'periods' => json_encode($periodIds), + 'periods' => json_encode($periodIds, JSON_THROW_ON_ERROR), ]; $builder = $this->formFactory->createNamedBuilder('reassign', FormType::class, $defaultData); diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php index 8c96906fc..cacdf2ee1 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListAccompanyingPeriod.php @@ -182,7 +182,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; case 'locationPersonName': @@ -226,7 +226,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface '|', array_map( fn ($s) => $this->translatableStringHelper->localize($s), - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ) ); }; @@ -245,7 +245,7 @@ class ListAccompanyingPeriod implements ListInterface, GroupedExportInterface '|', array_map( fn ($s) => $this->socialIssueRender->renderString($this->socialIssueRepository->find($s), []), - json_decode($value, true) + json_decode($value, true, 512, JSON_THROW_ON_ERROR) ) ); }; diff --git a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php index acaeb498c..21675a86a 100644 --- a/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php +++ b/src/Bundle/ChillPersonBundle/Export/Export/ListPerson.php @@ -334,7 +334,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou return $this->customFieldProvider ->getCustomFieldByType($cf->getType()) - ->render(json_decode($value, true), $cf, 'csv'); + ->render(json_decode($value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv'); }; if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) { @@ -344,7 +344,7 @@ class ListPerson implements ExportElementValidatedInterface, ListInterface, Grou if (null === $value) { return ''; } - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ('_header' === $value) { $label = $cfType->getChoices($cf)[$slugChoice]; diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php index 2cfc8d3cf..fc196dd50 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/LabelPersonHelper.php @@ -39,7 +39,7 @@ class LabelPersonHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return ''; diff --git a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php index de8870674..77a1d9c86 100644 --- a/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php +++ b/src/Bundle/ChillPersonBundle/Export/Helper/ListPersonHelper.php @@ -361,7 +361,7 @@ class ListPersonHelper return ''; } - $ids = json_decode($value); + $ids = json_decode($value, null, 512, JSON_THROW_ON_ERROR); return implode( diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php index 1d1711ce4..dc5c5c2ce 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php @@ -110,7 +110,7 @@ final class AccompanyingPeriodConfidentialTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period', 'user' => $user]) + json_encode(['type' => 'accompanying_period', 'user' => $user], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php index 154dbd884..596e0a870 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/AccompanyingCourseApiControllerTest.php @@ -313,10 +313,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -338,7 +338,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase } $response = $this->client->getResponse(); - $data = json_decode($response->getContent()); + $data = json_decode($response->getContent(), null, 512, JSON_THROW_ON_ERROR); // check that the person id is contained $participationsPersonsIds = array_map( @@ -357,10 +357,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -387,7 +387,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], - json_encode(['type' => 'social_issue', 'id' => $si->getId()]) + json_encode(['type' => 'social_issue', 'id' => $si->getId()], JSON_THROW_ON_ERROR) ); $this->assertTrue(in_array($this->client->getResponse()->getStatusCode(), [200, 422], true)); @@ -396,7 +396,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase $this->markTestSkipped('the next tests should appears only on valid accompanying period'); } - $data = json_decode($this->client->getResponse()->getContent(), true); + $data = json_decode($this->client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('id', $data); $this->assertArrayHasKey('type', $data); $this->assertEquals('social_issue', $data['type']); @@ -407,7 +407,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], - json_encode(['type' => 'social_issue', 'id' => $si->getId()]) + json_encode(['type' => 'social_issue', 'id' => $si->getId()], JSON_THROW_ON_ERROR) ); $this->assertTrue(in_array($this->client->getResponse()->getStatusCode(), [200, 422], true)); @@ -427,7 +427,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase $this->markTestSkipped('the next tests should appears only on valid accompanying period'); } - $data = json_decode($response->getContent()); + $data = json_decode($response->getContent(), null, 512, JSON_THROW_ON_ERROR); $this->assertEquals( $data->id, $periodId, @@ -453,7 +453,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period', 'emergency' => !$initialValueEmergency]) + json_encode(['type' => 'accompanying_period', 'emergency' => !$initialValueEmergency], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); @@ -492,7 +492,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_comment', 'content' => 'this is a text']) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -508,10 +508,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'accompanying_period_comment', 'id' => $data['id']]) + json_encode(['type' => 'accompanying_period_comment', 'id' => $data['id']], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); } @@ -568,10 +568,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'person', 'id' => $personId]) + json_encode(['type' => 'person', 'id' => $personId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -595,10 +595,10 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], // parameters [], // files [], // server parameters - json_encode(['type' => 'thirdparty', 'id' => $thirdPartyId]) + json_encode(['type' => 'thirdparty', 'id' => $thirdPartyId], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -655,7 +655,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_resource', 'resource' => ['type' => 'person', 'id' => $personId]]) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -680,7 +680,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], //server - json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()]) + json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -699,7 +699,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase json_encode(['type' => 'accompanying_period_resource', 'resource' => ['type' => 'thirdparty', 'id' => $thirdPartyId]]) ); $response = $this->client->getResponse(); - $data = json_decode($response->getContent(), true); + $data = json_decode($response->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); @@ -724,7 +724,7 @@ final class AccompanyingCourseApiControllerTest extends WebTestCase [], [], [], //server - json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()]) + json_encode(['type' => 'accompanying_period_resource', 'id' => $resource->getId()], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); $this->assertTrue(in_array($response->getStatusCode(), [200, 422], true)); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php index 8686172ee..710c5fc6b 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdApiControllerTest.php @@ -157,7 +157,7 @@ final class HouseholdApiControllerTest extends WebTestCase ); $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('count', $data); $this->assertArrayHasKey('results', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php index 34c7e3113..56000c3e0 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/HouseholdMemberControllerTest.php @@ -179,7 +179,7 @@ final class HouseholdMemberControllerTest extends WebTestCase $client->getResponse()->getStatusCode() ); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertEquals(null, $data); } @@ -284,7 +284,7 @@ final class HouseholdMemberControllerTest extends WebTestCase $client->getResponse()->getStatusCode() ); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertIsArray($data); $this->assertArrayHasKey('members', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php index f5a886fa6..0de312d84 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonApiControllerTest.php @@ -112,7 +112,7 @@ final class PersonApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('type', $data); $this->assertArrayHasKey('id', $data); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php index 67b45acd5..d6fb7a8da 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/RelationshipApiControllerTest.php @@ -136,7 +136,7 @@ final class RelationshipApiControllerTest extends WebTestCase 'toPerson' => ['id' => $toPersonId, 'type' => 'person'], 'relation' => ['id' => $relationId, 'type' => 'relation'], 'reverse' => $isReverse, - ]) + ], JSON_THROW_ON_ERROR) ); $response = $this->client->getResponse(); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php index a0dcae59a..ba19fc56e 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialIssueApiControllerTest.php @@ -47,7 +47,7 @@ final class SocialIssueApiControllerTest extends WebTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertArrayHasKey('id', $data); $this->assertArrayHasKey('type', $data); @@ -60,7 +60,7 @@ final class SocialIssueApiControllerTest extends WebTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $data = json_decode($client->getResponse()->getContent(), true); + $data = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $this->assertGreaterThan(0, $data['count']); $this->assertGreaterThan(0, count($data['results'])); diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php index aa98fdcd3..9ed62e4b3 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/SocialWorkEvaluationApiControllerTest.php @@ -77,7 +77,7 @@ final class SocialWorkEvaluationApiControllerTest extends WebTestCase $this->assertResponseIsSuccessful(); - $content = json_decode($client->getResponse()->getContent(), true); + $content = json_decode($client->getResponse()->getContent(), true, 512, JSON_THROW_ON_ERROR); $ids = array_map(static fn (array $item) => $item['id'], $content['results']); diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php b/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php index 0e06fccab..6b11a1d63 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20160818113633.php @@ -45,7 +45,7 @@ class Version20160818113633 extends AbstractMigration foreach ($personIdAndCFData as $person) { $personId = $person['id']; $cFDataArray = unserialize($person['cfdata']); - $cFDataJson = json_encode($cFDataArray); + $cFDataJson = json_encode($cFDataArray, JSON_THROW_ON_ERROR); $this->addSql( 'UPDATE person set cfdata = :cfdatajson WHERE id = :id', ['cfdatajson' => $cFDataJson, 'id' => $personId] diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php b/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php index 4f7765000..d3adb3401 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20181023101621.php @@ -40,20 +40,20 @@ final class Version20181023101621 extends AbstractMigration $this->addSql('CREATE INDEX fullnameCanonical_trgm_idx ON chill_person_person USING GIN (fullnameCanonical gin_trgm_ops)'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname - THEN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname + THEN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + END IF; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( <<<'SQL' @@ -67,17 +67,17 @@ final class Version20181023101621 extends AbstractMigration ); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS - $BODY$ - BEGIN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_insert() RETURNS TRIGGER AS + $BODY$ + BEGIN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); $this->addSql( <<<'SQL' diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php b/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php index 947d26357..7d48b5f53 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20200130213446.php @@ -130,20 +130,20 @@ final class Version20200130213446 extends AbstractMigration $this->addSql('DROP TRIGGER canonicalize_fullname_on_alt_name_delete ON chill_person_alt_name;'); $this->addSql('DROP FUNCTION canonicalize_fullname_on_alt_name_alter();'); $this->addSql( - <<<'SQL' - CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS - $BODY$ - BEGIN - IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname - THEN - UPDATE chill_person_person - SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) - WHERE id=NEW.id; - END IF; - RETURN NEW; - END; - $BODY$ LANGUAGE PLPGSQL; - SQL + <<<'SQL_WRAP' + CREATE OR REPLACE FUNCTION canonicalize_fullname_on_update() RETURNS TRIGGER AS + $BODY$ + BEGIN + IF NEW.firstname <> OLD.firstname OR NEW.lastname <> OLD.lastname + THEN + UPDATE chill_person_person + SET fullnameCanonical=LOWER(UNACCENT(CONCAT(NEW.firstname, ' ', NEW.lastname))) + WHERE id=NEW.id; + END IF; + RETURN NEW; + END; + $BODY$ LANGUAGE PLPGSQL; +SQL_WRAP ); } diff --git a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php index 21606d807..16ae19daa 100644 --- a/src/Bundle/ChillReportBundle/Export/Export/ReportList.php +++ b/src/Bundle/ChillReportBundle/Export/Export/ReportList.php @@ -276,7 +276,7 @@ class ReportList implements ExportElementValidatedInterface, ListInterface return ''; } - return $this->translatableStringHelper->localize(json_decode($value, true)); + return $this->translatableStringHelper->localize(json_decode($value, true, 512, JSON_THROW_ON_ERROR)); }; default: @@ -526,13 +526,13 @@ class ReportList implements ExportElementValidatedInterface, ListInterface return $this->customFieldProvider ->getCustomFieldByType($cf->getType()) - ->render(json_decode($value, true), $cf, 'csv'); + ->render(json_decode($value, true, 512, JSON_THROW_ON_ERROR), $cf, 'csv'); }; if ($cfType instanceof CustomFieldChoice && $cfType->isMultiple($cf)) { return function ($value) use ($cf, $cfType, $key) { $slugChoice = $this->extractInfosFromSlug($key)['additionnalInfos']['choiceSlug']; - $decoded = json_decode($value, true); + $decoded = json_decode($value, true, 512, JSON_THROW_ON_ERROR); if ('_header' === $value) { $label = $cfType->getChoices($cf)[$slugChoice]; diff --git a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php index f87fe41b4..2e7a20840 100644 --- a/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php +++ b/src/Bundle/ChillThirdPartyBundle/Export/Helper/LabelThirdPartyHelper.php @@ -54,7 +54,7 @@ class LabelThirdPartyHelper return ''; } - $decoded = json_decode($value); + $decoded = json_decode($value, null, 512, JSON_THROW_ON_ERROR); if (0 === count($decoded)) { return '';