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

NotNull: HasNodeInterface with odd interference with PropertyInfoLoader #3232

Open
tarjei opened this issue Dec 20, 2022 · 4 comments
Open

Comments

@tarjei
Copy link
Contributor

tarjei commented Dec 20, 2022

After upgrading to 6.2.3 and PHP 8.2, we suddenly experienced validationerrors when saving pages. The errors reported that the page.parent attribute was null, thus invalidating a NotNull constraint.

After a lot of grepping back and forth a longish debugger session we found out that the PropertyInfoLoader had started to report that the parent attribute on a subclass of AbstractPage - from the HasNodeInterface is a non null value and thus needs to be set when submitting the form.

In our code this seems to kick in after upgrading to 6.1, but I am not sure if this relates to a specific version of doctrine or Symfony dependencies.

Anyhow, the workaround I found was for all subclasses of AbstractPage to add a parent attribute that also disabled the automapping from the validator:

/**
     * @Assert\DisableAutoMapping()
     */
    protected $parent;

Now, the best solution IMHO would be to either make setParent() accept a null on the HasNodeInterface or to disable the automapping directly on the interface. But as that is quite far into the core of Kunstmaan I thought I'd report an issue before thinking of a PR.

@tarjei
Copy link
Contributor Author

tarjei commented Apr 20, 2023

@acrobat anye news on this? I just hit the same issue on another site :)

@acrobat
Copy link
Member

acrobat commented Apr 20, 2023

Hi @tarjei, I lost track of this issue but it's not something we see in our projects so we might need to debug this further. Can you share the installed packages and versions in those projects? And can you check in the symfony config of those projects if framework.validation.auto_mapping is enabled?

@tarjei
Copy link
Contributor Author

tarjei commented Apr 20, 2023

@acrobat :

    validation:
        auto_mapping:
            App\Entity\:
                services: {  }
        email_validation_mode: html5
        enabled: true
        enable_annotations: true
        static_method:
            - loadValidatorMetadata
        translation_domain: validators
        mapping:
            paths: {  }
        not_compromised_password:
            enabled: true
            endpoint: null

@tarjei
Copy link
Contributor Author

tarjei commented Apr 20, 2023

@acrobat the entities in question are in the App\Entity namespace. AFAIK this is the standard config, is it not?

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

No branches or pull requests

2 participants