bug PR-4.4-dev PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar artur-stepien
artur-stepien
8 Oct 2024

There was a bug in state filtering of CategoryModel that lead to administrators seeing trashed items in the front-end.

Summary of Changes

Changed the state filter to filter the contact items.

Testing Instructions

  • Create 2 contacts: contact A and contact B to Uncategorized
  • Move contact B to Trash
  • Create a front-end menu item of type List Contacts in a Category and select Uncategorized
  • Visit front-end logged in as a Super Administrator and click the menu item created in previous step

Actual result BEFORE applying this Pull Request

Both contacts visible

Expected result AFTER applying this Pull Request

Only contact A should be visible

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 artur-stepien artur-stepien - open - 8 Oct 2024
avatar artur-stepien artur-stepien - change - 8 Oct 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Oct 2024
Category Front End com_contact
avatar artur-stepien
artur-stepien - comment - 8 Oct 2024

There has to be another PR for category state filtering but the problem is 4.4 does not have subcategories filtering. Should I create a separate PR adding category state filtering for 4.4 and 5.1?

avatar brianteeman
brianteeman - comment - 8 Oct 2024

It is not a bug it is the intended behaviour

image

avatar artur-stepien
artur-stepien - comment - 8 Oct 2024

How on earth showing trashed items only in the Contact component front-end is an intended behaviour?

avatar brianteeman
brianteeman - comment - 8 Oct 2024

How on earth showing trashed items only in the Contact component front-end is an intended behaviour?

The same with articles. Otherwise the admin is not able to untrash/publish etc a contact when managing in the front end. That is why the state of the contact is displayed. (Perhaps you have a template which is overriding this view and not displaying the status

avatar artur-stepien
artur-stepien - comment - 8 Oct 2024

How on earth showing trashed items only in the Contact component front-end is an intended behaviour?

The same with articles. Otherwise the admin is not able to untrash/publish etc a contact when managing in the front end. That is why the state of the contact is displayed. (Perhaps you have a template which is overriding this view and not displaying the status

It doesn't work like this in the Content component. And I just checked that to be sure for both blog and default layouts. Contact is the only place where I found such behaviour.

avatar brianteeman
brianteeman - comment - 8 Oct 2024

Even if the intended behaviour is not to display these contacts the PR is obvioulsy not complete as you would surely need to update this as well.

<?php if ($item->published == 0) : ?>
<div>
<span class="list-published badge bg-warning text-light">
<?php echo Text::_('JUNPUBLISHED'); ?>
</span>
</div>
<?php endif; ?>
<?php if ($item->publish_up && strtotime($item->publish_up) > strtotime(Factory::getDate())) : ?>
<div>
<span class="list-published badge bg-warning text-light">
<?php echo Text::_('JNOTPUBLISHEDYET'); ?>
</span>
</div>
<?php endif; ?>
<?php if (!is_null($item->publish_down) && strtotime($item->publish_down) < strtotime(Factory::getDate())) : ?>
<div>
<span class="list-published badge bg-warning text-light">
<?php echo Text::_('JEXPIRED'); ?>
</span>
</div>
<?php endif; ?>
<?php if ($item->published == -2) : ?>
<div>
<span class="badge bg-warning text-light">
<?php echo Text::_('JTRASHED'); ?>
</span>
</div>
<?php endif; ?>

avatar HLeithner
HLeithner - comment - 15 Nov 2024

I think there are some bits missing, for example if the category is unpublished it shouldn't be shown.
Maybe check how it's done in com_content and replicate this to com_contact?

avatar HLeithner
HLeithner - comment - 15 Nov 2024

This pull request has been automatically rebased to 5.2-dev.

avatar HLeithner HLeithner - change - 15 Nov 2024
Title
Fix contact state filter for administrator
[5.2] Fix contact state filter for administrator
avatar HLeithner HLeithner - edited - 15 Nov 2024
avatar artur-stepien
artur-stepien - comment - 15 Nov 2024

I think there are some bits missing, for example if the category is unpublished it shouldn't be shown. Maybe check how it's done in com_content and replicate this to com_contact?

Unpublished items for administrators are shown in most of the core components. But only Contact had Trashed items visible too. The behaviour is copied from com_content in this PR. Only missing bit are changes in the view layout to not check for trashed state but I have no time this week for this.

avatar joomdonation
joomdonation - comment - 18 Jan 2025

I think there are some bits missing, for example if the category is unpublished it shouldn't be shown. Maybe check how it's done in com_content and replicate this to com_contact?

I looked at how it is handled in com_content and indeed, something is missing here:

@artur-stepien Could you please look at the feedback above to see if it is valid, and for valid items, update your PR with necessary change ?

avatar artur-stepien
artur-stepien - comment - 18 Jan 2025

I think there are some bits missing, for example if the category is unpublished it shouldn't be shown. Maybe check how it's done in com_content and replicate this to com_contact?

I looked at how it is handled in com_content and indeed, something is missing here:

* Only items from published categories should be shown https://github.com/joomla/joomla-cms/blob/5.2-dev/components/com_content/src/Model/ArticlesModel.php#L336

* The `filter.published` model state for administrator should be set inside populateState method like this https://github.com/joomla/joomla-cms/blob/5.2-dev/components/com_content/src/Model/CategoryModel.php#L158, not hardcode to [0,1,2] in the `getListQuery` method right now. Further more, we only show Pending and Published articles for administrator, guess it should be the same for contacts.

* The layout should be updated as Brian pointed out.

@artur-stepien Could you please look at the feedback above to see if it is valid, and for valid items, update your PR with necessary change ?

If you want to create a PR feel free. I will not waste more time on another Joomla PR ignored for months.

avatar artur-stepien artur-stepien - change - 18 Jan 2025
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2025-01-18 10:53:48
Closed_By artur-stepien
Labels Added: bug PR-4.4-dev PR-5.2-dev
avatar artur-stepien artur-stepien - close - 18 Jan 2025

Add a Comment

Login with GitHub to post a comment