Skip to content

Infinite loop in Container::getValue() #277

@milo

Description

@milo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions