Pending

User tests: Successful: Unsuccessful:

avatar itsnewtjam
itsnewtjam
25 Aug 2025

Pull Request for Issue # .

Summary of Changes

Functionality for filtering articles by workflow stage exists in the admin panel, but that filter is missing from the Content API. This adds support for the stage filter to the Content API.

Testing Instructions

Test 1: Filter for articles at a specific workflow stage
GET /api/index.php/v1/content/articles?filter[stage]=1

  • Expected: Returns only articles in the workflow stage with ID 1

Test 2: No filter parameter
GET /api/index.php/v1/content/articles

  • Expected: Returns all articles regardless of workflow stage (existing behavior preserved)

Test 3: Combined with other filters
GET /api/index.php/v1/content/articles?filter[stage]=1&filter[category]=2

  • Expected: Returns only articles in category 2 that are at workflow stage 1

Actual result BEFORE applying this Pull Request

While there was support for filtering articles by workflow stage in the admin panel, the Content API did not support this functionality.

Expected result AFTER applying this Pull Request

The Content API now supports the filter[stage] parameter to filter articles by workflow stage.

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 itsnewtjam itsnewtjam - open - 25 Aug 2025
avatar itsnewtjam itsnewtjam - change - 25 Aug 2025
Status New Pending
avatar exlemor
exlemor - comment - 25 Aug 2025

@itsnewtjam Hi James, I fear there might be some fixes that need to be made...

When testing Test 1, I seem to get what is expected,
When testing Test 2, I seem to get what is expected but
When testing Test 3, I seem to get what is expected for 'some' endpoints but not others:

https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=2
(Uncategorised - no articles) ----> no results as I would expect

https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=3
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=4
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=5
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=6
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=7
(No Article Category exists with that ID, therefore no articles) ----> no results as I would expect

https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=8
(Blog category ID:8, and articles ID 3,4,5,6,14) ----> articles listed 14,6,5,4,3 as expected

https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=9
(Help category ID: 9, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=10
(Joomla category ID: 10, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=11
(Typography category ID: 11, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=12
(Category (en-GB) category ID: 12, and no articles in stage 7) --> no results as I would expect
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=13
(Catégorie (fr-fr) category ID: 13, and no articles in stage 7) --> no results as I would expect

https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=1&filter[category]=10
(Joomla category ID: 10, and articles ID 7,8,9 in stage 1) --> articles listed 9,8, and 7 as expected

BUT why?

https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=0
https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=7&filter[category]=1
results in articles 14,6,5,4 and 3 show up in the results, even though there is no Category 1 or 0 defined in the backend?

https://www.domain.com/_j540/api/index.php/v1/content/articles?filter[stage]=1&filter[category]=1
(stage=1 - Basic Workflow, category 1 does not exist that I can find) yet the results are articles 1,2,7,8,9,10,11,12,13 ?

I may be missing something

using Postman Desktop Mac app.

avatar itsnewtjam
itsnewtjam - comment - 26 Aug 2025

@exlemor After playing around for a bit, I think I found what's happening. Good (bad?) news, this behavior exists prior to this PR.

In ArticlesModel the category filtering is done with the category's lft and rgt values, rather than explicitly comparing the ID. I think this is to include items in subcategories. When using filter[category]=1 it pulls the values from category ID 1 (the ROOT category) in the database, and all categories are included. When using filter[category]=0, the filter is not applied and is ignored.

All in all, to me this looks like it's intended behavior.

Add a Comment

Login with GitHub to post a comment