Skip to content

Commit

Permalink
ISSUE-1468: Fixed wrong request filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
BeMySlaveDarlin committed Mar 21, 2021
1 parent 921da17 commit 8d0a956
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Fixed model findFirst return type error [#1478](https://github.com/phalcon/phalcon-devtools/issues/1478)
- Added trailing semicolon to scaffolding crud views getters [#1477](https://github.com/phalcon/phalcon-devtools/issues/1477)
- Fixed optional options (namespace, abstract) checks on model create [#1491](https://github.com/phalcon/phalcon-devtools/issues/1491)
- Fixed wrong request filtering [#1468](https://github.com/phalcon/phalcon-devtools/issues/1468)

# [4.0.5](https://github.com/phalcon/cphalcon/releases/tag/v4.0.5) (2021-03-14)
## Fixed
Expand Down
18 changes: 8 additions & 10 deletions src/Builder/Component/Scaffold.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function build(): bool
$attributes = $metaData->getAttributes($entity);
$dataTypes = $metaData->getDataTypes($entity);
$identityField = $metaData->getIdentityField($entity);
$identityField = $identityField ? $identityField : null;
$identityField = $identityField ?: null;
$primaryKeys = $metaData->getPrimaryKeyAttributes($entity);

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

if ($this->options->get('templateEngine') == 'volt') {
if ($this->options->get('templateEngine') === 'volt') {
$this->makeLayoutsVolt();
$this->makeViewVolt('index');
$this->makeViewSearchVolt();
Expand All @@ -233,26 +233,24 @@ public function build(): bool
* @param string $var
* @param mixed $fields
* @param bool $useGetSetters
* @param string $identityField
* @param null|string $identityField
*
* @return string
*/
private function captureFilterInput(string $var, $fields, bool $useGetSetters, string $identityField = null): string
{
$code = '';
foreach ($fields as $field => $dataType) {
if ($identityField !== null && $field == $identityField) {
if ($identityField !== null && $field === $identityField) {
continue;
}

if (is_int($dataType) !== false) {
if (\in_array($dataType, [Column::TYPE_DECIMAL, Column::TYPE_INTEGER])){
$fieldCode = '$this->request->getPost("'.$field.'", "int")';
} elseif ($field === 'email') {
$fieldCode = '$this->request->getPost("'.$field.'", "email")';
} else {
if ($field == 'email') {
$fieldCode = '$this->request->getPost("'.$field.'", "email")';
} else {
$fieldCode = '$this->request->getPost("'.$field.'")';
}
$fieldCode = '$this->request->getPost("'.$field.'")';
}

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

0 comments on commit 8d0a956

Please sign in to comment.