Problem/Motivation
The following code reads settings from where it should be but then saves to somewhere else in NegotiationSessionForm.php:
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('language.negotiation');
$form['language_negotiation_session_param'] = array(
'#title' => $this->t('Request/session parameter'),
'#type' => 'textfield',
'#default_value' => $config->get('session.parameter'),
'#description' => $this->t('Name of the request/session parameter used to determine the desired language.'),
);
$form_state->setRedirect('language.negotiation');
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('language.settings')
->set('session.parameter', $form_state->getValue('language_negotiation_session_param'))
->save();
parent::submitForm($form, $form_state);
}
Proposed resolution
Save to the right place.
Add tests.
Remaining tasks
Add tests.
User interface changes
None.
API changes
None.
Comment | File | Size | Author |
---|---|---|---|
#9 | 2359879-session-settings-9.patch | 3.86 KB | penyaskito |
#9 | 2359879-session-settings-9.only-test.patch | 3.2 KB | penyaskito |
#4 | 2359879-session-settings-4.patch | 3.86 KB | penyaskito |
#4 | 2359879-session-settings-4.test-only.patch | 3.2 KB | penyaskito |
#1 | 2359879-session-settings.patch | 682 bytes | Gábor Hojtsy |
Comments
Comment #1
Gábor HojtsyFix is easy. Needs tests.
Comment #2
Wim LeersHah!
Comment #3
penyaskitoAdded tests for session negotiation. Tests this issue as a side effect.
Comment #4
penyaskitoForgot to add ::runTest() to the patch.
Comment #8
Gábor HojtsyYay, amazing. Thanks for these tests.
The assert messages are backwards? Need to be flipped.
Comment #9
penyaskitoOops, sorry.
(╯°□°)╯︵ ┻━┻
Fixed.
Comment #10
Gábor HojtsyLooks great, thanks a lot!
Comment #12
alexpottCommitted 455a6a6 and pushed to 8.0.x. Thanks!
Comment #14
Gábor HojtsyYay, thanks all!