No Code Attached Yet
avatar vicn1222
vicn1222
11 Oct 2022

When installing Joomla 3 in php 8 environment, Joomla crashes. I have found the bugs are in two files:

includes/framework.php
administrator/includes/framework.php

Where $config->error_reporting = "None", the switch below goes to default case

switch ($config->error_reporting)
{
        ......

	default:
		error_reporting($config->error_reporting);
		ini_set('display_errors', 1);

		break;

}

Where error_reporting( "None" ) throw exception as below

PHP Fatal error:  Uncaught TypeError: error_reporting(): Argument #1 ($error_level) must be of type ?int, string given in ....

In php 7, it does not throw exception and program moves on...
avatar vicn1222 vicn1222 - open - 11 Oct 2022
avatar vicn1222 vicn1222 - change - 11 Oct 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 11 Oct 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 11 Oct 2022
avatar richard67
richard67 - comment - 11 Oct 2022

The problem is that it is not case-insensitive, so it should not be "None" but "none": https://github.com/joomla/joomla-cms/blob/4.2-dev/administrator/includes/framework.php#L49

Update: For Joomla 3 it's the same: https://github.com/joomla/joomla-cms/blob/3.10-dev/administrator/includes/framework.php#L63

avatar richard67
richard67 - comment - 11 Oct 2022

@vicn1222 Have you manually edited your configuration.php or used a custom setup, so that the value is "None" instead of "none"? Or was that a clean installation with an official installation package? With "none" it ends at the right place in the switch and not in the default case. Of course the code in the default case should be corrected somehow, too, but that's another thing. The values have to be all lowercase to end in the right case of the switch.

avatar vicn1222
vicn1222 - comment - 11 Oct 2022

No, I don't even know what is that value in configuration.php. I have never changed that value manually in configuration.php.

I look at the Server Settings in the Global Reporting, the "Error Settings" is "System Default". I then look at the file /etc/php.ini, it is
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

avatar vicn1222
vicn1222 - comment - 11 Oct 2022

Interestingly, I re-save the configure.php using the admin control panel, it becomes "none". I don't know why that happened.

But still, it probably is better to use strtolower if lower case is expected. Especially the default case should be explicitly casted to int, knowing in php 8, exception will be thrown if the $config->error_reporting is a string

switch ( strtolower( $config->error_reporting ) ) {
...

    default:
        error_reporting( (int)$config->error_reporting );
        ini_set('display_errors', 1);

        break;

}

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38933.
avatar chmst
chmst - comment - 11 Oct 2022

. I don't know why that happened.

This can only happen when someone edits the configuration.php.

avatar richard67
richard67 - comment - 12 Oct 2022

Interestingly, I re-save the configure.php using the admin control panel, it becomes "none". I don't know why that happened.

It happens because saving configuration with the admin control panel saves them with lowercase as it should be.

But still, it probably is better to use strtolower if lower case is expected.

That would only be necessary if in past in old versions of Joomla the values would have been written in uppercase or mixed case and wever having changed configuration still have such values. I don't know if that is the case or if it always was lowercase throughout all history.

It could be useful though in case of manual edits of the configuration.php file.

But it would not solve the wrong default case.

Especially the default case should be explicitly casted to int, knowing in php 8, exception will be thrown if the $config->error_reporting is a string

Yes, but casting it to an integer will not be right. That default case as it is now simply doesn't make any sense, except if in very old times we saved that value as an integer string, e.g. '0' or '1' and so on, instead of values like "default" or "none" or "maximum". @wilsonge Do you remember if we had something like that in past?

avatar Fedik
Fedik - comment - 12 Oct 2022

I think, we can leave it as it is.
When there a wrong value then it should crash and burn, so owner will know he/she (or 3rd extension) doing something wrong with configuration.

avatar HLeithner HLeithner - close - 13 Oct 2022
avatar HLeithner
HLeithner - comment - 13 Oct 2022

So not a core problem and we can close this issue. Thanks for the report.

avatar HLeithner HLeithner - change - 13 Oct 2022
Status New Closed
Closed_Date 0000-00-00 00:00:00 2022-10-13 07:39:51
Closed_By HLeithner

Add a Comment

Login with GitHub to post a comment