User tests: Successful: Unsuccessful:
Pull Request for Issue # .
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
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
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Plugins |
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
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
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.
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?
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.
Status | Pending | ⇒ | Information Required |
Setting to information required
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.
Will try to reproduce this issue, not going to merge something I don't understand
Closing. Me and Michael have figured out the issue here and have messaged the author of the responsible extension
Status | Information Required | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-04-25 17:01:47 |
Closed_By | ⇒ | wilsonge |
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
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
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 legacyJError
class. So I'm clearly missing how you are managing to trigger this exception into the redirect pluginI 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