-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Labels
BugThis is a bug (something does not work as expected)This is a bug (something does not work as expected)
Description
Bug
jsonOrUnserialize() in core/lib/functions.lib.php line 15710 calls json_decode($stringtodecode) without the second parameter, which returns a stdClass object instead of an associative array. This causes a fatal error when the result is later used as an array in extrafields.class.php.
Actual behavior
PHP Fatal error: Uncaught Error: Cannot use object of type stdClass as array
in /var/www/html/core/class/extrafields.class.php on line 1345
Stack trace:
#0 /var/www/html/core/tpl/extrafields_list_search_input.tpl.php(84): ExtraFields->showInputField()
#1 /var/www/html/fourn/facture/list.php(1331): include('...')
Root cause
core/lib/functions.lib.php line 15710:
$result = json_decode($stringtodecode); // Returns stdClassSuggested fix
$result = json_decode($stringtodecode, true); // Returns associative arrayDolibarr Version
22.0.4
Environment PHP
8.2
Environment Database
MariaDB 11.4
Steps to reproduce the behavior and expected behavior
Steps to reproduce
- Create a custom module that registers extrafields of type
selectorsellistonfacture_fourn(supplier invoices) - The extrafield options are stored as JSON in
llx_extrafields.param - Navigate to Billing → Supplier Invoices → List or Create
Expected behavior
The supplier invoice list and create form should render normally.
Attached files
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugThis is a bug (something does not work as expected)This is a bug (something does not work as expected)