Null safety in translations

This commit is contained in:
David Bomba 2020-12-15 07:53:31 +11:00
parent fc47fb90de
commit ed20f2c4bc
3 changed files with 41 additions and 24 deletions

View File

@ -63,6 +63,14 @@ trait ClientGroupSettingsSaver
$entity_settings->{$key} = $value;
}
//this pass will handle any null values that are in the translations
foreach ($settings->translations as $key => $value) {
if (is_null($settings->translations[$key]))
$settings->translations[$key] = '';
}
$entity_settings->translations = $settings->translations;
$entity->settings = $entity_settings;
$entity->save();

View File

@ -58,6 +58,14 @@ trait CompanySettingsSaver
}
}
//this pass will handle any null values that are in the translations
foreach ($settings->translations as $key => $value) {
if (is_null($settings->translations[$key]))
$settings->translations[$key] = '';
}
$company_settings->translations = $settings->translations;
$entity->settings = $company_settings;
$entity->save();

49
composer.lock generated
View File

@ -116,16 +116,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.168.3",
"version": "3.169.0",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "49ef1f905388c8185012c9651b80941b8f2a218d"
"reference": "d15a231355e4435fc33bab83df075ec31edd0a9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/49ef1f905388c8185012c9651b80941b8f2a218d",
"reference": "49ef1f905388c8185012c9651b80941b8f2a218d",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/d15a231355e4435fc33bab83df075ec31edd0a9b",
"reference": "d15a231355e4435fc33bab83df075ec31edd0a9b",
"shasum": ""
},
"require": {
@ -200,9 +200,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.168.3"
"source": "https://github.com/aws/aws-sdk-php/tree/3.169.0"
},
"time": "2020-12-11T19:12:18+00:00"
"time": "2020-12-14T19:12:33+00:00"
},
{
"name": "brick/math",
@ -4019,16 +4019,16 @@
},
{
"name": "monolog/monolog",
"version": "2.1.1",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "f9eee5cec93dfb313a38b6b288741e84e53f02d5"
"reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/f9eee5cec93dfb313a38b6b288741e84e53f02d5",
"reference": "f9eee5cec93dfb313a38b6b288741e84e53f02d5",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/1cb1cde8e8dd0f70cc0fe51354a59acad9302084",
"reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084",
"shasum": ""
},
"require": {
@ -4041,16 +4041,17 @@
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"elasticsearch/elasticsearch": "^6.0",
"elasticsearch/elasticsearch": "^7",
"graylog2/gelf-php": "^1.4.2",
"mongodb/mongodb": "^1.8",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"php-parallel-lint/php-parallel-lint": "^1.0",
"phpspec/prophecy": "^1.6.1",
"phpstan/phpstan": "^0.12.59",
"phpunit/phpunit": "^8.5",
"predis/predis": "^1.1",
"rollbar/rollbar": "^1.3",
"ruflin/elastica": ">=0.90 <3.0",
"ruflin/elastica": ">=0.90 <7.0.1",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
@ -4070,7 +4071,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
"dev-main": "2.x-dev"
}
},
"autoload": {
@ -4086,11 +4087,11 @@
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
"homepage": "https://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"homepage": "https://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
@ -4098,7 +4099,7 @@
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/2.1.1"
"source": "https://github.com/Seldaek/monolog/tree/2.2.0"
},
"funding": [
{
@ -4110,7 +4111,7 @@
"type": "tidelift"
}
],
"time": "2020-07-23T08:41:23+00:00"
"time": "2020-12-14T13:15:25+00:00"
},
{
"name": "mtdowling/jmespath.php",
@ -11469,16 +11470,16 @@
},
{
"name": "phar-io/version",
"version": "3.0.3",
"version": "3.0.4",
"source": {
"type": "git",
"url": "https://github.com/phar-io/version.git",
"reference": "726c026815142e4f8677b7cb7f2249c9ffb7ecae"
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phar-io/version/zipball/726c026815142e4f8677b7cb7f2249c9ffb7ecae",
"reference": "726c026815142e4f8677b7cb7f2249c9ffb7ecae",
"url": "https://api.github.com/repos/phar-io/version/zipball/e4782611070e50613683d2b9a57730e9a3ba5451",
"reference": "e4782611070e50613683d2b9a57730e9a3ba5451",
"shasum": ""
},
"require": {
@ -11514,9 +11515,9 @@
"description": "Library for handling version information and constraints",
"support": {
"issues": "https://github.com/phar-io/version/issues",
"source": "https://github.com/phar-io/version/tree/3.0.3"
"source": "https://github.com/phar-io/version/tree/3.0.4"
},
"time": "2020-11-30T09:21:21+00:00"
"time": "2020-12-13T23:18:30+00:00"
},
{
"name": "php-cs-fixer/diff",