Language Change bug PR-4.3-dev Pending

User tests: Successful: Unsuccessful:

avatar particthistle
particthistle
2 Jan 2023

Summary of Changes

PHP error was encountered when test instructions below are met:

json_decode(): Passing null to parameter #1 ($json) of type string is deprecated

If $value is null at line 86 in plugins/fields/media/media.php, then the deprecated error occurs.

Added if statement to checkValue function to check $value is set before trying to decode the string.

Testing Instructions

  • Create a custom field for articles that is a Media type, that's also set to optional (ie Required = No)
  • Create an article, leaving the optional custom fields blank.
  • View the article in the front end.
  • Turn on Error Reporting for the site to Development so you can see the messages on screen.

(ShackOpenGraph also installs Social Images fields that are Media type and trigger the error)

Actual result BEFORE applying this Pull Request

If there's no image in the custom field, then the code in the plugin does a check on the $value provided to the checkValue function. As there's no value, json_decode triggers
json_decode(): Passing null to parameter #1 ($json) of type string is deprecated

Expected result AFTER applying this Pull Request

The checkValue function will now firstly check whether $value is null, and then only proceed with the rest of the function when $value has a value provided to it.

This in turn stops the deprecated message being generated.

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed
  • No documentation changes for manual.joomla.org needed
avatar joomla-cms-bot joomla-cms-bot - change - 2 Jan 2023
Category Front End Plugins
avatar particthistle particthistle - open - 2 Jan 2023
avatar particthistle particthistle - change - 2 Jan 2023
Status New Pending
avatar particthistle particthistle - change - 2 Jan 2023
Title
Update media.php
Update plugins/fields/media/media.php to prevent deprecated message caused if $value empty.
avatar particthistle particthistle - edited - 2 Jan 2023
avatar particthistle particthistle - change - 25 Jan 2023
Labels Added: ?
avatar particthistle particthistle - change - 30 Jan 2023
Labels Added: ?
avatar Quy Quy - test_item - 31 Jan 2023 - Tested successfully
avatar Quy
Quy - comment - 31 Jan 2023

I have tested this item successfully on 9e169df


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39542.

avatar particthistle particthistle - change - 24 Feb 2023
Labels Removed: ?
avatar particthistle
particthistle - comment - 24 Feb 2023

With 4.2-dev locked for 4.3 release, rebased this PR to 4.3-dev.

avatar joomdonation
joomdonation - comment - 24 Feb 2023

@particthistle Actually, 4.2-dev still accepts bugs fix. So you should not have to rebase to 4.3-dev.

avatar joomla-cms-bot joomla-cms-bot - change - 15 Mar 2023
Category Front End Plugins Administration com_admin SQL Postgresql com_config com_fields com_finder com_installer com_modules com_templates com_users Language & Strings
avatar obuisard
obuisard - comment - 15 Jul 2023

It looks like something went wrong with the files associated with the PR. Can you fix it on your end Patrick @particthistle? Thanks, I appreciate it.

avatar particthistle
particthistle - comment - 29 Aug 2023

Was nudged on this during PBF. Aside from botching the rebasing of the PR, and being away 3 months due to finding a new house and moving, the problem preventing the code being merged is more due to the entire Custom Fields code being refactored for Joomla 4.3 from what I have worked out. Had it been actioned back in February it would not have had an issue.

https://github.com/joomla/joomla-cms/blob/4.4-dev/plugins/fields/media/src/Extension/Media.php shows where the code has moved to.

In trying to replicate the problem with 4.3.3 and 4.3.4.rc1 it appears to have been resolved in the refactoring process.

If it does turn out that it needs to be fixed (scenario may be where data has been imported from J3 to J4, and the initial values for the data is NULL instead of a correct default blank value) then the code to add into a new PR before Line 89 is:

        if (!$value)
        {
            return;
        }

However as I can't replicate the problem with the above testing instructions, I'm closing this PR at the moment.

If anyone wants to walk me through the issue, or help with creating some "Github PR for Joomlers" content, reach out on Mattermost.

avatar particthistle particthistle - close - 29 Aug 2023
avatar particthistle particthistle - change - 29 Aug 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-08-29 23:55:37
Closed_By particthistle
Labels Added: Language Change bug PR-4.3-dev
Removed: ?

Add a Comment

Login with GitHub to post a comment