View Issue Details

This bug affects 1 person(s).
 6
IDProjectCategoryView StatusLast Update
19231Bug reportsOtherpublic2023-12-04 12:58
Reporterollehar Assigned Toollehar  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Summary19231: (array) json_decode($j) is not equivalent to json_decode($j, true)
Description

Lots of code seems to assume you can recursively cast an object to an array using (array) $obj, but that's not how it works.

See: https://3v4l.org/N99Ld

Question is if it can be fixed without causing any issues.

Affected places

application/helpers/export_helper.php: $attribute = (array)json_decode((string) $attribute);
application/helpers/admin/import_helper.php: $aTemplateConfiguration['theme_current']['options'] = (array)json_decode((string) $oTemplateConfigurationCurrent->attributes['options']);
application/models/TemplateConfiguration.php: ? (array)json_decode((string) $oAttributes['options'])
application/models/TemplateConfiguration.php: $oFiles = (array) json_decode((string) $this->$sField);
application/models/TemplateConfiguration.php: $aParentjFiles = (array) json_decode((string) $oTemplate->getParentConfiguration->$sField);
application/models/TemplateConfiguration.php: $aOptions = (array) json_decode($this->options);
application/models/TemplateConfiguration.php: $aFieldValue = (array) json_decode((string) $this->$sFieldName);
application/core/LS_Twig_Extension.php: return (array) json_decode((string)$json, $assoc);
application/core/LSETwigViewRenderer.php: ? (array) json_decode((string) $oTemplateConfigurationCurrent['options'])

TagsNo tags attached.
Bug heat6
Complete LimeSurvey version number (& build)master
I will donate to the project if issue is resolvedNo
Browser-
Database type & version-
Server OS (if known)-
Webserver software & version (if known)-
PHP Version-

Users monitoring this issue

There are no users monitoring this issue.

Activities

DenisChenu

DenisChenu

2023-11-10 15:43

developer   ~78392

Question : why we don't use json_decode($j, true) at start ?

If we find the reason : we can create test :)

ollehar

ollehar

2023-11-13 18:28

administrator   ~78434

Question : why we don't use json_decode($j, true) at start ?

My only guess is that the devs at the time thought it was the same thing.

Tests would be really nice, yes...

ollehar

ollehar

2023-11-28 18:23

administrator   ~78794

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=35791

LimeBot

LimeBot

2023-12-04 12:58

administrator   ~78861

Fixed in Release 6.3.8+231204

Related Changesets

LimeSurvey: master d7df1782

2023-11-28 18:33

ollehar

Committer: GitHub


Details Diff
Fixed issue 19231: (array) json_decode() is not equivalent to json_decode(, true) (#3615) Affected Issues
19231
mod - application/core/LSETwigViewRenderer.php Diff File
mod - application/helpers/admin/import_helper.php Diff File
mod - application/helpers/export_helper.php Diff File
mod - application/models/TemplateConfiguration.php Diff File

Issue History

Date Modified Username Field Change
2023-11-10 11:41 ollehar New Issue
2023-11-10 11:41 ollehar Description Updated
2023-11-10 12:22 ollehar Description Updated
2023-11-10 12:23 ollehar Description Updated
2023-11-10 14:36 ollehar Assigned To => ollehar
2023-11-10 14:36 ollehar Status new => assigned
2023-11-10 14:36 ollehar Status assigned => ready for code review
2023-11-10 15:43 DenisChenu Note Added: 78392
2023-11-10 15:43 DenisChenu Bug heat 0 => 2
2023-11-13 18:28 ollehar Note Added: 78434
2023-11-13 18:28 ollehar Bug heat 2 => 4
2023-11-28 18:23 ollehar Changeset attached => LimeSurvey master d7df1782
2023-11-28 18:23 ollehar Note Added: 78794
2023-11-28 18:23 ollehar Resolution open => fixed
2023-12-04 12:58 LimeBot Note Added: 78861
2023-12-04 12:58 LimeBot Status ready for code review => closed
2023-12-04 12:58 LimeBot Bug heat 4 => 6