RTC PR-4.4-dev Pending

User tests: Successful: Unsuccessful:

avatar ManuelHu
ManuelHu
22 Jan 2024

This aligns the access checks for the published state and the publish_up/down checks to both use the given filter.published.

Pull Request for Issue #42452.

Summary of Changes

The main CategoryModel model has the right access checks in

if ((!$user->authorise('core.edit.state', $asset)) && (!$user->authorise('core.edit', $asset))) {
// Limit to published for people who can't edit or edit.state.
$this->setState('filter.published', 1);
} else {
$this->setState('filter.published', [0, 1]);
}

Here, the access to the single category in question is checked the right way (i.e. by including the category id in the asset name).

But the category model does not filter the articles itself. For this, it calls into ArticlesModel:

if ($this->_articles === null && $category = $this->getCategory()) {
$model = $this->bootComponent('com_content')->getMVCFactory()
->createModel('Articles', 'Site', ['ignore_request' => true]);
$model->setState('params', Factory::getApplication()->getParams());
$model->setState('filter.category_id', $category->id);
$model->setState('filter.published', $this->getState('filter.published'));

and passes on the filter.published state.

But in ArticlesModel::getItems(), the access check is repeated with a generic asset tag (i.e. com_content w/o any category information), but only for the publish_up/down case. In the simple published case, no additional access check is performed, and just the value of filter.published is used.

// Filter by start and end dates.
if ((!$user->authorise('core.edit.state', 'com_content')) && (!$user->authorise('core.edit', 'com_content'))) {
$query->where(
[
'(' . $db->quoteName('a.publish_up') . ' IS NULL OR ' . $db->quoteName('a.publish_up') . ' <= :publishUp)',


This patch essentially aligns the access checks for the published state and the publish_up/down checks to both use the given filter.published.

Testing Instructions

  1. Create a content category
  2. create articles in it
    • at least one with published state
    • one with published state and with publish_up in the future
    • and one set to be hidden
  3. Create a user group and grant access to edit and edit-state for this category only
  4. create a category list menu item in the frontend menu
  5. log into the frontend with a user that is part of the group created in step 3

Actual result BEFORE applying this Pull Request

  • the user can only see two of the articles: the published one, and the hidden one.
  • The article with publish_up in the future is not visible

Expected result AFTER applying this Pull Request

  • the logged-in user can see all three articles
  • Note that this only changes the content of the list. The user always had the permission to view and edit the article (i.e. by "guessing" its URL), it was just not listed.

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

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar ManuelHu ManuelHu - open - 22 Jan 2024
avatar ManuelHu ManuelHu - change - 22 Jan 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 22 Jan 2024
Category Front End com_content
avatar ManuelHu ManuelHu - change - 25 Jan 2024
Labels Added: PR-4.4-dev
avatar HLeithner HLeithner - change - 24 Apr 2024
Title
Align the access checks for the unpublished articles in frontend category
[4.4] Align the access checks for the unpublished articles in frontend category
avatar HLeithner HLeithner - edited - 24 Apr 2024
avatar fgsw fgsw - test_item - 8 Aug 2024 - Tested successfully
avatar fgsw
fgsw - comment - 8 Aug 2024

I have tested this item ✅ successfully on 3ed3af0


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

avatar jivebody jivebody - test_item - 27 Aug 2024 - Tested successfully
avatar jivebody
jivebody - comment - 27 Aug 2024

I have tested this item ✅ successfully on 3ed3af0


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

avatar Quy Quy - change - 27 Aug 2024
Status Pending Ready to Commit
avatar Quy
Quy - comment - 27 Aug 2024

RTC


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

avatar Quy Quy - change - 3 Sep 2024
Labels Added: RTC
avatar laoneo laoneo - change - 12 Sep 2024
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-09-12 08:00:15
Closed_By laoneo
avatar laoneo laoneo - close - 12 Sep 2024
avatar laoneo laoneo - merge - 12 Sep 2024
avatar laoneo
laoneo - comment - 12 Sep 2024

Thanks!

Add a Comment

Login with GitHub to post a comment