Comments (11)
@dmitryuk thanks for your reply, but I am still completely baffled. 😕 I have a very standard installation of auditor-bundle v5.2.1
dh_auditor.yaml
dh_auditor:
providers:
doctrine:
viewer: true
ignored_columns:
- 'createdAt'
- 'updatedAt'
entities:
App\Entity\User:
roles:
view:
- 'ROLE_SUPER_ADMIN'
but in test
environment, I do this:
dh_auditor:
enabled: false
from auditor.
I checked and found that issue already fixed in
DamienHarper/auditor-bundle@e584374#diff-5864ffa23fdebf7326e8f8e2363c59b16447da425ce48776db1bc833fd832d02R24
DoctrineProviderConfigurationCompilerPass
was loaded after Doctrine\MiddlewaresPass
so it didn't work properly
@DamienHarper, please make a new tag of auditor-bundle to apply changes.
from auditor.
@DamienHarper I'd like to correct this in my code as well but don't understand the deprecation message.
User Deprecated: Since damienharper/auditor 2.2: SQLLogger is deprecated. Use DHMiddleware instead
Is there some documentation on how to "use DHMiddleware" and why it is needed?
I found this: DamienHarper/auditor-bundle#331 but don't understand what @dmitryuk means by "But now the error not caused by auditor package and must be resolved outside the package."
Help is appreciated.
from auditor.
@FluffyDiscord, What version of damienharper/auditor-bundle
do you have in composer.lock
?
If you have DoctrineProviderConfigurationCompilerPass
easiest way to understand the problem is to manually debug the process
method. Looks like $configuration->addMethodCall('setMiddlewares', [[$DHMiddlewareDef]]);
never executes
from auditor.
@craigh SqlLogger
is deprecated since Doctrine have created a new Middleware way to do the same.
About my comment - anyway if I don't use SqlLogger
Symfony defines service named DbalLogger implements SqlLogger
and we see a deprecation error:
User Deprecated: The "Symfony\Bridge\Doctrine\Logger\DbalLogger" class implements "Doctrine\DBAL\Logging\SQLLogger" that is deprecated Use {@see \Doctrine\DBAL\Logging\Middleware} or implement {@see \Doctrine\DBAL\Driver\Middleware} instead.
DamienHarper/auditor-bundle#331 (comment)
from auditor.
What version of doctrine/dbal
do you have in composer.lock
?
from auditor.
"name": "doctrine/dbal",
"version": "3.5.2",
from auditor.
@DamienHarper, ping
from auditor.
@FluffyDiscord Please install latest version of damienharper/auditor-bundle:^5.2.2
- issue must be fixed
from auditor.
Done in 5.2.3
, @DamienHarper close issue
from auditor.
The problem still exists when using sentry and dh auditor together, as sentry adds itself to the end of the doctrine middlewares: https://github.com/getsentry/sentry-symfony/blob/master/src/DependencyInjection/Compiler/DbalTracingPass.php#L71
This fails the drive instance check, as the last :
$driver = $entityManager->getConnection()->getDriver();
if ($driver instanceof DHDriver) {
I don't see a way to check if DHDriver is wrapped somewhere in the middleware chain... So my hacky workaround is to put the DHMiddleware to the end again:
<?php
namespace App\DependencyInjection\CompilerPass;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class DoctrineMiddlewarePass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$definition = $container->getDefinition('doctrine.dbal.default_connection.configuration');
foreach ($definition->getMethodCalls() as $methodCall) {
if ('setMiddlewares' !== $methodCall[0]) {
continue;
}
// get DH middleware and put it to the end
$dhMiddleware = null;
$calls = $methodCall[1];
foreach ($calls[0] as $key => $call) {
if ($call instanceof ChildDefinition
&& 'doctrine.dbal.default_connection.dh_middleware' === $call->getParent()) {
$dhMiddleware = $key;
break;
}
}
if (null === $dhMiddleware) {
throw new \InvalidArgumentException('dh middleware not found in setMiddlewares call');
}
$dhCall = $calls[0][$dhMiddleware];
unset($calls[0][$dhMiddleware]);
$calls[0][] = $dhCall;
$definition->removeMethodCall('setMiddlewares');
$definition->addMethodCall('setMiddlewares', $calls);
}
}
}
And add the compiler pass to the Kernel:
$container->addCompilerPass(new DoctrineMiddlewarePass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, -100);
from auditor.
Related Issues (20)
- Warning: mb_convert_encoding(): Object is not supported HOT 2
- Make DoctrineODM / MongoDB compatible?
- Custom columns and custom data in the audit tables
- Example use statement shown for Auditing Configuration in Docs Undefined HOT 1
- Correct timezone on Created_At field HOT 1
- You have requested a non-existent parameter "dh_auditor.provider.doctrine.configuration". HOT 4
- Invalid audit table name with schema
- Inject the entity in the UserProvider HOT 1
- `ignored_columns` as a callback or as a service
- Route name on transaction
- Wrong migration when using Postgres HOT 4
- DoctrineSubscriber throw deprecation when Driver is wrapped with another class HOT 11
- Nested LoggerChain DoctrineSubscriber HOT 3
- Multiple Logs Updates with Decimal values HOT 1
- Mass import generate same hash for all operations
- ORM 3 HOT 1
- Invalid table name on Postgresql
- Update SimpleFilter value type to accept int
- Importing Audit data from another system
- Remove the final keyword for some classes?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from auditor.