Skip to content

[5.4] Author Filter Fix #45264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 13, 2025
Merged

[5.4] Author Filter Fix #45264

merged 3 commits into from
Apr 13, 2025

Conversation

AdarshSantoria
Copy link
Contributor

@AdarshSantoria AdarshSantoria commented Apr 1, 2025

Pull Request for Issue #45181

Summary of Changes

This PR fixes a bug where filtering articles by Author = None did not return articles created by deleted users. Joomla previously used created_by = 0 for the "None" filter, but in reality, deleted users leave their created_by values intact in the #__content table — they just no longer exist in the #__users table.

This fix updates the logic to:

  • Detect when the filter is set to 0 (representing "None")
  • Return articles where created_by NOT IN (SELECT id FROM #__users)
  • Support multi-select filters, e.g. author_id = [0, 42], to include both deleted users and existing ones

This PR is a continuation and enhancement of #45186, extending support to "by_me" and fixing edge cases in combined filters.


Testing Instructions

  1. Create two users in Joomla.
  2. Create articles using each user.
  3. Delete one of the users via Users > Manage.
  4. Go to Content > Articles.
  5. Apply the Author filter:
    • Select "None" → should show article by deleted user ✅
    • Select deleted user + another existing user → both articles show ✅
    • Select only existing user → shows only that user’s articles ✅

Actual result BEFORE applying this Pull Request

Screenshot (9)

  • Filtering by Author = None shows no articles.
  • Deleted users are not handled properly in the query.
  • created_by = 0 was used incorrectly.

Expected result AFTER applying this Pull Request

Screenshot (10)

  • Articles created by deleted users appear when Author = None is selected.
  • Query uses created_by NOT IN (SELECT id FROM #__users) for deleted users.
  • Filtering works as expected for mixed author selections (deleted + existing).

Screenshot (24)

  • Articles created by the current user appear when Author = Created by me is selected.
  • The 'Created by me' filter is correctly replaced with the logged-in user's ID.
  • Deleted users are no longer incorrectly included.
  • Filtering works as expected for combinations like ["by_me"].

Link to documentation

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

@AdarshSantoria AdarshSantoria changed the base branch from 5.3-dev to 5.4-dev April 1, 2025 20:17
@richard67
Copy link
Member

@AdarshSantoria Could you extend the testing instructions by a test case for the "Created by me" filter? Thanks in advance.

@AdarshSantoria
Copy link
Contributor Author

@AdarshSantoria Could you extend the testing instructions by a test case for the "Created by me" filter? Thanks in advance.

Thanks for the suggestion. I will add the "Created by me" test case to the instructions.

@AdarshSantoria
Copy link
Contributor Author

✅ Additional Test Cases for Author Filter

This extends the original test coverage for the "Created by me" filters using the following setup:

  • Owner (main/logged-in user, i.e., me)
  • Owner with Admin (another user)
  • Owner with a deleted user

1. Created by me

  • Logged in as Owner
  • Apply the Author filter:
    • Select "Created by me" → ✅ Only article with author Owner is shown.
      Screenshot (25)

2. Created by me + Admin

  • Apply the Author filter:
    • Select "Created by me" + "Admin" → ✅ Articles with authors Owner and Admin are shown.
      Screenshot (27)

3. None (Deleted User)

  • Delete the user who created the third article
  • Apply the Author filter:
    • Select "Created by me" + "None" → ✅ Article with authors Owner and [Deleted User] is shown.
      Screenshot (26)

@richard67
Copy link
Member

@brianteeman @fgsw Could you test this PR, too? Thanks in advance.

@brianteeman
Copy link
Contributor

I have tested this item ✅ successfully on c8faaf9


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

1 similar comment
@fgsw
Copy link

fgsw commented Apr 3, 2025

I have tested this item ✅ successfully on c8faaf9


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

@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Apr 3, 2025
@richard67
Copy link
Member

I have tested this item ✅ successfully on c8faaf9

Not sure if previous human tests were also made with PostgreSQL, so I've just tested that.


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

Copy link
Member

@richard67 richard67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a join and then check for null value of the joined column would be better for performance than a subquery in a where clause, but the PR works fine, so for now that's ok.

@richard67 richard67 added this to the Joomla! 5.4.0 milestone Apr 13, 2025
@richard67 richard67 merged commit 23c79b5 into joomla:5.4-dev Apr 13, 2025
3 checks passed
@richard67
Copy link
Member

Thanks all (author and testers).

@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants