[5.3] undefined array key in table\nested.php#45176
Conversation
Signed-off-by: BrianTeeman <brian@teeman.net>
|
Hi @brianteeman, I have 5.3 beta 3 and I am not able to find that PHP Warning in my error_log, do I need to download/install the nightly Joomla_5.3.0-beta4-dev-Development-Full_Package.zip to be able to test this on my test hosting? (sorry for the stupid question, just want to be able to test this) |
|
@exlemor you probably need to ensure that php is set to log all errors and warnings |
|
I see (from code review) that this is a valid fix and it should be merged, but I also can't find it where you had the testing instruction pointing to. (I set a break point and during the author change, this code is never called?) Probably I missed something? |
|
Testing this is problematic for me. Without the patch applied I can change the user and see the segments returned on article save. For a real user I get the three segments expected starting with root. If I select -No User- and save I see an empty array returned and that does not seem to trigger an error. If I force $segments to be null then I get a fatal error. So I must be misunderstanding or doing something wrong. This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45176. |
|
I have tested this item ✅ successfully on fc7b91b This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45176. |
|
@bembelimen as you have validated this by code review can that count as the needed second test? |
|
I have tested this item ✅ successfully on fc7b91b This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45176. |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/45176. |
|
Thanks |
|
thanks |
Summary of Changes
The $segments array is being accessed without first checking if it contains any elements. If $segments is empty, trying to access $segments[0] will trigger the warning. You need to check if the $segments array is not empty before accessing its elements
Testing Instructions
Open an article and change the user who created it
Check php error log
and/or code review
Actual result BEFORE applying this Pull Request
PHP Warning: Undefined array key 0 in D:\repos\j51\libraries\src\Table\Nested.php on line 1320
Expected result AFTER applying this Pull Request
no entry in the error-log
Link to documentations
Please select:
Documentation link for docs.joomla.org:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed