Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.7.0 #16586

Merged
merged 23 commits into from
May 17, 2024
Merged

5.7.0 #16586

Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fdfc87f
Merge pull request #16564 from niden/T16532-column-corrections
niden Apr 5, 2024
9ac5dd7
enabling the mapper in the helper factory
niden Apr 29, 2024
735ce5c
updating changelog
niden Apr 29, 2024
ad6678e
Merge pull request #16574 from niden/T16571-helperfactory-mapper
niden Apr 29, 2024
7ff94ec
[#16567] - fix: changed \Phalcon\Forms\Form to set only existing prop…
noone-silent May 1, 2024
8c14b2e
[#16567] - fix: reset ini setting after test.
noone-silent May 1, 2024
e0dc3a7
Merge pull request #16575 from noone-silent/T16567-form-bind-entity-p…
niden May 1, 2024
8722b92
[#16577] - refactor: add @template for Model and add to @return in fi…
noone-silent May 2, 2024
e123c15
[#16577] - refactor: add @template for Model and add to @return in fi…
noone-silent May 3, 2024
0755759
[#16577] - refactor: add @template for Model and add to @return in fi…
noone-silent May 3, 2024
0c73a87
Merge pull request #16578 from noone-silent/T16577-enable-ide-autocom…
niden May 3, 2024
84ee128
fixing links
niden May 2, 2024
7b752ec
added tests for boolval and numbers
niden May 17, 2024
9ff268e
added conditions for numbers
niden May 17, 2024
f209030
updating changelog
niden May 17, 2024
92a111d
Merge pull request #16584 from niden/T16582-boolval-sanitize
niden May 17, 2024
e5f182f
refreshing ext
niden May 17, 2024
b4b99d6
prep for release
niden May 17, 2024
93c7690
Merge pull request #16585 from niden/5.0.x
niden May 17, 2024
4f24acc
Merge branch 'master' into 5.0.x
niden May 17, 2024
5cc8649
Bump versions of artifact actions to v4
Jeckerson May 17, 2024
989700b
Update main.yml
niden May 17, 2024
041897a
Merge pull request #16588 from phalcon/niden-patch-1
niden May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
- Changed `Phalcon\Support\HelperFactory` to use the internal mapper for better memory management [#16571](https://github.com/phalcon/cphalcon/issues/16571)

### Added

- New ini setting `phalcon.form.strict_entity_property_check` for `Phalcon\Forms\Form` to enable strict entity property checking. [#16567](https://github.com/phalcon/cphalcon/issues/16567)

### Fixed

- Fixed `Phalcon\Mvc\Cli\Router` to extend the `Phalcon\Mvc\Cli\RouterInterface` [#16551](https://github.com/phalcon/cphalcon/issues/16551)
- Fixed `Phalcon\Filter\Validation\Validator\StringLength::validate()` to correctly use the `include` parameter [#16560](https://github.com/phalcon/cphalcon/issues/16560)
- Fixed `Phalcon\Db\Column::TYPE_BINARY` and `Phalcon\Db\Column::TYPE_TINYINTEGER` to have unique values [#16532](https://github.com/phalcon/cphalcon/issues/16532)
- Fixed `Phalcon\Forms\Form` to bind only existing properties on entities, based on `phalcon.form.strict_entity_property_check` setting. [#16567](https://github.com/phalcon/cphalcon/issues/16567)

### Removed

Expand Down
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
"type": "bool",
"default": false
},
"form.strict_entity_property_check": {
"type": "bool",
"default": false
},
"orm.ast_cache": {
"type": "hash",
"default": "NULL"
Expand Down
10 changes: 9 additions & 1 deletion phalcon/Forms/Form.zep
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,15 @@ class Form extends Injectable implements Countable, Iterator, AttributesInterfac
/**
* Use the public property if it doesn't have a setter
*/
let entity->{key} = filteredValue;
if (!globals_get("form.strict_entity_property_check")) {
let entity->{key} = filteredValue;

continue;
}

if (property_exists(entity, key)) {
let entity->{key} = filteredValue;
}
}
}

Expand Down
62 changes: 62 additions & 0 deletions tests/unit/Forms/FormEntityCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,66 @@ public function isValidEntity(UnitTester $I)
$I->assertNotNull($validator->getEntity());
$I->assertSame($product->prd_name, $validator->getEntity()->prd_name);
}

/**
* Tests Phalcon\Forms\Form :: bind()
*
* @author noone-silent <lominum@protonmail.com>
* @since 2024-05-01
*/
public function bindDisabledStrictCheck(UnitTester $I): void
{
$I->wantToTest('Phalcon\Forms\Form - bind() with disabled strict property check');

$this->setNewFactoryDefault(); //create default DI

$product = new Products();

$I->assertFalse(property_exists($product, 'prd_not_exists'));

$form = new Form($product);
$form->setTagFactory($this->container->get("tag"));
$dynamic = new Text('prd_not_exists');
$form->add($dynamic);
$exists = new Text('prd_name');
$form->add($exists);
$form->bind(['prd_name' => 'Test', 'prd_not_exists' => 'TestValue'], $product);

$I->assertEquals('Test', $product->prd_name);
$I->assertEquals('TestValue', $product->prd_not_exists);
}

/**
* Tests Phalcon\Forms\Form :: bind()
*
* @author noone-silent <lominum@protonmail.com>
* @since 2024-05-01
*/
public function bindEnabledStrictCheck(UnitTester $I): void
{
$I->wantToTest('Phalcon\Forms\Form - bind() with enabled strict property check');

$this->setNewFactoryDefault(); //create default DI

$product = new Products();

$I->assertFalse(property_exists($product, 'prd_not_exists'));

// Set setting for GlobalsCest.php
ini_set('phalcon.form.strict_entity_property_check', '1');

$form = new Form($product);
$form->setTagFactory($this->container->get("tag"));
$dynamic = new Text('prd_not_exists');
$form->add($dynamic);
$exists = new Text('prd_name');
$form->add($exists);
$form->bind(['prd_name' => 'Test', 'prd_not_exists' => 'TestValue'], $product);

// Reset setting for GlobalsCest.php
ini_set('phalcon.form.strict_entity_property_check', '0');

$I->assertEquals('Test', $product->prd_name);
$I->assertFalse(property_exists($product, "prd_not_exists"));
}
}
4 changes: 4 additions & 0 deletions tests/unit/Mvc/GlobalsCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ private function getExamples(): array
'setting' => 'phalcon.db.force_casting',
'value' => '0',
],
[
'setting' => 'phalcon.form.strict_entity_property_check',
'value' => '0',
],
[
'setting' => 'phalcon.orm.cast_last_insert_id_to_int',
'value' => '0',
Expand Down
Loading