-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
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.