? Success

User tests: Successful: Unsuccessful:

avatar nikosdion
nikosdion
20 Apr 2016

Pull Request for Issue # .

Summary of Changes

Testing Instructions

How to reproduce

Publish the Redirect plugin. Access a front-end component page which throws an exception.

Expected result: Joomla!'s error page with error details and error message.

Actual result (BUG!): PHP throws a Fatal Error such as this: Catchable fatal error: Argument 1 passed to PlgSystemRedirect::handleError() must be an instance of JException, instance of FOF30\Factory\Exception\ControllerNotFound given in /XXXXXXXXXXX/plugins/system/redirect/redirect.php on line 55

Explanation (for developers)

JError is the default exception error handler. As a result JError calls PlgSystemRedirect::handleError as a callback error handler before PHP SPL has the chance to call PlgSystemRedirect::handleException

This doesn't even require testing. It's a very simple, obvious bug. /cc @wilsonge @mbabker

avatar nikosdion nikosdion - open - 20 Apr 2016
avatar nikosdion nikosdion - change - 20 Apr 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 20 Apr 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 20 Apr 2016
Category Plugins
avatar wilsonge
wilsonge - comment - 20 Apr 2016

Can I see a stack trace of how you ended up here please? As far as I understand the default exception handler should be JErrorPage https://github.com/joomla/joomla-cms/blob/staging/libraries/cms.php#L49 which should be totally unrelated to the legacy JError class. So I'm clearly missing how you are managing to trigger this exception into the redirect plugin

I also threw a standard RuntimeException in com_contents single article view.html.php in the display method and got a standard error page. I'm not denying that there's no bug - I'm just saying it's not obvious to me

avatar mbabker
mbabker - comment - 20 Apr 2016

@wilsonge when the redirect plugin's enabled PlgSystemRedirect::handleException() becomes the exception handler, but that's still outside the scope of any of the JError handlers.

avatar wilsonge
wilsonge - comment - 20 Apr 2016

Yah my bad. But as you say you're still running through handleException not handleError.... and I still can't replicate this issue nic reports

avatar weeblr
weeblr - comment - 20 Apr 2016

Hi

This situation happens when a front-end element just throw an Exception. For instance, insert
throw new Exception('Testing');
somewhere in /components/com_content/content.php

When the redirect plugin is enabled, as Michael pointed out, PlgSystemRedirect::handleException() is now the exception handler.

  • Before 3.5, throwing such an exception (which is the recommended way to handle errors I believe) would trigger a nice error page (with a 200 HTTP status, but that's another discussion, default should probably 500).

  • Post 3.5, you now get the "Catchable fatal error" due to the change in PlgSystemRedirect::handleException() signature.

If one uses JError::throwError(), indeed the error is different and is not caught either:

Fatal error: Call to undefined method Exception::get() in ...\src\main\libraries\legacy\error\error.php on line 209

avatar mbabker
mbabker - comment - 20 Apr 2016

handleException() is new as of 3.5. handleError() did have a signature change, yes. But handleError() is also no longer registered as an exception handler, it is only a JError callback handler for when JError::raiseError() is called or you call JError::throwError() with a JException object set to the E_ERROR level.

mbabker@3f05ba3 "fixes" this in another way (with full deprecation notices too because handleError needs to go away with JError), but to be frank I don't want to see this PR or my suggestion merged without knowing how on earth people are actually hitting this error because with the core bootstrap processes there is no way to hit this.

avatar Bakual
Bakual - comment - 20 Apr 2016

This situation happens when a front-end element just throw an Exception. For instance, insert
throw new Exception('Testing');
somewhere in /components/com_content/content.php

Can't reproduce this with current staging. I put throw new Exception('test'); into /components/com_content/content.php just after the User was fetched and get the regular error page. With the redirect plugin enabled. Maybe I'm missing something?

avatar smz
smz - comment - 20 Apr 2016

Performed same test as @Bakual and I can't reproduce either.
Current staging (HEAD at #9c5ab09), Multilingual, redirect enabled.

avatar weeblr
weeblr - comment - 20 Apr 2016

Hi

Folks, can't reproduce either now on a stock joomla! maybe I had an old version of sh404SEF on that site. Let's hear more from Nicholas then.

avatar brianteeman brianteeman - change - 20 Apr 2016
Status Pending Information Required
avatar brianteeman
brianteeman - comment - 20 Apr 2016

Setting to information required


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

avatar mbabker
mbabker - comment - 20 Apr 2016

I get HOW this error can be thrown, I just don't get WHAT is causing it. To me it seems like someone is directly calling the plugin's method OR someone is overloading the global exception handler. That's why I'm asking this not to be merged right away. Functionally, there's no difference with this PR applied, but it's better to know what we're patching here than to just blindly do it.

avatar mbabker
mbabker - comment - 24 Apr 2016

I give up. Nic shared with me some debugging info and nowhere in there indicates anything that should be causing handleError to be used as an Exception handler yet it's still being used. @rdeutz merge this.

avatar rdeutz
rdeutz - comment - 25 Apr 2016

Will try to reproduce this issue, not going to merge something I don't understand

avatar wilsonge
wilsonge - comment - 25 Apr 2016

Closing. Me and Michael have figured out the issue here and have messaged the author of the responsible extension

avatar wilsonge wilsonge - change - 25 Apr 2016
Status Information Required Closed
Closed_Date 0000-00-00 00:00:00 2016-04-25 17:01:47
Closed_By wilsonge
avatar wilsonge wilsonge - close - 25 Apr 2016
avatar wilsonge wilsonge - close - 25 Apr 2016
avatar xristoph
xristoph - comment - 15 Jul 2016

Not trying to duplicate posts @brianteeman, just wanting to ensure all involved with deBugging related code are aware

The error came from new user registration approval link within the admin email, when site admin clicks to approve the site displays blank white page, or with error reporting enabled, get the below error message.

Catchable fatal error: Argument 1 passed to PlgSystemRedirect::handleError() must be an instance of JException, instance of phpmailerException given in /path2site/mydomain.com/plugins/system/redirect/redirect.php on line 55

Joomla 3.5.1
JomSocial 4.2.1
sh404SEF 4.7.3.3292
PHP 5.4.16

Hoping this helps isolate the cause and related solution. Thank you in advance


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

avatar lyquix-owner
lyquix-owner - comment - 25 Jul 2016

We are seeing the same error in Joomla 3.6.0.

In our case the error was caused while we were upgrading an old custom module to use the database methods (e.g. $query -> select, $query -> where), and we were passing "AND" as part of a where statement.

For example, the following line produced the error:
$query->where("AND sky = 'blue'");

The error disappeared when we fixed the line to:
$query->where("sky = 'blue'");

I hope this is helpful


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

Add a Comment

Login with GitHub to post a comment