Skip to content

Commit

Permalink
Fix stale session data wrongly overriding configuration file when edi…
Browse files Browse the repository at this point in the history
…ting global configuration (#20590)

* Fix stale session data wrongly overriding configuration file when editing global configuration

* Use $this variable
  • Loading branch information
ggppdk authored and Michael Babker committed Jun 12, 2018
1 parent 0a7b023 commit ae7f4ca
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public function execute()
// Validate the posted data.
$return = $model->validate($form, $data);

// Save the posted data in the session.
$this->app->setUserState('com_config.config.global.data', $data);

// Check for validation errors.
if ($return === false)
{
/*
* The validate method enqueued all messages for us, so we just need to redirect back.
*/

// Save the posted data in the session.
$this->app->setUserState('com_config.config.global.data', $data);

// Redirect back to the edit screen.
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.application', false));
}
Expand All @@ -89,23 +89,26 @@ public function execute()
$data = $return;
$return = $model->save($data);

// Save the validated data in the session.
$this->app->setUserState('com_config.config.global.data', $data);

// Check the return value.
if ($return === false)
{
/*
* The save method enqueued all messages for us, so we just need to redirect back.
*/

// Save the validated data in the session.
$this->app->setUserState('com_config.config.global.data', $data);

// Save failed, go back to the screen and display a notice.
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.application', false));
}

// Set the success message.
$this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'), 'message');

// Clear the data from the session.
$this->app->setUserState('com_config.config.global.data', null);

// Set the redirect based on the task.
switch ($this->options[3])
{
Expand Down

0 comments on commit ae7f4ca

Please sign in to comment.