doctrine / common

Doctrine Common
https://www.doctrine-project.org/projects/common.html
MIT License
5.78k stars 294 forks source link

Undefined constant shown #990

Open victormacko opened 1 year ago

victormacko commented 1 year ago

It looks like the error reported in #983 is still happening - using PHP 8.1;

Uncaught PHP Exception Error: "Undefined constant "App\Entity\Member\AUTH_TYPE_ANY"" at /tmp/cache/prod/doctrine/orm/Proxies/CGAppEntityMemberMember.php line 1309

Exception: Error

Stacktrace;

/tmp/cache/prod/doctrine/orm/Proxies/CGAppEntityMemberMember.php:1309 /var/task/src/Entity/Member/Member.php:2864 /tmp/cache/prod/doctrine/orm/Proxies/CGAppEntityMemberMember.php:1809 /var/task/src/Entity/Member/Member.php:2835 /tmp/cache/prod/doctrine/orm/Proxies/CGAppEntityMemberMember.php:1798 /var/task/src/Service/Event/MyService.php:272

Code; This is referring to this method signature;

public function isMemberAuthorised( string $section, int $level_required, $type = AUTH_TYPE_ANY, $group = AUTH_GROUP_ANY ): bool { ... }

Let me know if you need any more info - happy to help where I can.

malarzm commented 1 year ago

@victormacko yesterday I've noticed that if you prefix global const with \ the generator will work good enough. I'll be looking into fixing this, but in the meantime could you please test #989? It'll solve your issue as long as consts have scalar values behind them.

victormacko commented 1 year ago

The only way i've been able to reproduce this so far is occasionally in prod -- prefer not to be testing code in prod like that, and due to it's occasional nature, it's hard to reproduce in staging. Is there any way to have it fixed without the '\' prefixing the constants? ... there'd be no-way of knowing if things are breaking until it's all too late otherwise!

Thanks in advance for your help - it's super appreciated.

nicolas-grekas commented 1 year ago

Also handled in https://github.com/symfony/symfony/blob/6.2/src/Symfony/Component/VarExporter/ProxyHelper.php#L318 for inspiration.