Add default value NULL for method getArray() for notexist values in Input.php#38
Conversation
|
Good catch! Please leave the original testcase alone and create a new test (based on your example above) instead. |
Please tell me. When will Joomla Framework 2 enter JoomlaCMS? |
Joomla 4 is using the Framework 2 in many places already. The move to pure framework packages is an ongoing task and should be completed with Joomla 5 (expected August 2023). |
Please tell me. When will PR JRegistry enter JoomlaCMS? |
|
@nibra why did you not already merge this into 2-dev branch? |
Because I wanted another pair of eyes having a look at this. LGTM, though. |
|
@HLeithner Is it possible to transfer this PR to Joomla 5 ? |
for a single Input value, it is possible to set a default value. But for the value in the array, there is no such possibility. And it is also a tragedy when a non-existent field in the array causes an error. Firstly, we do not have the ability to apply the default value, but in addition an error is caused.
The
$datavariable should return all the request fields after processing the STRING filter.But we see that the filter keys have other indexes in the array. Such code will cause an error.
Since there is no field with index 0 in the request.
As an alternative, we don't have the option to set default values. Therefore, the
getArray()method should return the default valueNULL. Thanks to this, we can later check for the presence of a value with an index of 0.All simple methods always return
NULLby default. Methods such asgetInt(),getString(),getCmd(),getHtml()and others returnNULL. But thegetArray()method for a nonexistent field causes an error.But:
This amendment cannot violate backward compatibility. Since the amendment corrects the error message. And I can also conclude that this method is not used by anyone. Since I didn't find any documentation on how this method works in the Joomla Doc help. Which means that developers do not use this method at all. Developers use simple methods.
getInt(),getCmd()...Otherwise, this error would have been discovered long ago.