? Pending

User tests: Successful: Unsuccessful:

avatar alexandreelise
alexandreelise
19 Aug 2021

ACTUAL: when trying to call getAllPropertiesToRender() public method or the getAllRelationsToRender() public method on the OnGetApiFields Event in a custom system plugin in Joomla! 4. If the fields argument is null or the relations argument is null it throws a TypeError because the returning value of both of theses methods should be array.

SUGGESTION: A quick fix to that is to add a null coalescing operator with an empty array as a fallback like so ?? [] just after getting the argument

EXPECTED: Using an empty array as fallback rather than null because otherwise it throws an TypeError

avatar alexandreelise alexandreelise - open - 19 Aug 2021
avatar alexandreelise alexandreelise - change - 19 Aug 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Aug 2021
Category Libraries
avatar alexandreelise
alexandreelise - comment - 19 Aug 2021

Hi @alikon can you please review this one when you have some time. Take care. I am trying to get involved in core code. Tasting the delicious codebase of Joomla! 4.

avatar wilsonge
wilsonge - comment - 20 Aug 2021

Why is your function for these returning null in the plugin? I think that's the problem.

avatar alexandreelise
alexandreelise - comment - 20 Aug 2021

@wilsonge Even without considering my plugin. When debugging the code with XDebug 3 I might have spotted a fishy behaviour leading to a TypeError. Because if we look at the code closely the fields argument and the relations arguments when not set are requiring to be arrays. Hence the TypeError when they are not defined because the default is null when calling getArgument('myarg') without specifiying anything. Just look in the base class you will see it.

avatar chmst chmst - change - 31 Jan 2022
Labels Added: ?
avatar chmst chmst - change - 31 Jan 2022
Labels Added: ?
avatar alexandreelise alexandreelise - change - 31 Jan 2022
Labels Removed: ?
avatar alexandreelise
alexandreelise - comment - 31 Jan 2022

Thanks @chmst for taking your time to have a look at this pull request. Take care and have a great day Super Joomler.

Add a Comment

Login with GitHub to post a comment