DamienHarper / auditor-bundle

The missing audit log library
MIT License
400 stars 121 forks source link

auditor Bundle listener not call in prod and dev #251

Closed zisson closed 3 years ago

zisson commented 3 years ago
Q A
auditor-bundle version 4.1.0
PHP version 7.1
Database MySQL

Summary

After installation and configuration of the bundle, no activity on the audited entity. After some research, I had to configure the doctrine listener in the service to listen to the events. In principle, the bundle must do this by itself. No need to do it manually

Current behavior

No activity on my audited entity

How to reproduce

Follow the installation recommended in the bundle doc and modify a header to be audited

Expected behavior

Pour y remedier j'ai du ajouter ces lignes dans mon fichier service.yml

DH\Auditor\Provider\Doctrine\Auditing\Transaction\TransactionManager: arguments: [ '@DH\Auditor\Provider\Doctrine\DoctrineProvider' ]

DH\Auditor\Provider\Doctrine\Auditing\Event\DoctrineSubscriber: arguments: [ '@DH\Auditor\Provider\Doctrine\Auditing\Transaction\TransactionManager' ] tags:

DamienHarper commented 3 years ago

@zisson thanks for the report, could you please tell me what version of auditor you're using (run composer info | grep "auditor" to check that).

The latest version of auditor is 1.2.0 so if you're not using the latest version, please consider updating to 1.2.0.

Also, could you please provide the result of composer info, it would be helpful.

zisson commented 3 years ago

Thanks for your quick return. I use the version dev-master de auditor.

DamienHarper commented 3 years ago

@zisson Could you please provide the result of composer info, it would be helpful.

zisson commented 3 years ago

result of command `damienharper/auditor dev-master 297c37a The missing audit l...

damienharper/auditor-bundle 4.1.0 Integrate auditor l`

DamienHarper commented 3 years ago

Could you please give the full result of composer info?

zisson commented 3 years ago

@DamienHarper damienharper/auditor dev-master 297c37a The missing audit log library. damienharper/auditor-bundle 4.1.0 Integrate auditor library in your Symfony projects.

DamienHarper commented 3 years ago

I need the full result, not only the lines belonging to auditor please. => full result of composer info

zisson commented 3 years ago

api-platform/core v2.2.0 beberlei/doctrineextensions v1.3.0 composer/xdebug-handler 1.4.5 damienharper/auditor dev-master 297c37a The missing audit log library. damienharper/auditor-bundle 4.1.0 Integrate auditor library in your Symfony projects. debril/feed-io v3.0.10 doctrine/annotations 1.12.1 doctrine/collections 1.6.7 doctrine/common 2.13.3 doctrine/dbal 2.12.1 doctrine/doctrine-bundle 1.12.13 doctrine/doctrine-cache-bundle 1.4.0 doctrine/doctrine-fixtures-bundle 3.4.0 doctrine/doctrine-migrations-bundle v1.3.2 doctrine/event-manager 1.1.1 doctrine/inflector 1.4.3 doctrine/instantiator 1.4.0 doctrine/lexer 1.2.1 doctrine/migrations v1.8.1 doctrine/orm 2.7.5 doctrine/persistence 1.3.8 doctrine/reflection 1.2.2 friendsofphp/php-cs-fixer v2.16.4 friendsofsymfony/user-bundle v2.0.2

DamienHarper commented 3 years ago

@zisson that's strange, I don't see any ref to symfony/doctrine-bridge. Could you try to add it to your deps please?

zisson commented 3 years ago

ok. But Why doctrine-bridge is not a dependency of your bundle ?

DamienHarper commented 3 years ago

@zisson it is, that's why I found your composer info output strange.

DamienHarper commented 3 years ago

@zisson Any news?

DamienHarper commented 3 years ago

@zisson Do you still face this issue?

benoliver999 commented 3 years ago

I actually have just encountered this when testing out the bundle.

Adding the services works for me.

Version 4.1.0, but on an old version of Symfony, 3.4, don't judge me.

composer info shows:

behat/transliterator                 v1.3.0            String transliterator
chrisandchris/barcode-bundle         v1.0.0            Symfony2 Barcode Generator Bundle with Twig function extension
composer/ca-bundle                   1.2.9             Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.
composer/package-versions-deprecated 1.11.99.1         Composer plugin that provides efficient querying for installed package versions (no runtime IO)
damienharper/auditor                 1.2.0             The missing audit log library.
damienharper/auditor-bundle          4.1.0             Integrate auditor library in your Symfony projects.
doctrine/annotations                 1.12.1            Docblock Annotations Parser
doctrine/cache                       1.10.2            PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.
doctrine/collections                 1.6.7             PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                      2.13.3            PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better reflection support...
doctrine/data-fixtures               1.5.0             Data Fixtures for all Doctrine Object Managers
doctrine/dbal                        2.10.4            Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.
doctrine/doctrine-bundle             1.10.1            Symfony DoctrineBundle
doctrine/doctrine-cache-bundle       1.4.0             Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle    3.0.2             Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle  v2.0.0            Symfony DoctrineMigrationsBundle
doctrine/event-manager               1.1.1             The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                   1.4.3             PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.
doctrine/instantiator                1.4.0             A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                       1.2.1             PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                  2.3.1             PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and e...
doctrine/orm                         v2.7.0            Object-Relational-Mapper for PHP
doctrine/persistence                 1.3.8             The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/reflection                  1.2.2             The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional functionality on top of the reflect...
egulias/email-validator              3.1.0             A library for validating emails against several RFCs
fig/link-util                        1.1.2             Common utility implementations for HTTP links
friendsofsymfony/user-bundle         v2.1.1            Symfony FOSUserBundle
incenteev/composer-parameter-handler v2.1.2            Composer script handling your ignored parameter file
jdorn/sql-formatter                  v1.2.17           a PHP SQL highlighting library
jjalvarezl/pdfjs-viewer-bundle       dev-sf3 c444b4f   This bundle provides an integration of pdf.js from mozilla with Symfony 3 framework and customizable parameters on server side
jms/metadata                         1.7.0             Class/method/property metadata management in PHP
kriswallsmith/assetic                v1.4.0            Asset Management for PHP
league/flysystem                     1.1.3             Filesystem abstraction: Many filesystems, one API.
league/flysystem-sftp                1.0.22            Flysystem adapter for SFTP
league/mime-type-detection           1.7.0             Mime-type detection for Flysystem
monolog/monolog                      1.26.0            Sends your logs to files, sockets, inboxes, databases and various web services
ocramius/proxy-manager               2.2.3             A library providing utilities to generate, instantiate and generally operate with Object Proxies
oneup/flysystem-bundle               3.7.0             Integrates Flysystem filesystem abstraction library to your Symfony project.
paragonie/random_compat              v2.0.19           PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phpseclib/phpseclib                  2.0.30            PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.
psr/cache                            1.0.1             Common interface for caching libraries
psr/container                        1.1.1             Common Container Interface (PHP FIG PSR-11)
psr/link                             1.0.0             Common interfaces for HTTP links
psr/log                              1.1.3             Common interface for logging libraries
psr/simple-cache                     1.0.1             Common interfaces for simple caching
sensio/distribution-bundle           v5.0.21           Base bundle for Symfony Distributions
sensio/framework-extra-bundle        v5.1.4            This bundle provides a way to configure your controllers with annotations
sensiolabs/security-checker          v4.1.8            A security checker for your composer.lock
swiftmailer/swiftmailer              v6.2.7            Swiftmailer, free feature-rich PHP mailer
symfony/assetic-bundle               v2.8.2            Integrates Assetic into Symfony2
symfony/monolog-bundle               v3.1.2            Symfony MonologBundle
symfony/phpunit-bridge               v3.4.4            Symfony PHPUnit Bridge
symfony/polyfill-apcu                v1.22.1           Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype               v1.22.1           Symfony polyfill for ctype functions
symfony/polyfill-iconv               v1.22.1           Symfony polyfill for the Iconv extension
symfony/polyfill-intl-icu            v1.22.1           Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn            v1.22.1           Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer     v1.22.1           Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring            v1.22.1           Symfony polyfill for the Mbstring extension
symfony/polyfill-php56               v1.20.0           Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70               v1.20.0           Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php72               v1.22.1           Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/swiftmailer-bundle           v3.1.6            Symfony SwiftmailerBundle
symfony/symfony                      3.4.x-dev 83093d5 The Symfony PHP framework
tetranz/select2entity-bundle         v2.9.4            A Symfony2 bundle that integrates Select2 as a drop-in replacement for a standard entity field on a Symfony form.
twig/extensions                      v1.5.1            Common additional features for Twig that do not directly belong in core
twig/twig                            v2.14.4           Twig, the flexible, fast, and secure template language for PHP
vich/uploader-bundle                 1.8.1             Ease file uploads attached to entities
zendframework/zend-code              3.4.1             Extensions to the PHP Reflection API, static code scanning, and code generation
zendframework/zend-eventmanager      3.2.1             Trigger and listen to events within a PHP application
DamienHarper commented 3 years ago

@benoliver999 thanks for the feedback and regarding Symfony 3.4, nobody's perfect 🤣 More seriously, I notice that you also don't have symfony/doctrine-bridge either which seems weird since it's required by auditor-bundle. Could you please try to install it manually and retry?

benoliver999 commented 3 years ago

I can't get it to install directly with composer require, it moans about a conflict with another require.

I also tried composer require symfony/doctrine-bridge "^3.4"

It didn't moan, but also it weirdly didn't appear to install doctrine-bridge. composer show still didn't show it.

Tried removing the services anyway, but it stopped working again.

gassan commented 3 years ago

its very strange. Local (macos) works without entries (both dev and prod) With entries in services.yml all changes are stored twice. On live server (debian) it works only with adding services to services.yml (dev and prod)

benoliver999 commented 3 years ago

Wow, I wouldn't have tied it back to OS!

I can confirm I'm using Debian.

I really don't mind having the entries in services.yml but as you say if it could end up auditing stuff twice it's something to keep an eye on.

llupa commented 3 years ago

I had this issue today. Same as the other commenters.

In my case adding the services in my services.yml seems to fix the issue. I also have a Sf 3.4 project.

My main suspicion right now is the way Sf 3.4 symfony/symfony works, which conflicts with Sf flex / Sf 4.4 and up. In the Doctrine bridge library under RegisterEventListenersAndSubscribersPass Symfony is trying to service-ify subscribers and listeners related to Doctrine, the Auditor library directly injects the subscriber class in the EventManager from Doctrine. The hypothesis is that maybe the Auditor should let Symfony handle this and let the Doctrine EvM "alone". 🤷

I haven't found anything substantial, but if I do I will update this comment (at least).

gassan commented 3 years ago

Since 09.07.2021 works good on prod without lines in services.yaml. I have no idea what was changed at the time.

DamienHarper commented 3 years ago

As long as I've never been able to reproduce the issue and no other feedback have been provided, I close this issue. Feel free to reopen if needed.

moag1000 commented 2 years ago

I can confirm that this issue is happening to me on both stable and dev-master version of auditor-bundle (Symfony 5.4.2 LTS, recent apache, php8.1, recent mariadb) on a debian buster machine both on dev and prod. The exact same project on my dev machine executes logging perfectly (same php and mariadb version), so I assume it's some weird OS behaviour. There is nothing unusual in the logs.

My fix was to register the services manually in the services.xml (but only in the debian machine to avoid double logging on the dev machine).

Any advice how to track this down further? Unfortunately, I am not able to publish the demo because of the productive state of the machine in my case.