Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix normally not visible fatal error #5072

Closed
Jimmi08 opened this issue Sep 11, 2023 · 2 comments · Fixed by #5073
Closed

fix normally not visible fatal error #5072

Jimmi08 opened this issue Sep 11, 2023 · 2 comments · Fixed by #5073
Labels
type: bug A problem that should not be happening

Comments

@Jimmi08
Copy link
Contributor

Jimmi08 commented Sep 11, 2023

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.

@Jimmi08 Jimmi08 added the type: enhancement An improvement or new feature request label Sep 11, 2023
@Deltik
Copy link
Member

Deltik commented Sep 11, 2023

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 Deltik added type: bug A problem that should not be happening and removed type: enhancement An improvement or new feature request labels Sep 11, 2023
@Deltik
Copy link
Member

Deltik commented Sep 11, 2023

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.

Deltik added a commit to Deltik/e107 that referenced this issue Sep 11, 2023
The exception handler parameter has to be of type `Throwable`, but we
are remaining compatible with PHP 5.6, which didn't have `Throwable`,
so let's fix this by moving the type to the phpDoc block.

Fixes: e107inc#5072
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A problem that should not be happening
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants