doctrine / DoctrineBundle

Symfony Bundle for Doctrine ORM and DBAL
https://www.doctrine-project.org/projects/doctrine-bundle.html
MIT License
4.72k stars 454 forks source link

Catchable Fatal Error: Argument 1 passed to Doctrine\Bundle\DoctrineBundle\Command\ImportMappingDoctrineCommand::__construct() must be an instance of Doctrine\Common\Persistence\ManagerRegistry, none given #886

Closed simpsonw closed 5 years ago

simpsonw commented 5 years ago

I recently upgraded from Symfony 2.8.48 to Symfony 2.9.49 and from DoctrineBundle 1.9.1 to DoctrineBundle 1.10.0. When I try to warm the cache, I get an error:

$ app/console cache:warmup --env=prod --no-debug
[Symfony\Component\Debug\Exception\ContextErrorException]                                                                                                               
  Catchable Fatal Error: Argument 1 passed to Doctrine\Bundle\DoctrineBundle\Command\ImportMappingDoctrineCommand::__construct() must be an instance of Doctrine\Common\  
  Persistence\ManagerRegistry, none given, called in /var/www/html/site/app/cache/prod/appProdProjectContainer.php on line 686 and defined 

Here's the output of composer show for my application:

behat/behat                            v3.0.15 Scenario-oriented BDD framework for PHP 5.3
behat/gherkin                          v4.5.1  Gherkin DSL parser for PHP 5.3
behat/mink                             v1.7.1  Browser controller/emulator abstraction for PHP
behat/mink-browserkit-driver           1.3.3   Symfony2 BrowserKit driver for Mink framework
behat/mink-extension                   2.3.1   Mink extension for Behat
behat/mink-goutte-driver               v1.2.1  Goutte driver for Mink framework
behat/mink-selenium2-driver            v1.3.1  Selenium2 (WebDriver) driver for Mink framework
behat/symfony2-extension               2.1.2   Symfony2 framework extension for Behat
behat/transliterator                   v1.2.0  String transliterator
behatch/contexts                       3.2.0   Behatch contexts
bossa/phpspec2-expect                  1.0.3   Helper that decorates any SUS with a phpspec lazy object wrapper
composer/ca-bundle                     1.1.3   Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.
doctrine/annotations                   v1.2.7  Docblock Annotations Parser
doctrine/cache                         v1.6.2  Caching library offering an object-oriented API for many cache backends
doctrine/collections                   v1.3.0  Collections Abstraction library
doctrine/common                        v2.6.2  Common Library for Doctrine projects
doctrine/data-fixtures                 v1.1.1  Data Fixtures for all Doctrine Object Managers
doctrine/dbal                          v2.5.13 Database Abstraction Layer
doctrine/doctrine-bundle               1.10.0  Symfony DoctrineBundle
doctrine/doctrine-cache-bundle         1.3.5   Symfony Bundle for Doctrine Cache
doctrine/doctrine-fixtures-bundle      v2.2.0  Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle    1.0.0   Symfony DoctrineMigrationsBundle
doctrine/inflector                     v1.1.0  Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                  1.0.5   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                         v1.0.1  Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                    v1.5.0  Database Schema migrations using Doctrine DBAL
doctrine/orm                           v2.5.14 Object-Relational-Mapper for PHP
dopiaza/slack-exception-logger-bundle  1.0.2   Log symfony2 exceptions to a Slack channel
eightpoints/guzzle-bundle              v4.0.1  Integrates Guzzle into Symfony2, comes with WSSE Plugin for RESTful Interfaces
eightpoints/guzzle-wsse-middleware     v3.1.0  WSSE Middleware for Guzzle, a PHP HTTP client library and framework for building RESTful web service clients
evenement/evenement                    v2.1.0  Événement is a very simple event dispatching library for PHP
fabpot/goutte                          v3.2.3  A simple PHP Web Scraper
gedmo/doctrine-extensions              v2.4.36 Doctrine2 behavioral extensions
guzzle/guzzle                          v3.9.3  PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle
guzzlehttp/guzzle                      6.3.3   Guzzle is a PHP HTTP client library
guzzlehttp/promises                    v1.3.1  Guzzle promises library
guzzlehttp/psr7                        1.5.2   PSR-7 message implementation that also provides common utility methods
instaclick/php-webdriver               1.4.5   PHP WebDriver for Selenium 2
ircmaxell/password-compat              v1.0.4  A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash
jdorn/sql-formatter                    v1.2.17 a PHP SQL highlighting library
jmose/command-scheduler-bundle         v1.2.7  This Symfony bundle will allow you to schedule all your commands just like UNIX crontab
jms/aop-bundle                         1.3.0   Adds AOP capabilities to Symfony2
jms/cg                                 1.2.0   Toolset for generating PHP code
jms/di-extra-bundle                    1.6.0   Allows to configure dependency injection using annotations
jms/metadata                           1.1.1   Class/method/property metadata management in PHP
jms/parser-lib                         1.0.0   A library for easily creating recursive-descent parsers.
jms/security-extra-bundle              1.5.2   Enhances the Symfony2 Security Component by adding several new features
jms/serializer-bundle                  0.9.0   Allows you to easily serialize, and deserialize object graphs of any complexity
justinrainbow/json-schema              5.2.7   A library to validate a json schema.
kriswallsmith/assetic                  v1.4.0  Asset Management for PHP
monolog/monolog                        1.24.0  Sends your logs to files, sockets, inboxes, databases and various web services
mtdowling/cron-expression              v1.2.1  CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
ocramius/proxy-manager                 1.0.2   A library providing utilities to generate, instantiate and generally operate with Object Proxies
paragonie/random_compat                v2.0.17 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phpdocumentor/reflection-common        1.0.1   Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock      3.2.2   With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that...
phpdocumentor/type-resolver            0.3.0   
phpoption/phpoption                    1.5.0   Option Type for PHP
phpspec/php-diff                       v1.0.2  A comprehensive library for generating differences between two hashable objects (strings or arrays).
phpspec/phpspec                        2.5.8   Specification-oriented BDD framework for PHP 5.3+
phpspec/prophecy                       1.8.0   Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage              2.2.4   Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator              1.4.5   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template              1.2.1   Simple template engine.
phpunit/php-timer                      1.0.9   Utility class for timing
phpunit/php-token-stream               1.4.12  Wrapper around PHP's tokenizer extension.
phpunit/phpunit                        4.8.36  The PHP Unit Testing framework.
phpunit/phpunit-mock-objects           2.3.8   Mock Object library for PHPUnit
psr/http-message                       1.0.1   Common interface for HTTP messages
psr/log                                1.1.0   Common interface for logging libraries
ralouphie/getallheaders                2.0.5   A polyfill for getallheaders.
react/event-loop                       v0.4.3  Event loop abstraction layer that libraries can use for evented I/O.
react/promise                          v2.7.0  A lightweight implementation of CommonJS Promises/A for PHP
react/socket                           v0.4.6  Async, streaming plaintext TCP/IP and secure TLS socket server for React PHP
react/stream                           v0.4.6  Basic readable and writable stream interfaces that support piping.
rickysu/php-livereload                 v0.1.2  a livereload server implement by php
sebastian/comparator                   1.2.4   Provides the functionality to compare PHP values for equality
sebastian/diff                         1.4.3   Diff implementation
sebastian/environment                  1.3.8   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                     1.2.2   Provides the functionality to export PHP variables for visualization
sebastian/global-state                 1.1.1   Snapshotting of global state
sebastian/recursion-context            1.0.5   Provides functionality to recursively process PHP variables
sebastian/version                      1.0.6   Library that helps with managing the version number of Git-hosted PHP projects
sensio/distribution-bundle             v4.0.41 Base bundle for Symfony Distributions
sensio/framework-extra-bundle          v3.0.29 This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle                v3.0.11 This bundle generates code for you
sensiolabs/behat-page-object-extension v2.0.1  Page object extension for Behat
sensiolabs/security-checker            v5.0.1  A security checker for your composer.lock
stof/doctrine-extensions-bundle        v1.2.2  Integration of the gedmo/doctrine-extensions with Symfony2
swiftmailer/swiftmailer                v5.4.12 Swiftmailer, free feature-rich PHP mailer
symfony/assetic-bundle                 v2.7.1  Integrates Assetic into Symfony2
symfony/monolog-bundle                 v2.8.2  Symfony MonologBundle
symfony/polyfill-apcu                  v1.10.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-ctype                 v1.10.0 Symfony polyfill for ctype functions
symfony/polyfill-intl-icu              v1.10.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring              v1.10.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php54                 v1.10.0 Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55                 v1.10.0 Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56                 v1.10.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                 v1.10.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util                  v1.10.0 Symfony utilities for portability of PHP codes
symfony/security-acl                   v3.0.1  Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle             v2.3.12 Symfony SwiftmailerBundle
symfony/symfony                        v2.8.49 The Symfony PHP framework
twig/extensions                        v1.5.4  Common additional features for Twig that do not directly belong in core
twig/twig                              v1.35.4 Twig, the flexible, fast, and secure template language for PHP
webmozart/assert                       1.3.0   Assertions to validate method input/output with nice error messages.
zendframework/zend-code                2.6.3   provides facilities to generate arbitrary code using an object oriented interface
zendframework/zend-eventmanager        3.0.1   Trigger and listen to events within a PHP application

Reverting to DoctrineBundle 1.9.1 fixes the issue. It looks like a __construct function has been added to Command/ImportMappingDoctrineCommand.php with required args:

+    /** @var string[] */
+    private $bundles;
+
+    /**
+     * @param string[] $bundles
+     */
+    public function __construct(ManagerRegistry $doctrine, array $bundles)
+    {
+        parent::__construct($doctrine);
+
+        $this->bundles = $bundles;
+    }
+
kimhemsoe commented 5 years ago

Can you try to upgrade again, but this time before you do warmup, do a manual delete of your sf cache folder?

simpsonw commented 5 years ago

@kimhemsoe That fixed it, thanks!