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

Infinite loop in Container::getValue() #277

Closed
milo opened this issue Sep 1, 2021 · 1 comment
Closed

Infinite loop in Container::getValue() #277

milo opened this issue Sep 1, 2021 · 1 comment

Comments

@milo
Copy link
Member

milo commented Sep 1, 2021

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.

@dg dg closed this as completed in 9b2e45f Sep 1, 2021
@milo
Copy link
Member Author

milo commented Sep 1, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant