common icon indicating copy to clipboard operation
common copied to clipboard

Undefined constant shown

Open victormacko opened this issue 2 years ago • 3 comments

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/__CG__AppEntityMemberMember.php line 1309

Exception: Error

  • Undefined constant "App\Entity\Member\AUTH_TYPE_ANY"

Stacktrace;

/tmp/cache/prod/doctrine/orm/Proxies/__CG__AppEntityMemberMember.php:1309 /var/task/src/Entity/Member/Member.php:2864 /tmp/cache/prod/doctrine/orm/Proxies/__CG__AppEntityMemberMember.php:1809 /var/task/src/Entity/Member/Member.php:2835 /tmp/cache/prod/doctrine/orm/Proxies/__CG__AppEntityMemberMember.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.

victormacko avatar Sep 27 '22 23:09 victormacko

@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.

malarzm avatar Sep 28 '22 06:09 malarzm

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.

victormacko avatar Sep 28 '22 12:09 victormacko

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

nicolas-grekas avatar Sep 28 '22 16:09 nicolas-grekas