Infinite loop in Container::getValue()
milo opened this issue · comments
Version: 3.1.4
Bug Description
After upgrade an older application, application falls into infinite loop (and max execution time exeed error) when submitting a form with own rule which call getValues()
.
Steps To Reproduce
<?php
require __DIR__ . '/vendor/autoload.php';
$form = new Nette\Forms\Form;
$form
->addText('a')
->setRequired()
->addRule(function () use ($form) {
$values = $form->getValues(); # <-- recursion in validation loop
return true;
}, 'Invalid');
$form->addSubmit('send');
echo $form;
if ($form->isSuccess()) {
echo '<xmp>' . print_r($form->getValues(), true) . '</xmp>';
}
Expected Behavior
Probably, throw an exception that cannot call getValues()
during validation process?
The getUnsafeValues()
should be used and I used it, but it took some time to discover the loop.
Thank you!