Skip to content

[5.3] undefined array key in table\nested.php#45176

Merged
rdeutz merged 4 commits intojoomla:5.3-devfrom
brianteeman:nested
Aug 25, 2025
Merged

[5.3] undefined array key in table\nested.php#45176
rdeutz merged 4 commits intojoomla:5.3-devfrom
brianteeman:nested

Conversation

@brianteeman
Copy link
Contributor

@brianteeman brianteeman commented Mar 20, 2025

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

image

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

Signed-off-by: BrianTeeman <brian@teeman.net>
@exlemor
Copy link

exlemor commented Mar 22, 2025

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)

@brianteeman
Copy link
Contributor Author

@exlemor you probably need to ensure that php is set to log all errors and warnings
error_reporting=E_ALL

@bembelimen
Copy link
Contributor

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?

@bembelimen bembelimen added this to the Joomla! 5.3.0 milestone Mar 25, 2025
@rdeutz rdeutz modified the milestones: Joomla! 5.3.0, Joomla! 5.3.1 Mar 28, 2025
@bembelimen bembelimen removed this from the Joomla! 5.3.1 milestone May 26, 2025
@ceford
Copy link
Contributor

ceford commented May 27, 2025

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.

@ceford
Copy link
Contributor

ceford commented May 27, 2025

I have tested this item ✅ successfully on fc7b91b

My last comment was because I had not customised my php error_log location. Having done that I now see the Undefined array key message without the patch and no message with the patch.


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

@brianteeman
Copy link
Contributor Author

@bembelimen as you have validated this by code review can that count as the needed second test?

@exlemor exlemor added the PBF Pizza, Bugs and Fun label Aug 23, 2025
@rbuelund
Copy link

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.

@richard67 richard67 removed the PBF Pizza, Bugs and Fun label Aug 23, 2025
@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Aug 23, 2025
@richard67 richard67 added PBF Pizza, Bugs and Fun bug labels Aug 23, 2025
@rdeutz rdeutz added this to the Joomla! 5.3.4 milestone Aug 25, 2025
@rdeutz rdeutz enabled auto-merge (squash) August 25, 2025 10:28
@rdeutz
Copy link
Contributor

rdeutz commented Aug 25, 2025

Thanks

@rdeutz rdeutz merged commit ad14580 into joomla:5.3-dev Aug 25, 2025
39 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Aug 25, 2025
@brianteeman
Copy link
Contributor Author

thanks

@brianteeman brianteeman deleted the nested branch August 25, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug PBF Pizza, Bugs and Fun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants