Thanks to visit codestin.com
Credit goes to github.com

Skip to content

You have requested a non-existent service "knp_menu.menu_provider.chain" #17910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ibasaw opened this issue Feb 23, 2016 · 25 comments
Closed

You have requested a non-existent service "knp_menu.menu_provider.chain" #17910

ibasaw opened this issue Feb 23, 2016 · 25 comments

Comments

@ibasaw
Copy link

ibasaw commented Feb 23, 2016

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]
  You have requested a non-existent service "knp_menu.menu_provider.chain". Did you mean this:  "knp_menu.menu_provider"?

in my composer.json, got : "symfony/symfony": "2.8.*@dev"

got this error after a composer update

@xabbuh
Copy link
Member

xabbuh commented Feb 23, 2016

@ibasaw Can you check if this is the same as #17864 which was fixed by #17866?

@ibasaw
Copy link
Author

ibasaw commented Feb 23, 2016

@xabbuh : yes it works with #17866

@nicokaag
Copy link

I Still have this issue on branch 2.8. The commit I'm on is: 4cbb3fd
So I'm not sure if #17866 fixed it.

@ibasaw
Copy link
Author

ibasaw commented Feb 24, 2016

you're right @nicokaag , on a fresh composer install, got this error too.

ping @xabbuh

@xabbuh
Copy link
Member

xabbuh commented Feb 24, 2016

@nicokaag @ibasaw Would you be able to provide some steps to reproduce your issue? Did you clear the cache of your application?

@xabbuh xabbuh reopened this Feb 24, 2016
@nicokaag
Copy link

@xabbuh I don't have exact steps to reproduce right now. But the call to the service knp_menu.menu_provider.chain is done in the cache directory and then the *ProjectContainer.php file.

The code that is generated is something like:

protected function getNicoDossier_Entity_CategoryRepositoryService()
{
    return $this->services['nico_dossier.entity.category_repository'] = $this->get('knp_menu.menu_provider.chain')->getRepository('Nico\\DossierBundle\\Entity\\Category');
}

So for some reason the doctrine service got replaced with the knp_menu.menu_provider.chain service.

The KnpMenuBundle in my project is a dependency of the SonataAdminBundle, so that may be related to this issue (?)

@ibasaw
Copy link
Author

ibasaw commented Feb 24, 2016

@xabbuh

in the first place, i only do a composer update when it arrived.

got SonataAdminBundle too, i delete cache, composer cache, vendors, then i do a composer update and got this error.

@ibasaw
Copy link
Author

ibasaw commented Feb 24, 2016

@xabbuh

for me in the ProjectContainer.php, the code is:

      /**
     * Gets the 'ao_translation.entity_manager' service.
     *
     * This service is shared.
     * This method always returns the same instance of the service.
     *
     * @return \Doctrine\ORM\EntityManager A Doctrine\ORM\EntityManager instance.
     */
    protected function getAoTranslation_EntityManagerService()
    {
        return $this->services['ao_translation.entity_manager'] = $this->get('knp_menu.menu_provider.chain')->getManager('default');
    }

@xabbuh
Copy link
Member

xabbuh commented Feb 24, 2016

@ibasaw Do you have some example code and configuration I can add to a blank Symfony Standard Edition that will lead to this issue?

@ibasaw
Copy link
Author

ibasaw commented Feb 24, 2016

@xabbuh : this is because i used https://github.com/adrianolek/AOTranslationBundle.

i had deleted it, and no more error...

@Soviann
Copy link

Soviann commented Feb 25, 2016

No more error by deleting the line99 of ReplaceAliasByActualDefinitionPass.php

$definition->setFactoryService($this->updateFactoryServiceReference($definition->getFactoryService(), $currentId, $newId));

Not sure if this is the solution though.

@xabbuh
Copy link
Member

xabbuh commented Feb 25, 2016

@nvasse No, we need that line to fix #17864. Can you provide some information about how we can reproduce your issue?

@Soviann
Copy link

Soviann commented Feb 25, 2016

I think that simply having KnpMenuBundle and trying to cache:clear triggers the error.

@xabbuh
Copy link
Member

xabbuh commented Feb 25, 2016

By simply adding the KnpMenuBundle I cannot reproduce your issue. Can you please fork the Symfony Standard Edition and make the changes that are needed to reproduce it?

@fungio
Copy link

fungio commented Feb 26, 2016

I have the same error with Symfony 2.8 and KnpMenuBundle. I also have this error with a Symfony 2.3 project. But if I rollback few commits in both my 2.8 and 2.3 projects the problem is "solved" so I'm pretty sure it's not a bug from Knp.
Any clues ?

@xabbuh
Copy link
Member

xabbuh commented Feb 26, 2016

@fungio I do agree but as long as I cannot reproduce your issue I am unable to create a fix.

@kockodev
Copy link

I have the same issue. Problem solved by adding to /app/services.yml:

    knp_menu.menu_provider.chain:
        class: %knp_menu.menu_provider.chain.class%
        arguments: [ {} ]
        public: true

@javiereguiluz
Copy link
Member

Thank you all for investigating this issue. However, as @xabbuh said, we need to be able to reproduce this issue consistently in order to fix it.

So please, could someone fork the Symfony Standard edition and add the minimum number of third-party bundles, config and PHP code to reproduce the issue? Thank you!

@ibasaw
Copy link
Author

ibasaw commented Feb 26, 2016

@javiereguiluz : which version of symfony ? 2.8 ?

@javiereguiluz
Copy link
Member

If it's a real Symfony bug, the version should be "the oldest Symfony version which is still maintained and suffers the bug". So it can be 2.3, 2.7 or 2.8.

@Soviann
Copy link

Soviann commented Feb 26, 2016

I tried @rapemer solution and now I get the same error from another service bazinga_geocoder.geocoder.default_adapter which is also a service with public set to false, I guess that links this problem to #17915

@kockodev
Copy link

@nvasse yeah, it seems to be problem with services public = false

@kockodev
Copy link

Error occured when I used composer update at my dev-master (2.8.x-dev) to the latest commit. When I revert to 2.8.2, everything is okay.

@wouterj
Copy link
Member

wouterj commented Feb 26, 2016

Status: Reviewed

@wouterj
Copy link
Member

wouterj commented Feb 26, 2016

I'm sorry, that test case was proofing something completely irrelevant. In order to reproduce this issue:

  • On a fresh Symfony install (dev-2.8)

  • Add a service config like this:

    services:
     app.demo:
       class: Doctrine\ORM\EntityManager
       factory_service: doctrine
       factory_method: getManager
  • Now, somewhere in a controller use $this->get('app.demo').

fabpot added a commit that referenced this issue Feb 28, 2016
…terJ)

This PR was squashed before being merged into the 2.3 branch (closes #17942).

Discussion
----------

Fix bug when using an private aliased factory service

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #17910, #17915
| License       | MIT
| Doc PR        | -

/cc @xabbuh

Commits
-------

de406c0 Fix bug when using an private aliased factory service
@fabpot fabpot closed this as completed Feb 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants