Closed arboc closed 3 years ago
This is not a hard dependency. Does it throw exceptions in your case if you don't have filter bundle installed?
We try to keep the hard (and needed) dependencies as less as possible.
During installation (composer install / update) you get an error, that the class FilterConfig
is not found.
Than the Installation is cancelled.
@koertho Could you please dig into this? We need to keep it that way that it's not a hard dep.
@arboc Could you please provide the complete error stack? Thanks!
// Warming up the cache for the prod environment with debug
// false
16:59:03 ERROR [console] Error thrown while running command "--ansi cache:warmup --env=prod". Message: "Class 'HeimrichHannot\FilterBundle\Filter\Type\ChoiceType' not found" ["exception" => Error { …},"command" => "--ansi cache:warmup --env=prod","message" => "Class 'HeimrichHannot\FilterBundle\Filter\Type\ChoiceType' not found"]
In CategoryChoiceType.php line 16:
Attempted to load class "ChoiceType" from namespace "HeimrichHannot\FilterB
undle\Filter\Type".
Did you forget a "use" statement for another namespace?
cache:warmup [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--] <command>
Script Contao\ManagerBundle\Composer\ScriptHandler::initializeApplication handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred while executing the "cache:warmup" command: 16:59:03 ERROR [console] Error thrown while running c
ommand "--ansi cache:warmup --env=prod". Message: "Class 'HeimrichHannot\FilterBundle\Filter\Type\ChoiceType' not found" [
[0;38;5;208m"exception" => Error { …},"command" => "
--ansi cache:warmup --env=prod","message" => "Class 'Heimric
hHannot\FilterBundle\Filter\Type\ChoiceType' not found"]
In CategoryChoiceType.php line 16:
Attempted to load class "ChoiceType" from namespace "HeimrichHannot\FilterB
undle\Filter\Type".
Did you forget a "use" statement for another namespace?
cache:warmup [--no-optional-warmers] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-inter
action] [-e|--env ENV] [--] <command>
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-scripts] [--no-progress] [--no-install] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--] [<packages>]...
I could not reproduce this error. Clean contao 4.9 install. Tried with composer and contao manager, dev and prod environments. No errors. Maybe you have another bundle install that do some strange class checking on warmup?
after hours I found, how to reproduce:
We use a .env and .env.local where our database connection is defined.
With these files, we get the error. Without these files every thing works fine.
in addition: it doesn't matter, where you define your database connection. (parameters.yml, .env) In the moment it is defined, the error will occur.
Very strange, database has nothing to do with class loading. Can you run the cache warmup command with verbose flag? cache:warmup -v
// Warming up the cache for the prod environment with debug false
12:48:25 ERROR [console] Error thrown while running command "cache:warmup -v". Message: "Class 'HeimrichHannot\FilterBundle\Filter\Type\ChoiceType' not found" ["exception" => Error { …},"command" => "cache:warmup -v","message" => "Class 'HeimrichHannot\FilterBundle\Filter\Type\ChoiceType' not found"]
In CategoryChoiceType.php line 16:
[Symfony\Component\ErrorHandler\Error\ClassNotFoundError]
Attempted to load class "ChoiceType" from namespace "HeimrichHannot\FilterBundle\Filter\Type".
Did you forget a "use" statement for another namespace?
Exception trace:
at /srv/htdocs/arne/contao4/test/vendor/heimrichhannot/contao-categories-bundle/src/Filter/Type/CategoryChoiceType.php:16
include() at /srv/htdocs/arne/contao4/test/vendor/composer/ClassLoader.php:444
Composer\Autoload\includeFile() at /srv/htdocs/arne/contao4/test/vendor/composer/ClassLoader.php:322
Composer\Autoload\ClassLoader->loadClass() at n/a:n/a
spl_autoload_call() at /srv/htdocs/arne/contao4/test/vendor/heimrichhannot/contao-categories-bundle/src/Resources/contao/languages/en/tl_filter_config_element.php:13
include() at /srv/htdocs/arne/contao4/test/vendor/contao/core-bundle/src/Resources/contao/library/Contao/System.php:501
Contao\System::loadLanguageFile() at /srv/htdocs/arne/contao4/test/vendor/netzmacht/contao-toolkit/src/Dca/Manager.php:90
Netzmacht\Contao\Toolkit\Dca\Manager->getDefinition() at /srv/htdocs/arne/contao4/test/vendor/contao-bootstrap/grid/src/Listener/Hook/RegisterFixContentParentRelationsFixerListener.php:67
ContaoBootstrap\Grid\Listener\Hook\RegisterFixContentParentRelationsFixerListener->onLoadDataContainer() at /srv/htdocs/arne/contao4/test/vendor/contao/core-bundle/src/Resources/contao/library/Contao/DcaLoader.php:118
Contao\DcaLoader->loadDcaFiles() at /srv/htdocs/arne/contao4/test/vendor/contao/core-bundle/src/Resources/contao/library/Contao/DcaLoader.php:70
Contao\DcaLoader->load() at /srv/htdocs/arne/contao4/test/vendor/contao/core-bundle/src/Resources/contao/library/Contao/Controller.php:1360
Contao\Controller::loadDataContainer() at /srv/htdocs/arne/contao4/test/vendor/contao/core-bundle/src/Framework/Adapter.php:44
Contao\CoreBundle\Framework\Adapter->__call() at /srv/htdocs/arne/contao4/test/vendor/heimrichhannot/contao-utils-bundle/src/Dca/DcaUtil.php:977
HeimrichHannot\UtilsBundle\Dca\DcaUtil->loadDc() at /srv/htdocs/arne/contao4/test/vendor/heimrichhannot/contao-utils-bundle/src/Cache/DatabaseTreeCache.php:255
HeimrichHannot\UtilsBundle\Cache\DatabaseTreeCache->generateAllCacheTree() at /srv/htdocs/arne/contao4/test/vendor/heimrichhannot/contao-utils-bundle/src/Cache/UtilCacheWarmer.php:132
HeimrichHannot\UtilsBundle\Cache\UtilCacheWarmer->generateDatabaseTreeCache() at /srv/htdocs/arne/contao4/test/vendor/heimrichhannot/contao-utils-bundle/src/Cache/UtilCacheWarmer.php:84
HeimrichHannot\UtilsBundle\Cache\UtilCacheWarmer->warmUp() at /srv/htdocs/arne/contao4/test/vendor/symfony/http-kernel/CacheWarmer/CacheWarmerAggregate.php:97
Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp() at /srv/htdocs/arne/contao4/test/vendor/symfony/framework-bundle/Command/CacheWarmupCommand.php:80
Symfony\Bundle\FrameworkBundle\Command\CacheWarmupCommand->execute() at /srv/htdocs/arne/contao4/test/vendor/symfony/console/Command/Command.php:255
Symfony\Component\Console\Command\Command->run() at /srv/htdocs/arne/contao4/test/vendor/symfony/console/Application.php:1027
Symfony\Component\Console\Application->doRunCommand() at /srv/htdocs/arne/contao4/test/vendor/symfony/framework-bundle/Console/Application.php:97
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /srv/htdocs/arne/contao4/test/vendor/symfony/console/Application.php:273
Symfony\Component\Console\Application->doRun() at /srv/htdocs/arne/contao4/test/vendor/symfony/framework-bundle/Console/Application.php:83
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /srv/htdocs/arne/contao4/test/vendor/symfony/console/Application.php:149
Symfony\Component\Console\Application->run() at /srv/htdocs/arne/contao4/test/vendor/contao/manager-bundle/bin/contao-console:38
@arboc Thanks, that's helpful.
@Defcon0 Looks like this is the DatabaseTreeUtil in the cache warmer again. I think we should remove this from the utils bundle, as it just build a cache, that contao build by itself and is often the reason for error.
@arboc Can you try without cache warmup (cache:clear --no-warmup
)?
@arboc Thanks, that's helpful.
@Defcon0 Looks like this is the DatabaseTreeUtil in the cache warmer again. I think we should remove this from the utils bundle, as it just build a cache, that contao build by itself and is often the reason for error.
Is it used anywhere we know of? Maybe we should provide a config switch to turn it on again. Would that be possible?
the cache:clear --no-warmup
works.
@arboc Did had the filter bundle installed before? Does the table tl_filter_configelement exist in your db? Cause the DatabaseTreeUtil loads all tl* tables from the database!
the cache:clear --no-warmup works.
Another sign that it's the DatabaseTreeUtil
@Defcon0 We just need to disable it in the cache warmer, not kill the util itself. But yes, we could provide a config.
@koertho yes, I had the filter bundle installed before. And the tables tl_filter* exist. They coudn't deleted because of that error.
After I deleted them manually from the database, I was able to uninstall the filter bundle without issues.
That was the problem in combination with the databasetree util cache warmer. We will deactivate it by default in the next utils bundle update as it has no impact on existing projects and lead to errors like this. Thanks for reporting and providing all necessary informations!
@arboc The problem was fixed in utils bundle. Thanks for reporting!
Context
Contao version: 4.9
Bundle version: 1.1
PHP version: 7.3
Description
Missing dependency / requirements
in class
CategoryChoiceType
you are using some methods from heimrichhannot/contao-filter-bundlethese requirements are not mentioned in the composer.json.