KnpLabs / DoctrineBehaviors

Doctrine2 behavior traits that help handling Blameable, Loggable, Sluggable, SoftDeletable, Uuidable, Timestampable, Translatable, Tree behavior
http://knplabs.com
MIT License
911 stars 287 forks source link

New version using symplify/package-builder ^8.0 #575

Closed I-Valchev closed 4 years ago

I-Valchev commented 4 years ago

I'm having trouble updating bolt/core to use ecs ^8, because of incompatible versions with doctrine behaviors. But I see you've already updated to symplify/package-builder ^8.0 on master.

Can you tag a new release so that this issue is resolved for people? :) Thanks

TomasVotruba commented 4 years ago

I'm not sure it's tested yet :/

Could you confirm how the DoctrineBehaviors dev-master version works?

I-Valchev commented 4 years ago

I'll check!

I-Valchev commented 4 years ago
!!
!!  In DefinitionErrorExceptionPass.php line 54:
!!
!!    Cannot autowire service "Knp\DoctrineBehaviors\EventSubscriber\HashidableEv
!!    entSubscriber": argument "$hashids" of method "__construct()" references cl
!!    ass "Roukmoute\HashidsBundle\Hashids" but no such service exists. Try chang
!!    ing the type-hint to "Hashids\HashidsInterface" instead.
!!
!!
!!

Does this make any sense to you? :-)

TomasVotruba commented 4 years ago

That was fixed here: https://github.com/KnpLabs/DoctrineBehaviors/pull/572

I just mergedit. Could you retry in 2-3 mins, when packagist gets the memo?

I-Valchev commented 4 years ago

Doesn't quite work, it seems...

Cannot autowire argument $content of "Bolt\Controller\Backend\ContentEditController::edit()": it references class "Bolt\Entity\Content" but no such service exists.

Content is an entity, explicitly excluded as a service, which was fine so far. Could this be related?

TomasVotruba commented 4 years ago

Not sure. I have no idea how this could be related, as Symfony configs can be autowired only in it's own scope. I'd try removing cache and check the configs with bolt controller registration.

I-Valchev commented 4 years ago

OK that's very strange. I get no such issues, only when I set simplify to ^8 and doctrine-behaviors to dev-master. 🤔

TomasVotruba commented 4 years ago

How did you fix previous error?

I-Valchev commented 4 years ago

DefinitionErrorExceptionPass.php issue I waited and got the changes from the PR you merged in. Autowire thing goes away if I revert back to simplify 7 and latest stable doctrine-behaviors.

TomasVotruba commented 4 years ago

Autowire thing goes away if I revert back to simplify 7 and latest stable doctrine-behaviors.

That's not good :/ Last idea is to check bundles.php, sometimes symfony/flex adds undesired bundles.

If that doesn't help, we'd need reproducible code in a repository on Github. This needs to be fixed before release

I-Valchev commented 4 years ago

I don't see anything wrong with the bundles.php :/

https://github.com/bolt/core/pull/1513 here is an example of it happening.

To reproduce: grab that branch and install, then run make db-reset and login on the backend (default user/password is admin admin%1) and go to edit any page.

TomasVotruba commented 4 years ago

That's seems to hard, I can't invest that much time. Any unit test? Failing Github Action error would be the best

I-Valchev commented 4 years ago

I don't think the failing tests will be of much help... tests are checking what's on the page, but obviously that doesn't work as the issue is at controller level.

Maybe this will help: content-autowire-error

tsdevelopment commented 4 years ago

Hi, sorry to interrupt you. But I think the error doesn't have to do anything with this package. I installed your branch and found the following in your app/config/services.yaml file:

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    Bolt\:
        resource: '../src/*'
        exclude: '../src/{Entity,Exception,Migrations,Kernel.php}'

You exclude the Entity directory. But in your edit function you want to autoload the Content Service:

/**
     * @Route("/edit/{id}", name="bolt_content_edit", methods={"GET"}, requirements={"id": "\d+"})
     */
    public function edit(Request $request, Content $content): Response
    {
        [...]
    }

Remove Entity from service.yaml and the service will be available:

    # makes classes in src/ available to be used as services
    # this creates a service per class whose id is the fully-qualified class name
    Bolt\:
        resource: '../src/*'
        exclude: '../src/{Exception,Migrations,Kernel.php}'

After that I run into another error. But it's not related to this package! This package works in my opinion. I installed the latest master branch in a new Symfony project and used hashidable and timestampable with success! So I think a new version could be published.

I-Valchev commented 4 years ago

Hi! @tsdevelopment thanks for trying this out. but that's not the issue - if you look at the master branch, it has the same services.yaml (Entity excluded) and it works without issues :-)

I'm not really sure what the issue is exactly, but it looks like something's going wrong with updating to ecs8 and doctrine-behaviors/package-builder, if it only happens in that case.

TomasVotruba commented 4 years ago

Not related to you issue, but actually the https://github.com/KnpLabs/DoctrineBehaviors/pull/572/files only fixed in tests. I'm trying the bundle now on one project and hashids implementation depends on bundle and can broke.

I'm fixing this behavior in https://github.com/KnpLabs/DoctrineBehaviors/pull/577 and tagging a new patch release. It might not influence your issue, but we need a fix of current master :)

I-Valchev commented 4 years ago

Right! So the issue is with Roukmoute\HashidsBundle\RoukmouteHashidsBundle::class => ['all' => true],. It has to be manually removed from bundles.php.

TomasVotruba commented 4 years ago

So basically the hashids don't work?

I-Valchev commented 4 years ago

I don't know, they're not used in Bolt. But looks like that bundle isn't used anymore after #572 ?

TomasVotruba commented 4 years ago

The #572 didn't really fix it, just tested non-real life usage.

The bundle was correctly added here https://github.com/KnpLabs/DoctrineBehaviors/pull/577