Coder Social home page Coder Social logo

Deprecation spam about auditor HOT 11 CLOSED

FluffyDiscord avatar FluffyDiscord commented on June 16, 2024
Deprecation spam

from auditor.

Comments (11)

craigh avatar craigh commented on June 16, 2024 1

@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.

dmitryuk avatar dmitryuk commented on June 16, 2024 1

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.

craigh avatar craigh commented on June 16, 2024

@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.

dmitryuk avatar dmitryuk commented on June 16, 2024

@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.

dmitryuk avatar dmitryuk commented on June 16, 2024

@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.

dmitryuk avatar dmitryuk commented on June 16, 2024

What version of doctrine/dbal do you have in composer.lock?

from auditor.

craigh avatar craigh commented on June 16, 2024
            "name": "doctrine/dbal",
            "version": "3.5.2",

from auditor.

dmitryuk avatar dmitryuk commented on June 16, 2024

@DamienHarper, ping

from auditor.

dmitryuk avatar dmitryuk commented on June 16, 2024

@FluffyDiscord Please install latest version of damienharper/auditor-bundle:^5.2.2 - issue must be fixed

from auditor.

dmitryuk avatar dmitryuk commented on June 16, 2024

Done in 5.2.3, @DamienHarper close issue

from auditor.

Marmelatze avatar Marmelatze commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.