Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQLMutex doesn't work correctly together with Sentry #53

Open
eddokloosterman opened this issue Oct 5, 2022 · 1 comment
Open

MySQLMutex doesn't work correctly together with Sentry #53

eddokloosterman opened this issue Oct 5, 2022 · 1 comment

Comments

@eddokloosterman
Copy link

After upgrading Symfony and Sentry ("sentry/sentry-symfony": "^4.3.0") I got the message that I needed to also upgrade doctrine/dbal ("doctrine/dbal": "^2.13.9",) , which then subsequently broke my use of MySQLMutex.

<b>Fatal error</b>:  Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Type error: Argument 1 
passed to malkusch\lock\mutex\MySQLMutex::__construct() must be an instance of PDO, instance of 
Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingServerInfoAwareDriverConnection given, called in 
/var/www/html/src/ApiBundle/Controller/Invoicing/InvoiceController.php on line 533 in 
/var/www/html/vendor/malkusch/lock/classes/mutex/MySQLMutex.php:27

The MySQLMutex class only expects an instance of PDO to be provided, and in my case this is actually an instance of the Doctrine\DBAL\Connection interface with the updated Sentry package.

$em = $this->getContainer()->get('doctrine.orm.entity_manager');
$pdo = $em->getConnection()->getWrappedConnection();
$mutex = new MySQLMutex($pdo, 'Some lock');

A solution would be to adapt the package so that the MySQLMutex class accepts both an instance of PDO and Doctrine\DBAL\Connection.

Might make a PR for this in the coming week.

@willemstuursma
Copy link
Contributor

I think you should just call \Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingServerInfoAwareDriverConnection::getNativeConnection or \Sentry\SentryBundle\Tracing\Doctrine\DBAL\TracingServerInfoAwareDriverConnection::getWrappedConnection again on the object until you get the PDO object. Can you give it a shot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants