Skip to content

Commit

Permalink
Don't try to json_decode() a null value (#20675)
Browse files Browse the repository at this point in the history
* Don't try to json_decode() a null value

* Add Registry package fix to make sure broken code can continue to work
  • Loading branch information
Michael Babker authored and laoneo committed Jun 6, 2018
1 parent 7e938bc commit 3ab1eb9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion administrator/components/com_fields/models/field.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function getItem($pk = null)
$result->context = JFactory::getApplication()->input->getCmd('context', $this->getState('field.context'));
}

if (property_exists($result, 'fieldparams'))
if (property_exists($result, 'fieldparams') && $result->fieldparams !== null)
{
$registry = new Registry;
$registry->loadString($result->fieldparams);
Expand Down
10 changes: 5 additions & 5 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions libraries/vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,6 @@
'Joomla\\Session\\Storage\\None' => $vendorDir . '/joomla/session/Joomla/Session/Storage/None.php',
'Joomla\\Session\\Storage\\Wincache' => $vendorDir . '/joomla/session/Joomla/Session/Storage/Wincache.php',
'Joomla\\Session\\Storage\\Xcache' => $vendorDir . '/joomla/session/Joomla/Session/Storage/Xcache.php',
'Joomla\\Session\\Tests\\Handler\\ApcuHandlerTest' => $vendorDir . '/joomla/session/tests/Handler/ApcuHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\DatabaseHandlerTest' => $vendorDir . '/joomla/session/tests/Handler/DatabaseHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\FilesystemHandlerTest' => $vendorDir . '/joomla/session/tests/Handler/FilesystemHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\MemcachedHandlerTest' => $vendorDir . '/joomla/session/tests/Handler/MemcachedHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\NativeStorageTest' => $vendorDir . '/joomla/session/tests/Storage/NativeStorageTest.php',
'Joomla\\Session\\Tests\\Handler\\RedisHandlerTest' => $vendorDir . '/joomla/session/tests/Handler/RedisHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\WincacheHandlerTest' => $vendorDir . '/joomla/session/tests/Handler/WincacheHandlerTest.php',
'Joomla\\Session\\Tests\\SessionTest' => $vendorDir . '/joomla/session/tests/SessionTest.php',
'Joomla\\String\\Inflector' => $vendorDir . '/joomla/string/src/Inflector.php',
'Joomla\\String\\Normalise' => $vendorDir . '/joomla/string/src/Normalise.php',
'Joomla\\String\\String' => $vendorDir . '/joomla/string/src/String.php',
Expand Down
8 changes: 0 additions & 8 deletions libraries/vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,6 @@ class ComposerStaticInit205c915b9c7d3e718e7c95793ee67ffe
'Joomla\\Session\\Storage\\None' => __DIR__ . '/..' . '/joomla/session/Joomla/Session/Storage/None.php',
'Joomla\\Session\\Storage\\Wincache' => __DIR__ . '/..' . '/joomla/session/Joomla/Session/Storage/Wincache.php',
'Joomla\\Session\\Storage\\Xcache' => __DIR__ . '/..' . '/joomla/session/Joomla/Session/Storage/Xcache.php',
'Joomla\\Session\\Tests\\Handler\\ApcuHandlerTest' => __DIR__ . '/..' . '/joomla/session/tests/Handler/ApcuHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\DatabaseHandlerTest' => __DIR__ . '/..' . '/joomla/session/tests/Handler/DatabaseHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\FilesystemHandlerTest' => __DIR__ . '/..' . '/joomla/session/tests/Handler/FilesystemHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\MemcachedHandlerTest' => __DIR__ . '/..' . '/joomla/session/tests/Handler/MemcachedHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\NativeStorageTest' => __DIR__ . '/..' . '/joomla/session/tests/Storage/NativeStorageTest.php',
'Joomla\\Session\\Tests\\Handler\\RedisHandlerTest' => __DIR__ . '/..' . '/joomla/session/tests/Handler/RedisHandlerTest.php',
'Joomla\\Session\\Tests\\Handler\\WincacheHandlerTest' => __DIR__ . '/..' . '/joomla/session/tests/Handler/WincacheHandlerTest.php',
'Joomla\\Session\\Tests\\SessionTest' => __DIR__ . '/..' . '/joomla/session/tests/SessionTest.php',
'Joomla\\String\\Inflector' => __DIR__ . '/..' . '/joomla/string/src/Inflector.php',
'Joomla\\String\\Normalise' => __DIR__ . '/..' . '/joomla/string/src/Normalise.php',
'Joomla\\String\\String' => __DIR__ . '/..' . '/joomla/string/src/String.php',
Expand Down
12 changes: 6 additions & 6 deletions libraries/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -604,17 +604,17 @@
},
{
"name": "joomla/registry",
"version": "1.6.1",
"version_normalized": "1.6.1.0",
"version": "1.6.2",
"version_normalized": "1.6.2.0",
"source": {
"type": "git",
"url": "https://github.com/joomla-framework/registry.git",
"reference": "9b7fe128204301bebdae9bd8f02868e8e2e36f74"
"reference": "182eed3a56b2b7e14cef11fdbc63c253ddcfd924"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/joomla-framework/registry/zipball/9b7fe128204301bebdae9bd8f02868e8e2e36f74",
"reference": "9b7fe128204301bebdae9bd8f02868e8e2e36f74",
"url": "https://api.github.com/repos/joomla-framework/registry/zipball/182eed3a56b2b7e14cef11fdbc63c253ddcfd924",
"reference": "182eed3a56b2b7e14cef11fdbc63c253ddcfd924",
"shasum": ""
},
"require": {
Expand All @@ -632,7 +632,7 @@
"suggest": {
"symfony/yaml": "Install symfony/yaml if you require YAML support."
},
"time": "2018-05-26T16:34:53+00:00",
"time": "2018-06-06T16:48:30+00:00",
"type": "joomla-package",
"extra": {
"branch-alias": {
Expand Down
6 changes: 6 additions & 0 deletions libraries/vendor/joomla/registry/src/Format/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public function stringToObject($data, array $options = array('processSections' =
{
$data = trim($data);

// Because developers are clearly not validating their data before pushing it into a Registry, we'll do it for them
if (empty($data))
{
return new \stdClass;
}

if ($data !== '' && $data[0] !== '{')
{
return AbstractRegistryFormat::getInstance('Ini')->stringToObject($data, $options);
Expand Down

0 comments on commit 3ab1eb9

Please sign in to comment.