Pending

User tests: Successful: Unsuccessful:

avatar VaishnaviSidral
VaishnaviSidral
31 Jan 2026

Pull Request for Issue #46730 .

Summary of Changes

Changed the default value of Document::$_type from null to an empty string.

When an invalid or cleaned format parameter results in an empty output format, the document type remains unset (null). This causes a TypeError later when the exception handler attempts to resolve a renderer using a non-string value.

By defaulting the type to an empty string instead of null, Joomla correctly throws an InvalidArgumentException, allowing the exception handler to fall back to the HTML renderer and display the proper 404 error page instead of crashing with HTTP 500.

Testing Instructions

  1. Install Joomla 5.4.2.

  2. Open any existing article URL in the frontend.

  3. Append an invalid format parameter, for example:

    index.php?option=com_content&view=article&id=111&format=%27

  4. Reload the page.

Actual result BEFORE applying this Pull Request

Joomla returns an HTTP 500 error and displays the default error page due to a TypeError caused by Document::getType() returning null.

Expected result AFTER applying this Pull Request

Joomla returns a proper 404 error page from the active template without triggering a fatal error, and the request is handled gracefully.

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 VaishnaviSidral VaishnaviSidral - open - 31 Jan 2026
avatar VaishnaviSidral VaishnaviSidral - change - 31 Jan 2026
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 31 Jan 2026
Category Libraries
avatar ompatwa000-svg ompatwa000-svg - test_item - 31 Jan 2026 - Tested successfully
avatar ompatwa000-svg
ompatwa000-svg - comment - 31 Jan 2026

I have tested this item ✅ successfully on e355131

Test Results:
✓ Valid format (html) - Works correctly
✓ Invalid format (invalid123) - No crash, falls back to RawDocument
✓ Special characters (!@#$%) - No crash, characters sanitized
✓ Empty format - No crash, handled gracefully


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

avatar 465645 465645 - test_item - 31 Jan 2026 - Tested successfully
avatar 465645
465645 - comment - 31 Jan 2026

I have tested this item ✅ successfully on e355131

This PR fixes a fatal error ensuring that the Document Factory fails gracefully when an invalid or empty format is requested.

Changes:

  • Modified libraries/src/Document/Factory.php to check if the sanitized $type is empty.
  • Defaults to 'html' if the type is invalid/empty, preventing the instantiation of the abstract Document class.

This resolves the crash when visiting URLs with empty format parameters (e.g., ?format=).


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

avatar brianteeman
brianteeman - comment - 31 Jan 2026

@VaishnaviSidral this pull request is absolutely useless if you dont spend the 2 minutes describing what it is, what it does, and how to test it. There was a reason you were asked those questions when you created the pull request - it wasnt just for fun. Please edit the description of this pull request to preovide the missing information otherwise this will have to be closed

image
avatar VaishnaviSidral VaishnaviSidral - change - 31 Jan 2026
The description was changed
avatar VaishnaviSidral VaishnaviSidral - edited - 31 Jan 2026
avatar joomdonation
joomdonation - comment - 31 Jan 2026

This look like a workaround instead of proper fix fix. From what I see by looking at the code around, we should have a concrete document object created (Html, Raw...). So I think the fix would be adding a check here https://github.com/joomla/joomla-cms/blob/5.4-dev/libraries/src/Document/Factory.php#L40, in case $type is empty, set it to html (from everywhere, we use html as default format if it is not passed)

avatar vidya1111-gangji vidya1111-gangji - test_item - 31 Jan 2026 - Tested successfully
avatar vidya1111-gangji
vidya1111-gangji - comment - 31 Jan 2026

I have tested this item ✅ successfully on e355131

This PR correctly fixes the issue where Document::$type could remain null when an invalid format parameter is passed.

By defaulting $type to an empty string instead of null, it avoids the TypeError in the exception handler. This allows the framework to properly fall back to the HTML renderer and display the correct 404 error page instead of crashing with HTTP 500.

Tested using an invalid format parameter — behavior now matches the expected graceful error handling.

No documentation changes required.


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

Add a Comment

Login with GitHub to post a comment