Skip to content

Conversation

@korenevskiy
Copy link

@korenevskiy korenevskiy commented Mar 22, 2022

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.

<input name="user[name][1]" ......... >
<input name="user[name][2]" ......... >
$arrFilter = ['user'=> ['name'=> [ 0 => 'STRING', 1 => 'STRING', 2 => 'STRING' ] ] ];
$input = new Joomla\Input\Input();
$data = $input->getArray($arrFilter);

The $data variable 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 value NULL. Thanks to this, we can later check for the presence of a value with an index of 0.
All simple methods always return NULL by default. Methods such as getInt(), getString(), getCmd(), getHtml() and others return NULL. But the getArray() 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.

@nibra
Copy link
Contributor

nibra commented Mar 22, 2022

Good catch! Please leave the original testcase alone and create a new test (based on your example above) instead.

@korenevskiy
Copy link
Author

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?

@nibra
Copy link
Contributor

nibra commented Mar 23, 2022

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).

@korenevskiy
Copy link
Author

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?

@Llewellynvdm
Copy link

@nibra why did you not already merge this into 2-dev branch?

@nibra
Copy link
Contributor

nibra commented Feb 28, 2023

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.

@korenevskiy
Copy link
Author

@HLeithner Is it possible to transfer this PR to Joomla 5 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants