e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
318 stars 212 forks source link

fix normally not visible fatal error #5072

Closed Jimmi08 closed 9 months ago

Jimmi08 commented 9 months ago

Motivation

Just to have better code

When you install e107 and there is some error, in PHP 8.2 there is message

Fatal error: Uncaught TypeError: installLog::exceptionHandler(): Argument #1 ($exception) must be of type Exception, Error given in ***\install.php on line 51

    static function exceptionHandler(Exception $exception)
    {
        $message = $exception->getMessage();
        self::add($message, "error");
    }

Actually, I am trying to find out why this happened :)

By mistake, I let one folder in the theme folder without theme.xml. Installation was trying to find theme.xml, theme.php and because it did not exist, an error was fired and with PHP 8.2 it ended with this fatal error.

Deltik commented 9 months ago

The function exceptionHandler() has the wrong parameter signature. It needs to accept a Throwable, not an Exception. See the documentation for set_exception_handler() for more information.

Deltik commented 9 months ago

Ah, but Throwable didn't exist in PHP 5.6…

An alternative could be to remove the strict type definition and replace it with a phpDoc string.