kohana / core

Core system classes from Kohana
http://kohanaframework.org
635 stars 327 forks source link

Server Upgraded to PHP7 Error: __toString() must not throw an exception #703

Open velkymx opened 7 years ago

velkymx commented 7 years ago

ErrorException [ Fatal Error ]: Method View::__toString() must not throw an exception, caught ParseError: syntax error, unexpected 'else' (T_ELSE)

screenshot 2017-02-01 15 52 08

ghost commented 6 years ago

Any answer? I have similar problem...

Ikke commented 6 years ago

@Pantela777 Kohana is no longer maintained, so there will be no PHP7 support.

timhj commented 6 years ago

But to fix your problem if you want to update the core yourself, change the exception in the elseif to return false instead maybe.

On 16 Oct. 2017 8:43 am, "Alex Belov" notifications@github.com wrote:

Any answer? I have similar problem...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kohana/core/issues/703#issuecomment-336743788, or mute the thread https://github.com/notifications/unsubscribe-auth/ADtzk-g_wBUQP-_enAlzxfJ0vxPnhW6Kks5ssnxlgaJpZM4L0i5O .

ejg commented 6 years ago

I fixed this by changing the catch in the __toString function in system/classes/Kohana/View.php to

catch (Throwable $e)

in PHP7, fatal and recoverable errors extend a new Error class instead of of the Exception class. I found the explanation on this blog: https://www.aurigait.com/blog/fatal-error-handling-in-php-7/

-- Edited to change catch (Error $e) to catch (Throwable $e) since ErrorExcecptions were causing the toString problem with catch Error. https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/