FOSCommentBundle icon indicating copy to clipboard operation
FOSCommentBundle copied to clipboard

Dependency on non existent service after update to v2.2.0

Open Stoakes opened this issue 6 years ago • 8 comments

Hi,

To begin with, thank you for this bundle, which brings me comments on pages with limited efforts.

I recently updated from FosComment 2.1.0 to 2.2.0 on a Symfony 3.4 project.

After the update, I got the error:

In CheckExceptionOnInvalidReferenceBehaviorPass.php line 31:
                                                                               
  The service "fos_comment.command.fix_aces" has a dependency on a non-existent service "security.acl.provider".   

I eventually overcomed it by running composer require symfony/security-acl and adding

# app/config/security.yml
security:
    acl:
        connection: default

Such change on a minor update is quite surprising, especially when used to Symfony lifecycle. Anyway, it might worth it to add a note on the 2.2.0 release page and/or the UPDATE.md to save some time for those who will get into the same issue.

Cheers

Stoakes avatar Jul 04 '18 21:07 Stoakes

That's a bug. It should not happen.

XWB avatar Jul 06 '18 12:07 XWB

@Stoakes I'm not fully understanding how the commands can be loaded without having ACL installed:

https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/DependencyInjection/FOSCommentExtension.php#L60 https://github.com/FriendsOfSymfony/FOSCommentBundle/blob/master/DependencyInjection/FOSCommentExtension.php#L139

As you can see, we only load commands.xml when ACL is enabled.

XWB avatar Jul 06 '18 12:07 XWB

It might comes from my config which is years old.

If you want to reproduce the issue:

git clone https://github.com/n7consulting/Incipio.git
cd Incipio
git checkout v2.6.0
composer install
# dependencies update will bump Foscomment bundle to 2.2.0 and should raise the error
composer update
# Post install scripts will fail, displaying the error

Fos Comment configuration on this project

Stoakes avatar Jul 07 '18 07:07 Stoakes

So you are using ACL, but the security.acl.provider service is not available in your project. Interesting. Can you try installing https://github.com/symfony/acl-bundle ?

XWB avatar Jul 07 '18 10:07 XWB

Got same bug, install bundle doesn't work. FML

87vrvk9k avatar Jul 21 '18 21:07 87vrvk9k

@XWB sorry for the delay,

Installing the acl-bundle doesn't fix the issue (error message doesn't change). However the fix in my first message still works.

So there is a workaround, the question is, is it a previous bug that is now fixed or the other way round ?

Don't know if you had a look to my configuration, but I was not using strict ACL, just role based ACL.

fos_comment:
    acl_roles:
        comment:
            create: ROLE_SUIVEUR
            view: ROLE_SUIVEUR
            edit: ROLE_SUIVEUR
            delete: ROLE_ADMIN
        thread:
            create: ROLE_SUIVEUR
            view: ROLE_SUIVEUR
            edit: ROLE_ADMIN
            delete: ROLE_ADMIN
        vote:
            create: ROLE_ADMIN
            view: ROLE_ADMIN
            edit: ROLE_ADMIN
            delete: ROLE_ADMIN
    acl: true
    service:
        acl:
            thread:  fos_comment.acl.thread.roles
            comment: fos_comment.acl.comment.roles
            vote:    fos_comment.acl.vote.roles
        manager:
            thread:  fos_comment.manager.thread.acl
            comment: fos_comment.manager.comment.acl
            vote:    fos_comment.manager.vote.acl

Stoakes avatar Jul 22 '18 06:07 Stoakes

@Stoakes The package symfony/security-acl is required if you want to use ACL. Symfony has removed ACL out of the core, so perhaps that's the reason why it cannot be found anymore. Thus the package needs to be installed separately.

XWB avatar Jul 22 '18 12:07 XWB

As for now, the best approach I've found was to actually downgrade FOSCommentBundle to 2.1.* with "friendsofsymfony/comment-bundle": "2.1.*" in composer.json

That is if you still want role based security AND don't want all the junk in database that enabling acl in security.yml adds in.

kyeno avatar Apr 17 '19 22:04 kyeno