Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

mbabker
Copy link
Contributor

@mbabker mbabker commented Jul 3, 2025

Partially addresses #1895

This will stop calling the ORM Configuration class' deprecated setAutoGenerateProxyClasses(), setProxyDir(), and setProxyNamespace() methods when the native lazy objects feature is enabled and soft-deprecates the relevant config options by noting they'll be ignored in this case. This purposely only stops calling those methods with ORM 3.5 since 3.4 doesn't have the deprecation notices and issues like doctrine/orm#11997 meant with 3.4.0 specifically there were a couple of cases where not configuring them led to errors.

@mbabker mbabker force-pushed the proxy-config-deprecations branch from f4344bc to c50ce02 Compare July 3, 2025 15:47
@ostrolucky ostrolucky added this to the 2.16.0 milestone Jul 3, 2025
Copy link
Member

@greg0ire greg0ire left a comment

Choose a reason for hiding this comment

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

Looks good. Is the plan to hard deprecate it in 2.17.x?

@ostrolucky ostrolucky merged commit 3a854f8 into doctrine:2.16.x Jul 7, 2025
12 checks passed
@mbabker mbabker deleted the proxy-config-deprecations branch July 7, 2025 13:31
@Gemorroj
Copy link

what about 2.15.x branch?

@ostrolucky
Copy link
Member

That one is for bug fixes only

@Gemorroj
Copy link

Gemorroj commented Jul 14, 2025

php 8.4
2.16.x branch
config:

    orm:
        auto_generate_proxy_classes: true
        enable_lazy_ghost_objects: true
        report_fields_where_declared: true
        validate_xml_mapping: true
        naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
        identity_generation_preferences:
            Doctrine\DBAL\Platforms\PostgreSQLPlatform: identity
        auto_mapping: true
        enable_native_lazy_objects: true
        mappings:
            App:
                type: attribute
                is_bundle: false
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App
        controller_resolver:
            auto_mapping: false
composer update --with-all-dependencies

Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!
!!  In ProxyCacheWarmer.php line 49:
!!                                                       
!!    Unable to create the Doctrine Proxy directory "".  
!!                                                       
!!
!!
Script @auto-scripts was called via post-update-cmd

@ostrolucky
Copy link
Member

Hm maybe we should unset these settings only if enable_lazy_ghost_objects = false?

@mbabker
Copy link
Contributor Author

mbabker commented Jul 16, 2025

I'm heading out of town so can't help more right now, but lazy ghosts probably shouldn't be enabled alongside native ghosts. But that's also a little weird because the settings in this PR and that lazy ghost option are in the "don't configure this for each EM" list, but native ghosts can be configured on each EM separately.

@mbabker
Copy link
Contributor Author

mbabker commented Jul 24, 2025

The cache warmer issue looks to be a bug in symfony/doctrine-bridge, this block always tries to create the proxy directory and doesn't handle a null return from the object manager configuration's getProxyDir() method (both the ORM and MongoDB ODM have nullable returns, the PHPCR ODM defaults to the system temp folder so it won't return null).

Fixing some of this would be easier if the enable_native_lazy_objects option were in the list of keys that isn't configured on each entity manager separately, but that ship has sailed (because that'd also give a way to approach not enabling the deprecated proxy autoloader as well). So right now, if a Symfony application running ORM 3.4 or later on PHP 8.4 has multiple entity managers, and at least one of them doesn't have the native lazy objects option enabled, the cache warmer and proxy autoloader need to be active.

@acasademont
Copy link

is it too late to chang that option to make it global? it would be a bc-break but i don't think many people have used it yet...As you say it would make it easier to also fix the other deprecation notice

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.

6 participants