dachcom-digital / pimcore-members

Pimcore Object, Asset and Document Restriction & Frontend Authentication
Other
54 stars 34 forks source link

UserAwareEncoderFactory autoloading issue #114

Closed marekgach closed 5 years ago

marekgach commented 5 years ago
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no

Installed libraries:

After a fresh install of those version combinations, I am not able to run any command from Pimcore console.

After running php bin/console cache:clear --no-warmup or even php bin/console the command seems to run but new error is emmited to var/logs/php.log:

[09-Oct-2019 18:02:55 Europe/Berlin] PHP Fatal error:  Uncaught Symfony\Component\DependencyInjection\Exception\RuntimeException: Invalid service "MembersBundle\Security\Encoder\Factory\UserAwareEncoderFactory": class "MembersBundle\Security\Encoder\Factory\UserAwareEncoderFactory" does not exist. in /home/marek/kurzor/repo/kurzor/maturikon-cz/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php:122
Stack trace:
#0 /home/marek/kurzor/repo/kurzor/maturikon-cz/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php(148): Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->getConstructor(Object(Symfony\Component\DependencyInjection\Definition), true)
#1 /home/marek/kurzor/repo/kurzor/maturikon-cz/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/ResolveNamedArgumentsPass.php(50): Symfony\Component\DependencyInjection\Compiler\AbstractRecursivePass->getReflectionMethod(Object(Symfony\Component\DependencyInjection\Definition), '__constru in /home/marek/kurzor/repo/kurzor/maturikon-cz/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/AbstractRecursivePass.php on line 122

When I was doing some investigation it seems there is some problem with an autoloader. Class UserAwareEncoderFactory is in namespace MembersBundle\Security\Encoder\Factory however directory structure is missing last part and is MembersBundle\Security\Encoder which will make mess in PSR-4 autoloading.

When I did some small test and moved class in my vendor folder into the correct place everything started to work: image

Maybe some autoloader generation or some special config breaks it up, but I am not aware of anything like this. At least I personally think the directory structure will not work with PSR-4.

Waiting for your comments. Maybe I miss something heavily.

marekgach commented 5 years ago

I have optimize-autoloader set to true in my composer.json. This is the only part that possibly can cause such an issue when the directory structure is not according to PSR-4 rules.

marekgach commented 5 years ago

So what I found out after a few hours is that the machine was running an older Composer. But still not any super very old one:

Composer version 1.2.1 2016-09-12 11:27:19

So the issue was fixed after the Composer upgrade. However, I think this may be a good idea you will change the directory structure to comply with PSR-4. Because only this error is blocking it from running in older Composer. I can approve in Composer 1.6 everything is working fine.

Decide what to do, comment and feel free to close this issue. Thanks!

solverat commented 5 years ago

hey @marekgach. You are absolutely right - thanks to composer, this issue never showed up! I'll fix it right away.