No Code Attached Yet bug
avatar GaryA
GaryA
7 Feb 2023

Steps to reproduce the issue

Set up some contacts and enable users to edit their own contact details in the frontend.
Log in to frontend and go to contacts list page.

Expected result

Contacts are displayed as a table with edit link for the contact details of the logged in user.
This does happen but there are PHP warnings displayed (if so configured)

Actual result

PHP warnings displayed:
Warning: Undefined variable $item in C:\xampp-8-0\htdocs\joomla-4\components\com_contact\tmpl\category\default_items.php on line 85
Warning: Attempt to read property "created_by" on null in C:\xampp-8-0\htdocs\joomla-4\components\com_contact\tmpl\category\default_items.php on line 85

System information (as much as possible)

Joomla version: Joomla! 4.2.7 Stable [ Uaminifu ] 31-January-2023 15:00 GMT
Web server: Apache/2.4.54 (Win64) OpenSSL/1.1.1p PHP/8.0.25
PHP version: 8.0.25
Database version: mysql 10.4.27-MariaDB

Additional comments

The problem is that when the table header is created the decision as to whether to create the edit column heading (line 85) is the same as the decision whether to show an edit link in each table row (line 186) which depend on whether the current row is the the current user's details.
The test && $item->created_by === $userId) should be removed from line 85.
Patched file attached.

default_items.php.txt

avatar GaryA GaryA - open - 7 Feb 2023
avatar GaryA GaryA - change - 7 Feb 2023
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 7 Feb 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 Feb 2023
avatar GaryA GaryA - change - 7 Feb 2023
The description was changed
avatar GaryA GaryA - edited - 7 Feb 2023
avatar GaryA GaryA - change - 7 Feb 2023
The description was changed
avatar GaryA GaryA - edited - 7 Feb 2023
avatar chmst
chmst - comment - 8 Feb 2023

Thank you! Would you like to make a PR for that, as you have already identified the error?

avatar chmst chmst - change - 8 Feb 2023
Labels Added: bug
avatar chmst chmst - labeled - 8 Feb 2023
avatar chmst chmst - change - 8 Feb 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-02-08 22:34:01
Closed_By chmst
avatar chmst chmst - close - 8 Feb 2023
avatar chmst
chmst - comment - 8 Feb 2023

Closing as we have a PR. Please test #39826

Add a Comment

Login with GitHub to post a comment