? ? Pending

User tests: Successful: Unsuccessful:

avatar GaryA
GaryA
8 Feb 2023

Pull Request for Issue #39820 .

Summary of Changes

Line 85 of components\com_contact\tmpl\category\default_items.php
Remove test for item is owned by current user when generating table headings, since there is no current item at this point

Testing Instructions

Create some contacts and enable users to edit their own contact details in the front end.
Enable PHP warnings.
Go to the contacts list view

Actual result BEFORE applying this Pull Request

Everything works but 2 PHP warnings are generated about an undefined variable

Expected result AFTER applying this Pull Request

Everything works exactly the same but there are no warnings

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

avatar joomla-cms-bot joomla-cms-bot - change - 8 Feb 2023
Category Front End com_contact
avatar GaryA GaryA - open - 8 Feb 2023
avatar GaryA GaryA - change - 8 Feb 2023
Status New Pending
avatar GaryA GaryA - change - 8 Feb 2023
Labels Added: ?
avatar joomdonation
joomdonation - comment - 9 Feb 2023

While this PR addresses the warning issue, it will hide the potential logical error. Think about the following case :

  • User has core.edit.own permission but does not have core.edit permission.
  • The current list of contacts does not have any contact belongs to him

With the proposed code, the Edit column will still being displayed but there is no contact items in the table editable, and it is not right. We could use the code like below handle it:

$showEditColumn = false;

if ($canEdit) {
    $showEditColumn = true;
} elseif ($canDo->get('core.edit.own') && !empty($this->items)) {
    foreach ($this->items as $item) {
        if ($item->created_by == $userId) {
            $showEditColumn = true;
            break;
        }
    }
}

After that blog of code, $showEditColumn will determine if we should show edit column. I would even go further by adding $showEditColumn as a property of view class and move that logical calculation to the view to avoid too much logic handle inside the layout.

avatar GaryA
GaryA - comment - 10 Feb 2023

Tried to add $showEditColumn to the view class but couldn't get it to work (not very familiar with Joomla code)
It doesn't really save much since the layout has to calculate for each row anyway, using the same logic.

avatar chmst chmst - test_item - 12 Feb 2023 - Tested successfully
avatar chmst
chmst - comment - 12 Feb 2023

I have tested this item successfully on 2da47f2


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

avatar viocassel viocassel - test_item - 13 Feb 2023 - Tested successfully
avatar viocassel
viocassel - comment - 13 Feb 2023

I have tested this item successfully on 2da47f2


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

avatar joomdonation joomdonation - change - 13 Feb 2023
Status Pending Ready to Commit
avatar joomdonation
joomdonation - comment - 13 Feb 2023

RTC. The current change is fine as it is. Further improvement if required could be done in separate PR.


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

avatar roland-d roland-d - change - 22 Feb 2023
Labels Added: ?
avatar roland-d roland-d - change - 22 Feb 2023
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-02-22 19:01:49
Closed_By roland-d
avatar roland-d roland-d - close - 22 Feb 2023
avatar roland-d roland-d - merge - 22 Feb 2023
avatar roland-d
roland-d - comment - 22 Feb 2023

Thank you

Add a Comment

Login with GitHub to post a comment