? Success

User tests: Successful: Unsuccessful:

avatar zjw
zjw
9 Jun 2014

This pull request is based on comments made in an earlier request (#3739) which will now be closed.

Joomla Code Tracker: http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=33829&start=0

How to test:

Install Joomla 3.3.0 with some sample data on an apache server.

In the Site Settings, enable:
1. Search Engine Friendly URLs
2. Use URL rewriting
3. Adds Suffix to URL

Rename htaccess.txt to .htaccess to enable URL rewriting on the server.

Enter a URL for a non-existent file (assume the Joomla installation is at http://example.com):
http://examle.com/images/missing-file.pdf

The expected response is a "404" (not found) error.

The actual response is a "500" (internal server error) response. This response is misleading. There has been no "server error" -- it's simply a case of the client requesting a file that was not found on the server.

The issue is further exacerbated with the recent merging of pull request #488, because now any missing file with any file extension will be redirected to Joomla. If the file ends with anything other than ".html", the response will likely be 500 rather than 404.

This problem also affects the Redirect component. Although redirects can be created for missing files, the redirects will not be honored. An example redirect:

http://examle.com/images/missing-file.pdf -> http://example.com/index.php

Such a redirect will fail because it would only be honored when a 404 error condition is encountered.

This issue is probably the same as issue #30344, but that was closed due to inactivity.

avatar zjw zjw - open - 9 Jun 2014
avatar roland-d
roland-d - comment - 15 Jun 2014

Hello @zjw ,

Looking at the source code of the legacy.php file I wonder if your change should also be applied to line 608, this throws the same error as on line 861 that you modified.

avatar zjw
zjw - comment - 16 Jun 2014

@roland-d:

In looking at line 608, I think the 500 response at that point is appropriate in all cases.

In the example case of http://example.com/images/missing-file.pdf, JControllerLegacy::createView() is called from getView() (line 855) with arguments:

 $name = 'category'
 $prefix = 'contentView'
 $type = 'pdf'

createView() then tests whether the file components/com_content/views/category/view.pdf.php exists. Since the file does not exist, the method returns null. This null response is then processed by my changes in getView(), triggering a 404 response instead of a 500 response.

Using a different example of http://example.com/images/missing-file.html, JControllerLegacy::createView() is invoked with arguments:

 $name = 'category'
 $prefix = 'contentView'
 $type = 'html'

createView() then tests whether the file components/com_content/views/category/view.html.php exists. Since that file does exist, it is loaded and a case-insensitive test is performed to confirm that the class contentViewcategory was loaded from the file. If the class could not be found, then a 500 error would be appropriately thrown on line 608. But since the class does exist, processing continues, and an attempt is made to find a category named 'missing-file'. When that category is not found, a 404 response is ultimately generated somewhere else.

avatar roland-d
roland-d - comment - 17 Jun 2014

@zjw Ok, sounds good. I had reached the same conclusion but wanted to double check.
Moved the JC tracker to RTC.

avatar phproberto phproberto - reference | e8f12f2 - 23 Jun 14
avatar phproberto phproberto - reference | 99c81b3 - 23 Jun 14
avatar phproberto phproberto - change - 23 Jun 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-06-23 20:02:11
avatar phproberto phproberto - close - 23 Jun 2014
avatar phproberto phproberto - close - 23 Jun 2014
avatar zjw zjw - head_ref_deleted - 27 Jun 2014

Add a Comment

Login with GitHub to post a comment