Open JanTvrdik opened 1 year ago
We're currently sunsetting the Common library including the proxy implementation. This is why I'm a bit reluctant to introduce this kind of change into the codebase at this point.
Furthermore, this is not a bugfix but rather a workaround for a very arbitrary limitation of the filesystem that you are using.
Can you elaborate what you use proxies for? Have you tried to work around the issue without changing doctrine/common?
Can you elaborate what you use proxies for?
I'm using proxies as part of doctrine/orm.
Have you tried to work around the issue without changing doctrine/common?
Yes, but there is no easy way to use custom logic for naming proxies, because ProxyGenerator
instance is created in constructor of Doctrine\ORM\Proxy\ProxyFactory
and ProxyFactory
instance is created in constructor of Doctrine\ORM\EntityManager
.
@JanTvrdik on PHP 8.1 and newer, the ORM has a new proxy implementation (currently opt-in) that is based on the trait provided by symfony/var-exporter.
However, I think the new code in Doctrine\ORM\Proxy\ProxyFactory in doctrine/orm 2.17.x uses the same naming convention for files and so would suffer from the same issue.
@derrabus IMO, we should still do a bugfix in doctrine to avoid generating file names of arbitrary lengh. All filesystems have such limitations (it is just that eCryptfs has a max file name length that is but shorter than ext4 so it is easier to reach it). See https://bugs.launchpad.net/ecryptfs/+bug/344878/comments/10 for a comment in the ecryptfs explaining that.
The current file name generating takes the FQCN of the entity and uses that as part of the file name as is. This could even reach the ext4 limit if the FQCN is long enough.
However, I'm not sure spreading generated proxies in subfolder is the right approach to fix this.
However, I think the new code in Doctrine\ORM\Proxy\ProxyFactory in doctrine/orm 2.17.x uses the same naming convention for files and so would suffer from the same issue.
Then let's start with the ORM please. ORM 2.17 with recommended settings will bypass whatever we change in doctrine/common anyway.
The maximum file name length when using eCryptfs is 143 bytes. This causes issues with Doctrine proxies where with current implementation this limit can be exceeded.
This PR changes how proxy file name is generated to avoid hitting this limit.