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

Method isControlInvalid does not "see" through ComponentContainer #93

Merged
merged 1 commit into from Dec 21, 2011

Conversation

JanTvrdik
Copy link
Contributor

If a component is not a direct descendant (in component tree) of presenter but is a child of ComponentContainer (which is child of some presenter) then after component invalidation the presenter is not invalidated even though it should be because method isControlInvalid does not "go through" ComponentContainer (because it does not implement IRenderable).

@dg dg closed this Dec 14, 2011
@dg dg reopened this Dec 14, 2011
@dg
Copy link
Member

dg commented Dec 14, 2011

Any fix?

@JanTvrdik
Copy link
Contributor Author

This may work but I haven't tested it because I need to study for exams which I'm about to write in few hours.

public function isControlInvalid($snippet = NULL)
{
    if ($snippet === NULL) {
        if (count($this->invalidSnippets) > 0) {
            return TRUE;

        } else {
            $queue = array($this);
            do {
                foreach (array_shift($queue)->getComponents() as $component) {
                    if ($component instanceof IRenderable) {
                        if ($component->isControlInvalid()) {
                            // $this->invalidSnippets['__child'] = TRUE; // as cache
                            return TRUE;
                        }

                    } elseif ($component instanceof Nette\ComponentModel\IContainer) {
                        $queue[] = $component;                          
                    }
                }
            } while ($queue);

            return FALSE;
        }

    } else {
        return isset($this->invalidSnippets[NULL]) || isset($this->invalidSnippets[$snippet]);
    }
}

@JanTvrdik
Copy link
Contributor Author

I have found a bit of time to test the fix which was suggested above and it seems to be fine. And managed to convert this issue to pull request.

@dg
Copy link
Member

dg commented Dec 18, 2011

And what about foreach ($this->getComponents(TRUE) as $component)?

@JanTvrdik
Copy link
Contributor Author

That will iterate also over children of classes which implements IRenderable and that is not necessary.

dg added a commit that referenced this pull request Dec 21, 2011
Method isControlInvalid does not "see" through ComponentContainer
@dg dg merged commit e6d2176 into nette:master Dec 21, 2011
dg pushed a commit to nette/application that referenced this pull request Mar 13, 2014
dg pushed a commit to nette/application that referenced this pull request Mar 20, 2014
@JanTvrdik JanTvrdik deleted the i93-isControlInvalid branch February 28, 2017 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants