No Code Attached Yet
avatar jjnxpct
jjnxpct
18 Mar 2025

Background

I am not a developer and don’t have deep technical knowledge of Joomla’s internal workings, but I ran into an issue with configuration.php while troubleshooting a restored Joomla site.

After restoring a backup to a different domain on the same server, I noticed that configuration.php contained unexpected variables that I had never seen before. These variables were not part of a clean Joomla installation. I tried to track down where they were coming from and discovered that they appear when Joomla’s Configuration API is used to modify settings.

Problem summary

When using the Joomla Configuration API (Factory::getApplication()->getConfig()) to modify and save site settings, Joomla unexpectedly includes additional variables in configuration.php. These variables do not seem to be explicitly set but appear when Joomla writes the file.

Steps to reproduce the issue

Install a fresh Joomla 5.x instance.

Use the following code to modify a setting via the Joomla API:

use Joomla\CMS\Factory;

$config = Factory::getApplication()->getConfig();
$config->set('sitename', 'New Site Name'); // Modify a setting
$newConfig = $config->toString('PHP', ['class' => 'JConfig']);
file_put_contents(JPATH_CONFIGURATION . '/configuration.php', $newConfig);

Open configuration.php and inspect the file.

Expected result

Only intended changes should appear in configuration.php (e.g., the modified sitename).
No additional variables should be included.

Actual result

Joomla adds extra variables to configuration.php, including:

public $execution = array(...);
public $uri = array(...);
public $session = true;

These variables were not manually added but appeared after Joomla saved the configuration.

Joomla incorrectly saves request-related variables, polluting the config file.

System information (as much as possible)

Joomla 5.2.5
PHP 8.3.16

Additional comments

I think there might have been an issue about this in the past by I was not able to find it.

avatar jjnxpct jjnxpct - open - 18 Mar 2025
avatar joomla-cms-bot joomla-cms-bot - change - 18 Mar 2025
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 18 Mar 2025
avatar hiteshm0
hiteshm0 - comment - 20 Mar 2025

It looks like runtime properties are leaking into configuration.php. Is filtering out these properties before saving in configuration
file using a new function a good way to proceed ?

avatar brianteeman
brianteeman - comment - 31 Mar 2025

It looks like runtime properties are leaking into configuration.php. Is filtering out these properties before saving in configuration file using a new function a good way to proceed ?

sorry that is completely wrong.

The values being added are perfectly valid. The ones you mention are just some of the additional values being added.

It's not a problem as without those values Joomla uses default values (the same as written when you press save in global config). However I do agree that ideally all the possible settings should be entered in configuration.php during installation and it is confusing (as you discovered) when they are not. they should also be in configuration.php-dist

Add a Comment

Login with GitHub to post a comment