PR-5.3-dev Pending

User tests: Successful: Unsuccessful:

avatar kartikeyg0104
kartikeyg0104
19 Sep 2025

Summary of Changes

This pull request fixes an issue in the SmartSearch indexer where removing the publish_down date from an article does not properly update the index. The previous publish_end_date value persists in the #__finder_links table, causing articles to be excluded from search results when the old date is in the past.

The fix introduces a new cleanupDate() method to handle various representations of "empty" dates (e.g., null, empty strings, MySQL zero dates like '0000-00-00 00:00:00', etc.) and ensures proper NULL handling during indexing.


Testing Instructions

  1. Before applying the fix:

    • Create an article with no publish_down date → Index is correct.
    • Add a publish_down date → Index updates with the new date.
    • Remove the publish_down date → Index still retains the old date.
  2. After applying the fix:

    • Create an article with no publish_down date → Index is correct.
    • Add a publish_down date → Index updates with the new date.
    • Remove the publish_down date → Index properly clears the publish_end_date and sets it to NULL.

Actual Result BEFORE applying this Pull Request

  • Articles with removed publish_down dates still retain the old publish_end_date in the index.
  • Articles are excluded from search results when the old date is in the past.

Expected Result AFTER applying this Pull Request

  • Articles with removed publish_down dates have their publish_end_date properly cleared in the index.
  • Articles appear in search results as expected.

Link to Documentation

  • Documentation link for docs.joomla.org: <link>

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org: <link>

  • No documentation changes for manual.joomla.org needed


Additional Notes

  • This fix is minimal and targeted, affecting only the index() method in the Indexer class.
  • The cleanupDate() method ensures robust handling of NULL-like values for date fields during indexing.
avatar kartikeyg0104 kartikeyg0104 - open - 19 Sep 2025
avatar kartikeyg0104 kartikeyg0104 - change - 19 Sep 2025
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 19 Sep 2025
Category Administration com_finder
avatar brianteeman
brianteeman - comment - 19 Sep 2025

In what scenario with current joomla can you ever have a date of 0000-00-00?

avatar kartikeyg0104
kartikeyg0104 - comment - 19 Sep 2025

Thanks for your question, While 0000-00-00 is not something you did normally see in the current Joomla system it can still show up in some rare cases like when a database field is set to a zero date or when old data is imported from another system. This fix makes sure those cases don’t cause problems in SmartSearch by handling them properly. If you feel this scenario doesn’t really need to be covered, I can simplify the logic. Let me know what you think.

avatar brianteeman
brianteeman - comment - 19 Sep 2025

I will leave it to others to decide but to me this stinks of ai generated code that doesn't understand where the code is being used. I cannot imagine any scenario where this code will ever see such a value.

avatar kartikeyg0104
kartikeyg0104 - comment - 19 Sep 2025

Okay, let me fix it from my side.

avatar kartikeyg0104
kartikeyg0104 - comment - 19 Sep 2025

Sir, the main fix is handling null and empty ('') values for publish_down, since those cause some SmartSearch issues.
I add checks for '0000-00-00 00:00:00' and '0000-00-00' as a safeguard for legacy or malformed data.

avatar Serge-45
Serge-45 - comment - 19 Sep 2025

In such a case, is there a kind of cleanup procedure to be launched during upgrade in order to fix the already indexed articles ? Or just an instruction note asking to clear the index and rebuild it ?

avatar kartikeyg0104
kartikeyg0104 - comment - 19 Sep 2025

Fix makes sure the new indexing handles publish_down dates correctly by setting publish_end_date to null but for articles it is already indexed with wrong values so there a cleanup is needed. So basically there will be two options

  1. Add note in the released docs with asking users to clear and rebuild the index after upgrading and all
  2. Make a migration script to automatically reset incorrect publish_end_date values
    If you prefer I can work on adding the automated cleanup so the fix also applies to old indexed articles.
avatar Serge-45
Serge-45 - comment - 19 Sep 2025

You should follow the usual way of doing in the Joomla's developpers community. I've no clue what are the habits.

avatar kartikeyg0104
kartikeyg0104 - comment - 19 Sep 2025

Sir, I’m new to Joomla and tried to make the cleanupDate() method handle edge cases like '0000-00-00 00:00:00' for safety. If this isn’t needed, I can simplify it to only handle null and empty strings, since those cause the issue. Please let me know the right approach so I can update the code.

avatar richard67
richard67 - comment - 19 Sep 2025

@kartikeyg0104 To me this PR looks like snake oil.

The existing code (without this ) does a type cast to integer before checking != 0 for the ternary expression. So an empty string, null, an old zero date or old zero datetime, all that will be zero when casted to integer. That should work well.

In which scenario does it not work? I would expect issues at other places when using an old zero date or zero datetime, but not here in the code changed by this PR.

If you cant provide a valid scenario where the old code has a problem, then this PR will not be accepted.

avatar kartikeyg0104
kartikeyg0104 - comment - 19 Sep 2025

Sir, the old logic (int) $date != 0 is not reliable for all date strings. For example if '2024-12-25 10:30:00' becomes 2024 when cast to int which is not correct for date checks also in some legacy or migated Joomla sites values like '0000-00-00 00:00:00' or '0000-00-00' still exist. The old logic doesn’t handle them properly, which can leave invalid publishdown dates in the index and exclude artcles from SmartSearch.
The updated cleanupDate() makes sure only valid dates are kept and everything else (null, '', '0000-00-00', '0000-00-00 00:00:00', etc.) is set to null. This ensures articles don’t get wrongly excluded and improves SmartSearch reliability even for legacy data.

avatar richard67
richard67 - comment - 19 Sep 2025

For example if '2024-12-25 10:30:00' becomes 2024 when cast to int which is not correct for date checks

@kartikeyg0104 Nonsense as the cast to int is used only in the condition of the ternary expression but not in the return value of the ternary for the case if it is true. So there is no date check logic applied on the 2024 in your example.

in some legacy or migated Joomla sites values like '0000-00-00 00:00:00' or '0000-00-00' still exist.

Also nonsense as Joomla 5 amd later require MySQL versions >= 8, where using the old zero dates or zero datetimes will result in an SQL error when trying to import such data or insert such data.

Only on MariaDB such old date or datetime values might still exist.

But any import tool which claims to be compatible with Joomla 5 or 6 has to support both, MySQL and MariaDB, and for MaSQL Joomla's version requirement makes sure that the version is >= 8.

Your long explanations still have not provided a valid practical use case, only theoretical things based on assumptions (which party are wrong).

avatar kartikeyg0104 kartikeyg0104 - change - 19 Sep 2025
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2025-09-19 18:58:22
Closed_By kartikeyg0104
Labels Added: PR-5.3-dev
avatar kartikeyg0104 kartikeyg0104 - close - 19 Sep 2025

Add a Comment

Login with GitHub to post a comment