Skip to content

Commit 5799835

Browse files
authored
Merge pull request #1495 from BeMySlaveDarlin/fix/issue-1468-wrong-getpost-behavior
ISSUE-1468: Fixed wrong request filtering
2 parents 02d7932 + 5a33136 commit 5799835

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- Fixed model findFirst return type error [#1478](https://github.com/phalcon/phalcon-devtools/issues/1478)
44
- Added trailing semicolon to scaffolding crud views getters [#1477](https://github.com/phalcon/phalcon-devtools/issues/1477)
55
- Fixed optional options (namespace, abstract) checks on model create [#1491](https://github.com/phalcon/phalcon-devtools/issues/1491)
6+
- Fixed wrong request filtering [#1468](https://github.com/phalcon/phalcon-devtools/issues/1468)
67

78
# [4.0.5](https://github.com/phalcon/cphalcon/releases/tag/v4.0.5) (2021-03-14)
89
## Fixed

src/Builder/Component/Scaffold.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function build(): bool
183183
$attributes = $metaData->getAttributes($entity);
184184
$dataTypes = $metaData->getDataTypes($entity);
185185
$identityField = $metaData->getIdentityField($entity);
186-
$identityField = $identityField ? $identityField : null;
186+
$identityField = $identityField ?: null;
187187
$primaryKeys = $metaData->getPrimaryKeyAttributes($entity);
188188

189189
$setParams = [];
@@ -210,7 +210,7 @@ public function build(): bool
210210
// Build Controller
211211
$this->makeController();
212212

213-
if ($this->options->get('templateEngine') == 'volt') {
213+
if ($this->options->get('templateEngine') === 'volt') {
214214
$this->makeLayoutsVolt();
215215
$this->makeViewVolt('index');
216216
$this->makeViewSearchVolt();
@@ -233,26 +233,24 @@ public function build(): bool
233233
* @param string $var
234234
* @param mixed $fields
235235
* @param bool $useGetSetters
236-
* @param string $identityField
236+
* @param null|string $identityField
237237
*
238238
* @return string
239239
*/
240240
private function captureFilterInput(string $var, $fields, bool $useGetSetters, string $identityField = null): string
241241
{
242242
$code = '';
243243
foreach ($fields as $field => $dataType) {
244-
if ($identityField !== null && $field == $identityField) {
244+
if ($identityField !== null && $field === $identityField) {
245245
continue;
246246
}
247247

248-
if (is_int($dataType) !== false) {
248+
if (\in_array($dataType, [Column::TYPE_DECIMAL, Column::TYPE_INTEGER])) {
249249
$fieldCode = '$this->request->getPost("'.$field.'", "int")';
250+
} elseif ($field === 'email') {
251+
$fieldCode = '$this->request->getPost("'.$field.'", "email")';
250252
} else {
251-
if ($field == 'email') {
252-
$fieldCode = '$this->request->getPost("'.$field.'", "email")';
253-
} else {
254-
$fieldCode = '$this->request->getPost("'.$field.'")';
255-
}
253+
$fieldCode = '$this->request->getPost("'.$field.'")';
256254
}
257255

258256
$code .= '$' . Utils::lowerCamelizeWithDelimiter($var, '-', true) . '->';

0 commit comments

Comments
 (0)