JMSDiExtraBundle icon indicating copy to clipboard operation
JMSDiExtraBundle copied to clipboard

Getting error after updating to #55c3f875f08a333848284cdbc1fd3e0cea4e6776

Open mzampetakis opened this issue 6 years ago • 22 comments

After updating to commit#55c3f875f08a333848284cdbc1fd3e0cea4e6776 I get this error while clearing my cache:

[RuntimeException]                                                                 
  An error occurred when executing the "'cache:clear --no-warmup'" command:          
  
[LogicException]                                                                 
    You must call one of in() or append() methods before iterating over a Finder.

Going back to #4adca6ba4feec25869c16a8af2ade9f20fc62f91 it worked fine.

mzampetakis avatar Sep 28 '17 08:09 mzampetakis

@gremo please help

greg0ire avatar Sep 28 '17 08:09 greg0ire

@mzampetakis can you please provide the output of the same command with the -vvv flag? Also, can you show the output of composer outdated --no-ansi?

greg0ire avatar Sep 28 '17 09:09 greg0ire

php app/console cache:clear --env=prod -vvv

 // Clearing the cache for the prod environment with debug false                                                        

 // Clearing outdated warmup directory...                                                                               

 // Warming up cache...                                                                                                 


                                                                                 
  [LogicException]                                                               
  You must call one of in() or append() methods before iterating over a Finder.  
                                                                                 

Exception trace:
 () at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Component/Finder/Finder.php:677
 Symfony\Component\Finder\Finder->getIterator() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/jms/di-extra-bundle/HttpKernel/ControllerInjectorsWarmer.php:86
 JMS\DiExtraBundle\HttpKernel\ControllerInjectorsWarmer->findControllerClasses() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/jms/di-extra-bundle/HttpKernel/ControllerInjectorsWarmer.php:60
 JMS\DiExtraBundle\HttpKernel\ControllerInjectorsWarmer->warmUp() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:48
 Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:526
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:133
 Symfony\Component\HttpKernel\Kernel->boot() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:134
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->warmup() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php:96
 Symfony\Bundle\FrameworkBundle\Command\CacheClearCommand->execute() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:266
 Symfony\Component\Console\Command\Command->run() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:893
 Symfony\Component\Console\Application->doRunCommand() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:204
 Symfony\Component\Console\Application->doRun() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:93
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:122
 Symfony\Component\Console\Application->run() at /Applications/MAMP/htdocs/newLoggia/loggiaConsole/app/console:29

cache:clear [--no-warmup] [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-s|--shell] [--process-isolation] [-e|--env ENV] [--no-debug] [--] <command>

mzampetakis avatar Sep 28 '17 09:09 mzampetakis

$ composer outdated --no-ansi
bcc/cron-manager-bundle              v2.6.1             v3.1               A cron table manager bundle for Symfony2
cocur/slugify                        v2.5               v3.0.1             Converts a string into a slug.
cspoo/swiftmailer-mailgun-bundle     0.2.1              0.4.0              Swiftmailer Mailgun bundle
firebase/php-jwt                     v3.0.0             v5.0.0             A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
friendsofsymfony/rest-bundle         1.7.7              2.2.0              This Bundle provides various tools to rapidly develop RESTful API's with Symfony
friendsofsymfony/user-bundle         v1.3.7             v2.0.1             Symfony FOSUserBundle
guzzle/guzzle                        v3.9.3             v3.9.3             PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle
Package guzzle/guzzle is abandoned, you should avoid using it. Use guzzlehttp/guzzle instead.
mailgun/mailgun-php                  v1.7.2             2.3.4              The Mailgun SDK provides methods for all API functions.
symfony/monolog-bundle               v2.12.1            v3.1.1             Symfony MonologBundle
symfony/phpunit-bridge               v2.8.27            v3.3.9             Symfony PHPUnit Bridge
symfony/swiftmailer-bundle           v2.6.3             v3.0.3             Symfony SwiftmailerBundle
symfony/symfony                      v2.8.27            v3.3.9             The Symfony PHP framework
willdurand/negotiation               1.5.0              v2.3.1             Content Negotiation tools for PHP provided as a standalone library.

mzampetakis avatar Sep 28 '17 09:09 mzampetakis

@greg0ire are you sure it depends on my commit?

gremo avatar Sep 28 '17 09:09 gremo

No I have no clue. @mzampetakis please use git bisect to determine which commit causes this issue. Also, I see you use sf 2.8, maybe there was a bc-break in the finder API ?

greg0ire avatar Sep 28 '17 09:09 greg0ire

I have never used git bisect. Can you guide me please?

mzampetakis avatar Sep 28 '17 10:09 mzampetakis

If you have access to the sf slack please have a look at this conversation I had about bisecting: https://symfony-devs.slack.com/archives/C3GC7MKM5/p1506013758000022 (I should really write a blog post or something someday).

greg0ire avatar Sep 28 '17 10:09 greg0ire

And if you don't, https://symfony.com/slack-invite should get you in

greg0ire avatar Sep 28 '17 10:09 greg0ire

I will try to bisect it later. However, going back to #4adca6ba4feec25869c16a8af2ade9f20fc62f91 worked fine. I indeed use sf 2.8.

mzampetakis avatar Sep 28 '17 10:09 mzampetakis

Links for the lazy: 55c3f875f08a333848284cdbc1fd3e0cea4e6776 482fdb85a1fb81bfad2e20ec6bf24b5cc8354691 (please don't put a # next time)

greg0ire avatar Sep 28 '17 10:09 greg0ire

Oh wow that's very weird. One of them is @gremo's commit, the other is the merge commit. Guess that means you are not at fault @gremo , and your PR was based on a still sane version of the branch. Good job!

greg0ire avatar Sep 28 '17 10:09 greg0ire

That means you should probably bisect between 4adca6ba4feec25869c16a8af2ade9f20fc62f91 and 55c3f87

greg0ire avatar Sep 28 '17 10:09 greg0ire

My mistake 4adca6b is the working one. I didn't try 482fdb8. Editing previous comments.

mzampetakis avatar Sep 28 '17 10:09 mzampetakis

482fdb8 Seems to be the problematic one.

<?php
namespace JMS\DiExtraBundle\HttpKernel;
...
class ControllerInjectorsWarmer implements CacheWarmerInterface
{
    ...
    private function findControllerClasses()
    {
        ...
        if (!$this->scanAllBundles && !in_array($bundle->getName(), $this->scanBundles, true)) {
            continue;
        }
        ...
    }

If I comment the continue, the error doesn't show up. I don't have the time to make any test right now, I just wanted to confirm the issue.

adaniloff avatar Sep 28 '17 12:09 adaniloff

@adaniloff maybe because of this https://github.com/symfony/finder/blob/master/Finder.php#L566

@mzampetakis do you have all_bundles: false and bundles: [] in your configuration? In that case there are no directories to scan and Finder component will throw the exception.

Before my commit, all bundles where scanned. That is, the Finder component received at least one directory to scan. Now, this isn't true all the time.

Honestly, I was not aware of exception thrown in case of empty directories to scan.

gremo avatar Sep 28 '17 13:09 gremo

@gremo, I don't know what these configurations are (all_bundles: false and bundles: []). Where can I find them?

mzampetakis avatar Sep 28 '17 13:09 mzampetakis

@mzampetakis can you past your JMSDiExtraBundle configuration?

gremo avatar Sep 28 '17 14:09 gremo

@gremo my config

jms_di_extra:
    automatic_controller_injections:
        properties:
            request: "@request"
            router: "@router"

        method_calls:
            setRouter: ["@router"]

mzampetakis avatar Sep 28 '17 14:09 mzampetakis

@mzampetakis thank you, I'll look and do some tests ASAP.

gremo avatar Sep 28 '17 14:09 gremo

@gremo

Can't tell. I cannot check it up rightnow. But I don't think that I have done the things you mentionned in your comment.

I'll tell as soon as I can.

Thanks for the help anyway.

adaniloff avatar Sep 28 '17 15:09 adaniloff

I made a PR that should fix the error (https://github.com/schmittjoh/JMSDiExtraBundle/pull/288). @greg0ire as new "maintainer" can you please review and check if it's right?

gremo avatar Sep 28 '17 16:09 gremo