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

TargetGroup has a database interaction within "bin/console pimcore:build:classes" #70

Open
MarkTro opened this issue Mar 26, 2024 · 3 comments · May be fixed by #80
Open

TargetGroup has a database interaction within "bin/console pimcore:build:classes" #70

MarkTro opened this issue Mar 26, 2024 · 3 comments · May be fixed by #80

Comments

@MarkTro
Copy link

MarkTro commented Mar 26, 2024

If you have "TargetGroup" in a class definition and run the command "bin/console pimcore:build:classes" without a database running, it ends up in an missing database connection error:

11:22:18 EMERGENCY [pimcore] PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo for database failed: Temporary failure in name resolution in /var/www/html/vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php:33
Stack trace:
#0 /var/www/html/vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php(33): PDO->__construct('mysql:host=data...', 'pimcore', Object(SensitiveParameterValue), Array)
#1 /var/www/html/vendor/doctrine/dbal/src/Driver/Middleware/AbstractDriverMiddleware.php(29): Doctrine\DBAL\Driver\PDO\MySQL\Driver->connect(Object(SensitiveParameterValue))
#2 /var/www/html/vendor/doctrine/dbal/src/Logging/Driver.php(34): Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware->connect(Object(SensitiveParameterValue))
#3 /var/www/html/vendor/doctrine/dbal/src/Driver/Middleware/AbstractDriverMiddleware.php(29): Doctrine\DBAL\Logging\Driver->connect(Object(SensitiveParameterValue))
#4 /var/www/html/vendor/symfony/doctrine-bridge/Middleware/Debug/Driver.php(37): Doctrine\DBAL\Driver\Middleware\AbstractDriverMiddleware->connect(Object(SensitiveParameterValue))
#5 /var/www/html/vendor/doctrine/dbal/src/Connection.php(378): Symfony\Bridge\Doctrine\Middleware\Debug\Driver->connect(Array)
#6 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1659): Doctrine\DBAL\Connection->connect()
#7 /var/www/html/vendor/doctrine/dbal/src/Connection.php(1082): Doctrine\DBAL\Connection->getWrappedConnection()
#8 /var/www/html/vendor/doctrine/dbal/src/Connection.php(953): Doctrine\DBAL\Connection->executeQuery('SELECT id FROM ...', Array, Array)
#9 /var/www/html/vendor/pimcore/personalization-bundle/src/Model/Tool/Targeting/TargetGroup/Listing/Dao.php(33): Doctrine\DBAL\Connection->fetchFirstColumn('SELECT id FROM ...', Array)
#10 [internal function]: Pimcore\Bundle\PersonalizationBundle\Model\Tool\Targeting\TargetGroup\Listing\Dao->load()
#11 /var/www/html/vendor/pimcore/pimcore/lib/Model/AbstractModel.php(220): call_user_func_array(Array, Array)
#12 /var/www/html/vendor/pimcore/personalization-bundle/src/Pimcore/Model/DataObject/ClassDefinition/Data/TargetGroup.php(80): Pimcore\Model\AbstractModel->__call('load', Array)
#13 /var/www/html/vendor/pimcore/personalization-bundle/src/Pimcore/Model/DataObject/ClassDefinition/Data/TargetGroup.php(116): Pimcore\Model\DataObject\ClassDefinition\Data\TargetGroup->configureOptions()
#14 /var/www/html/var/classes/definition_CustomerSegment.php(246): Pimcore\Model\DataObject\ClassDefinition\Data\TargetGroup::__set_state(Array)
#15 /var/www/html/vendor/pimcore/pimcore/bundles/CoreBundle/src/Command/ClassesDefinitionsBuildCommand.php(61): include('/var/www/html/v...')
#16 /var/www/html/vendor/symfony/console/Command/Command.php(326): Pimcore\Bundle\CoreBundle\Command\ClassesDefinitionsBuildCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/html/vendor/symfony/console/Application.php(1096): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(126): Symfony\Component\Console\Application->doRunCommand(Object(Pimcore\Bundle\CoreBundle\Command\ClassesDefinitionsBuildCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /var/www/html/vendor/symfony/console/Application.php(324): Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand(Object(Pimcore\Bundle\CoreBundle\Command\ClassesDefinitionsBuildCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /var/www/html/vendor/symfony/framework-bundle/Console/Application.php(80): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#21 /var/www/html/vendor/symfony/console/Application.php(175): Symfony\Bundle\FrameworkBundle\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#22 /var/www/html/bin/console(49): Symfony\Component\Console\Application->run()
#23 {main}

As far as I know the console command should build the classes without any database interaction. We use this in a deployment pipeline where no database is available.

The class definition has calls the function \Pimcore\Model\DataObject\ClassDefinition\Data\TargetGroup::__set_state. This one uses the function $obj->configureOptions(); in line 116. That one has a DAO listing call on line 80 which forces the error.

Is it really necessary to fetch the options for the class building?

Copy link

Thanks a lot for reporting the issue. We did not consider the issue as "Pimcore:Priority", "Pimcore:ToDo" or "Pimcore:Backlog", so we're not going to work on that anytime soon. Please create a pull request to fix the issue if this is a bug report. We'll then review it as quickly as possible. If you're interested in contributing a feature, please contact us first here before creating a pull request. We'll then decide whether we'd accept it or not. Thanks for your understanding.

@saitho
Copy link

saitho commented Oct 5, 2024

I'm currently also running into this issue. This affects my phpstan tests which obviously run without database and fail, because I can't generate the classes.

I now removed TargetGroups from my CustomerSegments, as I didn't use them anyways

@dpfaffenbauer
Copy link
Contributor

there is not really a focus on fixing this? its 7 months old... we also ran into this now

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

Successfully merging a pull request may close this issue.

3 participants