?
avatar stAn47
stAn47
1 Jun 2016

Steps to reproduce the issue

example code:

JHtml::_('list.images', 'image', ....

for a non-existent image path.

PROBLEM: instead of giving a warning or an empty reply, joomla 3.5.1 provides a non-recoverable user error 500.

Expected result

non-logged error 500 without a backtrace even when system-debug and global debug config is enabled.

possible solution:
\libraries\cms\html\list.php

inside the images function:
if (!file_exists(JPATH_SITE . '/' . $directory)) { return ''; }

Actual result

System information (as much as possible)

php5.5 + mysql 5.7 + joomla 3.5.1

Additional comments

since this is a rendering function i do not think that error 500 is an expected result. i would suggest to return either empty html, or at least provide more information about the error (log in into php error log)

avatar stAn47 stAn47 - open - 1 Jun 2016
avatar mbabker
mbabker - comment - 1 Jun 2016

DirectoryIterator::__construct() throws either a RuntimeException or UnexpectedValueException (see http://php.net/manual/en/directoryiterator.construct.php), so you can catch those in your code calling the JHtml method as a short term solution.

As for just returning an empty string, this IMO is a no-go as it silently discards the error and the CMS in general already has too many places where there is either no error handling at all or errors are caught and silently discarded.

avatar stAn47
stAn47 - comment - 1 Jun 2016

hello, yes, it's possible to fix in the 3rd party code as well with try/catch or with checking the path, but the real problem is that there is no information from joomla about what and why it actually happened

the problem here is that the function gives:

  • a non-recoverable error (error 500 / blank screen)
  • does not provide any debugging information on why and from where this had came at the screen OR at the php error log
  • it raises php's default warning behavior to a joomla user/fatal error
  • this class is mentioned in "bug fix-es" in every other php release so it's quite dangerous to use without proper checks
avatar mbabker
mbabker - comment - 1 Jun 2016

a non-recoverable error (error 500 / blank screen)

Actually no. As the method is only throwing Exceptions the error is recoverable as long as those are being caught, which at the highest level should trigger Joomla's error page (based on the PHP docs for all supported versions it will unless the constructor is throwing an undocumented error).

does not provide any debugging information on why and from where this had came at the screen OR at the php error log

As long as it's throwing Exceptions, you should get Joomla's error page, which in debug mode (as long as the template supports it, the core templates do) will give you a backtrace; otherwise the error page just spits out the Exception message. If you're getting anything else, then this error case isn't the culprit for your error condition/white screen (if it's a white screen then turn on error reporting). Also, Joomla doesn't have any place where it is instructed to write to PHP's logs so that is reliant on your PHP runtime configuration.

I'm not saying it shouldn't be patched somehow in core, but the severity of this error case isn't as fatal as it seems. The constructor from DirectoryIterator is throwing an Exception that goes uncaught up the entire trace, something that's easy to deal with.

avatar stAn47
stAn47 - comment - 1 Jun 2016

well, i was at the backend, but i did not receive the joomla's default error page - maybe a combination of other problems, but for such exceptions i haven't seen the error page in the backend for quite time now.

avatar brianteeman brianteeman - close - 3 Aug 2016
avatar brianteeman brianteeman - change - 3 Aug 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-08-03 16:16:28
Closed_By brianteeman
avatar brianteeman
brianteeman - comment - 3 Aug 2016

Closed as nothing for core to do here based on the comments above


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

Add a Comment

Login with GitHub to post a comment