pim-community-dev
pim-community-dev copied to clipboard
RemoveNonExistingProductValuesSubscriber requires a logged in user
:bug: I'm reporting a Bug :bug:
Context: When trying to create/delete attribute options from a CLI or testing context an error is thrown.
[Error] Call to a member function getUser() on null
#1 /var/www/html/vendor/akeneo/pim-community-dev/src/Akeneo/Pim/Structure/Bundle/EventListener/RemoveNonExistingProductValuesSubscriber.php:71
#2 /var/www/html/vendor/symfony/event-dispatcher/Debug/WrappedListener.php:117
#3 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php:230
#4 /var/www/html/vendor/symfony/event-dispatcher/EventDispatcher.php:59
#5 /var/www/html/vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:154
Cause
RemoveNonExistingProductValuesSubscriber::launchRemoveNonExistingProductValuesJob
requires a user to be logged in.
TokenStorageInterface::getToken
can return null. This is not handled properly.
JobLauncherInterface::launch
is designed to work with null
for $user
.
Fix
On RemoveNonExistingProductValuesSubscriber:71
allow null
- $user = $this->tokenStorage->getToken()->getUser();
+ $user = $this->tokenStorage->getToken()?->getUser();
Will create a pull request.
Any update on this?