Skip to content

[PropertyAccess] Fix handling of uninitialized property of parent class #45255

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

Conversation

filiplikavcan
Copy link
Contributor

@filiplikavcan filiplikavcan commented Jan 31, 2022

Q A
Branch? 4.4
Bug fix? yes
Tickets Fix #45233
New feature? no
Deprecations? no
License MIT

This fix introduced a new bug:

class X
{
    public int $a;
}

class Y extends X
{
}

(new Y)->a;

// PropertyAccessor expects: Typed property Y::$a must not be accessed before initialization
// Actual exception message: Typed property X::$a must not be accessed before initialization

This prevents from throwing AccessException exception and it bubbles up and causes this exception after form submit: "Typed property X::$a must not be accessed before initialization" which would otherwise be handled by PropertyPathAccessor:

        } catch (PropertyAccessException $e) {
            // ...

            return null;
        }

@nicolas-grekas nicolas-grekas force-pushed the fix-unitialized-property-of-parent-class branch from bf24301 to 5cd10b0 Compare January 31, 2022 15:53
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a few changes, thanks for the PR.

@nicolas-grekas
Copy link
Member

Thank you @filiplikavcan.

@nicolas-grekas nicolas-grekas merged commit b7da2a0 into symfony:4.4 Jan 31, 2022
This was referenced Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants