Skip to content

Latest commit

 

History

History
168 lines (117 loc) · 6.16 KB

File metadata and controls

168 lines (117 loc) · 6.16 KB

UPGRADE FROM 6.x to 7.0

This document summarizes the backward incompatible changes introduced in auditor-bundle 7.0.

For a complete upgrade guide with step-by-step instructions, see the full documentation.

Requirements Changes

Requirement 6.x 7.0
PHP >= 8.2 >= 8.4
Symfony >= 5.4 >= 8.0
Doctrine DBAL >= 3.2 >= 4.0
Doctrine ORM >= 2.13 >= 3.2
Doctrine Bundle >= 2.0 >= 3.0
PHPUnit >= 11.0 >= 12.0
damienharper/auditor >= 3.2 >= 4.0

See auditor UPGRADE-4.0.md for auditor library changes.

Breaking Changes

auditor Library Changes

This bundle requires damienharper/auditor >= 4.0 which introduces several breaking changes:

Namespace Rename: Annotation → Attribute

Before (3.x) After (4.0)
DH\Auditor\...\Auditing\Annotation\Auditable DH\Auditor\...\Auditing\Attribute\Auditable
DH\Auditor\...\Auditing\Annotation\Ignore DH\Auditor\...\Auditing\Attribute\Ignore
DH\Auditor\...\Auditing\Annotation\Security DH\Auditor\...\Auditing\Attribute\Security
DH\Auditor\...\Auditing\Annotation\AnnotationLoader DH\Auditor\...\Auditing\Attribute\AttributeLoader

utf8_convert is now opt-in

The implicit mb_convert_encoding() pass on every audit entry is disabled by default (DBAL 4 enforces UTF-8). Re-enable it explicitly if needed:

dh_auditor:
    providers:
        doctrine:
            utf8_convert: true

Entry Model - Property Hooks (PHP 8.4)

Before After
$entry->getId() $entry->id
$entry->getType() $entry->type
$entry->getObjectId() $entry->objectId
$entry->getUserId() $entry->userId
$entry->getUsername() $entry->username
$entry->getCreatedAt() $entry->createdAt

See auditor UPGRADE-4.0.md for the complete list of changes.

Route Names

Before (6.x) After (7.0)
dh_auditor_show_entity_history dh_auditor_show_entity_stream
dh_auditor_show_transaction dh_auditor_show_transaction_stream

ConsoleUserProvider

CLI commands now use the command name as the user identifier:

Before (6.x) After (7.0)
blame_id: "command" blame_id: "app:import-users"
blame_user: "app:import-users" blame_user: "app:import-users"

Note: Existing audit entries with blame_id = "command" will not be automatically migrated.

Removed Classes

Removed Class Replacement
DH\AuditorBundle\DependencyInjection\Configuration DHAuditorBundle::configure()
DH\AuditorBundle\DependencyInjection\DHAuditorExtension DHAuditorBundle::loadExtension()
DH\AuditorBundle\DependencyInjection\Compiler\AddProviderCompilerPass Autowiring
DH\AuditorBundle\DependencyInjection\Compiler\CustomConfigurationCompilerPass DHAuditorBundle::loadExtension()
DH\AuditorBundle\DependencyInjection\Compiler\DoctrineProviderConfigurationCompilerPass DoctrineMiddlewareCompilerPass

UserProvider

The AnonymousToken handling was removed (deprecated in Symfony 6.0, removed in Symfony 8.0).

Template Blocks

The following Twig blocks have been removed from the base layout:

Removed Block Reason
navbar Replaced by built-in header
breadcrumbs No longer used

The dh_auditor_header and dh_auditor_pager blocks are still available in stream templates.

If you override layout.html.twig, update your template to use the available blocks: title, stylesheets, dh_auditor_content, javascripts.

Composer Scripts

The setup5, setup6, setup7, setup8 scripts have been replaced by a unified setup script.

PHP Attributes Migration

The following classes now use PHP 8.4+ attributes for auto-configuration:

Class Attributes Used
ConsoleEventSubscriber #[AsEventListener]
ViewerEventSubscriber #[AsEventListener]
ViewerController #[AsController]
TimeAgoExtension #[AsTwigFilter]
RoutingLoader #[AutoconfigureTag]

Final Classes

The following classes are now final and cannot be extended:

  • DH\AuditorBundle\Event\ConsoleEventSubscriber
  • DH\AuditorBundle\Event\ViewerEventSubscriber
  • DH\AuditorBundle\Twig\TimeAgoExtension
  • DH\AuditorBundle\Routing\RoutingLoader
  • DH\AuditorBundle\User\UserProvider
  • DH\AuditorBundle\User\ConsoleUserProvider
  • DH\AuditorBundle\Security\SecurityProvider
  • DH\AuditorBundle\Security\RoleChecker
  • DH\AuditorBundle\Viewer\ActivityGraphProvider

ActivityGraphProvider API Changes

Before After
$provider->getDays() $provider->days
$provider->getLayout() $provider->layout

TimeAgoExtension

TimeAgoExtension no longer extends Twig\Extension\AbstractExtension. If you extended this class, update your code accordingly.

SecurityProvider

SecurityProvider now uses #[Autowire] attribute for dependency injection. This is an internal change but may affect you if you were manually constructing this service.

Quick Migration

# 1. Update dependencies
composer require php:^8.4 symfony/framework-bundle:^8.0 \
    doctrine/dbal:^4.0 doctrine/orm:^3.2 doctrine/doctrine-bundle:^3.0 \
    damienharper/auditor:^4.0 damienharper/auditor-bundle:^7.0

# 2. Clear cache
bin/console cache:clear

# 3. Check schema
bin/console audit:schema:update --dump-sql

Need Help?