Skip to content
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

Getting errors because of API code bundle needs #686

Closed
AntonioCS opened this issue Jan 31, 2016 · 16 comments
Closed

Getting errors because of API code bundle needs #686

AntonioCS opened this issue Jan 31, 2016 · 16 comments

Comments

@AntonioCS
Copy link

Hey,

I have "sonata-project/user-bundle": "^2.2" in my composer.json.
I do not plan to use any type of API component. When I do composer update I get this:

[Doctrine\Common\Annotations\AnnotationException]
  [Semantical Error] The annotation "@Nelmio\ApiDocBundle\Annotation\ApiDoc" in method Sonata\UserBundle\Controller\Api\GroupController::getGroupsAction() does not exist, or could not be auto-loaded.


Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception



  [RuntimeException]
  An error occurred when executing the "'cache:clear --no-warmup'" command:

    [Doctrine\Common\Annotations\AnnotationException]
    [Semantical Error] The annotation "@Nelmio\ApiDocBundle\Annotation\ApiDoc" in method Sonata\UserBundle\Controller\Api\GroupController::getGroupsAction() does not exist, or could not be auto-loaded.

  .

Do I need to install & configure FOSRestBundle and NelmioApiDocBundle? Is this something that you are forcing users to do???

@core23
Copy link
Member

core23 commented Jan 31, 2016

Hi,

for the 2.2 version of the this bundle, the dependency is requires. In the current master, the ApiBundle is removed (#650).

@AntonioCS
Copy link
Author

Thanks. I will change to dev-master in the composer.json.

@core23
Copy link
Member

core23 commented Jan 31, 2016

Be aware of using the master version, because you are using a bleeding edge version. This should not be used for a production environment.

@AntonioCS
Copy link
Author

Right. Any version that I can use that does not have this bundle issue?

@core23
Copy link
Member

core23 commented Jan 31, 2016

I see there was a new release. You could use version 2.2.4.

@AntonioCS
Copy link
Author

AntonioCS commented Jan 31, 2016

Changed to 2.2.4, did composer update and got this:

PHP Fatal error: Declaration of Sonata\UserBundle\Block\AccountBlockService::validateBlock() must be compatible with Sonata\BlockBundle\Block\BlockAdminServiceInterface::validateBlock(Sonata\CoreBundle\Validator\ErrorElement $errorElement, Sonata\BlockBundle\Model\BlockInterface $block) in /var/www/mylocalpitch/rc_mlp_20140609/vendor/sonata-project/user-bundle/Block/AccountBlockService.php on line 110

@core23
Copy link
Member

core23 commented Feb 19, 2016

Can you show your composer config? @AntonioCS

@kaiwa
Copy link
Contributor

kaiwa commented Apr 6, 2016

I am experiencing the same problem, but I don't think it's SonataUserBundle's fault in my case. I am using the master branch, the api controllers do not get loaded by SonataUserBundle, which is correct, but for some reason JMSDiExtraBundle loads the controllers anyway (or at least they are not loaded if I disable JMSDiExtraBundle) and therefore it comes to the same exception as OP's initial one.

Something is fucked up since i explicitly configured

jms_di_extra:
    locations:
        all_bundles: false

I guess this is the point when magic starts kicking your butt :-/

@SonataCI SonataCI removed the questions label May 2, 2016
@gremo
Copy link
Contributor

gremo commented Jan 25, 2017

I have the same problem: using JMSDiExtraBundle without NelmioApiDocBundle.

Maybe the problem relies in the cache warmer scanning all bundles folders and looking for controllers (note that all_bundles: false is ignored).

It works if you disable the warmer:

jms_di_extra:
    cache_warmer:
        enabled: false

There is a blacklist option but it relies on the controller realpath.

What about prepending the blacklist option if JMSDiExtraBundle is found but NelmioApiDocBundle not?

Edit: I made a quick test with the following prepended configuration and it seems to work just fine (other sonata bundles have the same issue, like SonataClassificationBundle). I can work on a PR.

public function prepend(ContainerBuilder $container)
{
    $bundles = $container->getParameter('kernel.bundles');
    if (isset($bundles['JMSDiExtraBundle']) &&
        (!isset($bundles['NelmioApiDocBundle']) || !isset($bundles['FOSRestBundle']))) {
        $blacklistedControllers = [];
        foreach (glob(__DIR__.'/../Controller/Api/*.php', GLOB_NOSORT) as $filename) {
            $blacklistedControllers[] = realpath($filename);
        }

        if (!empty($blacklistedControllers)) {
            $container->prependExtensionConfig('jms_di_extra', [
                'cache_warmer' => [
                    'controller_file_blacklist' => $blacklistedControllers,
                ],
            ]);
        }
    }
}

@greg0ire
Copy link
Contributor

I can work on a PR.

Amazing work. Please do!

@kaiwa
Copy link
Contributor

kaiwa commented Jan 26, 2017

@gremo Nice workaround. But I guess it would be preferrable if this would be fixed in JmsDiExtraBundle itself, so that all_bundles: false is working correctly. Maybe better put your effort into an PR over at https://github.com/schmittjoh/JMSDiExtraBundle ? Anyway, looking forward to a solution :)

@gremo
Copy link
Contributor

gremo commented Jan 26, 2017

@kaiwa I agree, but a PR (shouldn't hard to write) on JMSDiExtraBundle could take months to be accepted. In addition we have BC to older version of JMSDiExtraBundle.

@greg0ire
Copy link
Contributor

Did someone report the bug to JMSDiExtraBundle ?

In addition we have BC to older version of JMSDiExtraBundle.

I think we can drop older versions if it's not a major version we're dropping.

@kaiwa
Copy link
Contributor

kaiwa commented Jan 26, 2017

@greg0ire

Did someone report the bug to JMSDiExtraBundle ?

Yes I did, here you go:

schmittjoh/JMSDiExtraBundle#248

@gremo
Copy link
Contributor

gremo commented Jan 26, 2017

I just opened a new one schmittjoh/JMSDiExtraBundle#269 and I'm sending a PR.

@jordisala1991
Copy link
Member

This seems to be solved, or atleast belongs to JMSDiExtraBundle. If I am wrong ping me and I will reopen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants