Skip to content
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

[5.3] Author Filter Now Supports Deleted Users #45186

Open
wants to merge 8 commits into
base: 5.3-dev
Choose a base branch
from

Conversation

AdarshSantoria
Copy link

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

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).

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

@fgsw
Copy link

fgsw commented Mar 22, 2025

@AdarshSantoria Please delete "Fix #45181 - " from the title.

The title say [5.3], but the label is PR-5.2-dev.

@AdarshSantoria AdarshSantoria changed the title [5.3] Fix #45181 - Author Filter Now Supports Deleted Users [5.3] Author Filter Now Supports Deleted Users Mar 22, 2025
@brianteeman
Copy link
Contributor

please rebase this to 5.3 dev https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/changing-the-base-branch-of-a-pull-request

@AdarshSantoria AdarshSantoria changed the base branch from 5.2-dev to 5.3-dev March 22, 2025 09:14
@brianteeman
Copy link
Contributor

I have tested this item ✅ successfully on 66cd254


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

@AdarshSantoria
Copy link
Author

Thank you for your feedbacks, @fgsw @brianteeman.

@brianteeman
Copy link
Contributor

great work!!

@fgsw
Copy link

fgsw commented Mar 22, 2025

I have tested this item ✅ successfully on 66cd254

Before PR

No deleted user

without1

One deleted user

without2

After PR

One deleted user

with1

Three deleted user

with2


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

@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Mar 22, 2025

if (\in_array(0, $authorId)) {
// Remove 0 from array and handle deleted users with OR condition
$authorId = array_filter($authorId, fn ($id) => $id !== 0);
Copy link
Contributor

@bembelimen bembelimen Mar 25, 2025

Choose a reason for hiding this comment

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

No extra function needed, array_filter removes "empty" values

Copy link
Author

Choose a reason for hiding this comment

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

Fixed, thanks!

@bembelimen
Copy link
Contributor

Good work with this PR, really like it, just found a minor thing you probably could fix.

@bembelimen bembelimen added this to the Joomla! 5.3.0 milestone Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-5.3-dev RTC This Pull Request is Ready To Commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants