Skip to content

Commit 7db9c84

Browse files
committed
Bug-fix.
Changelog excerpt: - Decimals in the names, choice keys, and labels keys of configuration directives were being coerced by PHP to underscores; Fixed.
1 parent 8b417e1 commit 7db9c84

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
125125
[2022.12.10; Bug-fix; Maikuolan]: The reset button at the front-end configuration page wasn't resetting the hidden "other" field; Fixed.
126126

127127
[2023.01.06; Maikuolan]: Added L10N for Hebrew.
128+
129+
[2023.01.12; Bug-fix; Maikuolan]: Decimals in the names, choice keys, and labels keys of configuration directives were being coerced by PHP to underscores; Fixed.

src/FrontEnd.php

+25-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Front-end handler (last modified: 2022.12.10).
11+
* This file: Front-end handler (last modified: 2023.01.12).
1212
*/
1313

1414
namespace phpMussel\FrontEnd;
@@ -1092,6 +1092,16 @@ public function view(string $Page = ''): void
10921092
' autocomplete="%s"',
10931093
$DirValue['autocomplete']
10941094
);
1095+
1096+
/** Fix for PHP automatically changing certain kinds of $_POST keys. */
1097+
if (!isset($_POST[$ThisDir['DirLangKey']])) {
1098+
$Try = str_replace('.', '_', $ThisDir['DirLangKey']);
1099+
if (isset($_POST[$Try])) {
1100+
$_POST[$ThisDir['DirLangKey']] = $_POST[$Try];
1101+
unset($_POST[$Try]);
1102+
}
1103+
}
1104+
10951105
if (isset($_POST[$ThisDir['DirLangKey']])) {
10961106
if (in_array($DirValue['type'], ['bool', 'float', 'int', 'kb', 'string', 'timezone', 'email', 'url'], true)) {
10971107
$this->Loader->autoType($_POST[$ThisDir['DirLangKey']], $DirValue['type']);
@@ -1119,10 +1129,24 @@ public function view(string $Page = ''): void
11191129
foreach ($DirValue['labels'] as $DirValue['ThisLabelKey'] => $DirValue['ThisLabel']) {
11201130
if (!empty($_POST[$ThisDir['DirLangKey'] . '_' . $DirValue['ThisChoiceKey'] . '_' . $DirValue['ThisLabelKey']])) {
11211131
$DirValue['Posts'][] = $DirValue['ThisChoiceKey'] . ':' . $DirValue['ThisLabelKey'];
1132+
} else {
1133+
$Try = str_replace('.', '_', $ThisDir['DirLangKey'] . '_' . $DirValue['ThisChoiceKey'] . '_' . $DirValue['ThisLabelKey']);
1134+
if (!empty($_POST[$Try])) {
1135+
$_POST[$ThisDir['DirLangKey'] . '_' . $DirValue['ThisChoiceKey'] . '_' . $DirValue['ThisLabelKey']] = $_POST[$Try];
1136+
unset($_POST[$Try]);
1137+
$DirValue['Posts'][] = $DirValue['ThisChoiceKey'] . ':' . $DirValue['ThisLabelKey'];
1138+
}
11221139
}
11231140
}
11241141
} elseif (!empty($_POST[$ThisDir['DirLangKey'] . '_' . $DirValue['ThisChoiceKey']])) {
11251142
$DirValue['Posts'][] = $DirValue['ThisChoiceKey'];
1143+
} else {
1144+
$Try = str_replace('.', '_', $ThisDir['DirLangKey'] . '_' . $DirValue['ThisChoiceKey']);
1145+
if (!empty($_POST[$Try])) {
1146+
$_POST[$ThisDir['DirLangKey'] . '_' . $DirValue['ThisChoiceKey']] = $_POST[$Try];
1147+
unset($_POST[$Try]);
1148+
$DirValue['Posts'][] = $DirValue['ThisChoiceKey'];
1149+
}
11261150
}
11271151
}
11281152
$DirValue['Posts'] = implode(',', $DirValue['Posts']) ?: '';

0 commit comments

Comments
 (0)