Question: Getting rows affected by token deletion
It would be helpful if delete() returned the number of rows affected. I need this to ensure that a single-use token is truly only refreshed once.
Instead, I am using DQL to get this information:
$q = $this->entityManager->createQuery('delete from Gesdinet\JWTRefreshTokenBundle\Entity\RefreshToken rt where rt.id = :id');
$q->setParameter('id', $refreshToken->getId());
$numDeleted = $q->execute();
But it would be nice if $this->refreshTokenManager->delete($refreshToken) returned this info for me.
@rajivraman-MRM do you want to sent a new PR for this? Thanks
@rajivraman-MRM do you want to sent a new PR for this? Thanks
@shakaran I'm currently just doing this in a controller, but sure I can work on a PR.
@rajivraman-MRM I just made the PR https://github.com/markitosgv/JWTRefreshTokenBundle/pull/405
Let me know if works fine for you in master
@rajivraman-MRM I just made the PR #405
Let me know if works fine for you in master
@shakaran thank you for jumping on it! Unfortunately, that patch is still prone to race condition. Two threads can both findOneBy the record, and attempt the delete. But only one will succeed. Seems the only way to truly get the number of rows affected from the delete is by calling execute.
@rajivraman-MRM I just made the PR #405
Let me know if works fine for you in master
@shakaran thank you for jumping on it! Unfortunately, that patch is still prone to race condition. Two threads can both
findOneBythe record, and attempt the delete. But only one will succeed. Seems the only way to truly get the number of rows affected from the delete is by callingexecute.
ok, waiting for you pull request covering the case. Take in mind the ObjectManager with remove doesnt return info and we dont have the createQuery
@shakaran I opened https://github.com/markitosgv/JWTRefreshTokenBundle/pull/406