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

core_boot hook is not called when using CLI commands #2846

Open
litzinger opened this issue Feb 13, 2023 · 4 comments · Fixed by #3409
Open

core_boot hook is not called when using CLI commands #2846

litzinger opened this issue Feb 13, 2023 · 4 comments · Fixed by #3409
Assignees

Comments

@litzinger
Copy link
Contributor

litzinger commented Feb 13, 2023

Description of the problem

The core_boot hook does not appear to be getting called when using the CLI commands. This was an issue a few versions ago and I thought it was resolved, but it appears to be happening again.

How To Reproduce

Put a core_boot extension hook into any add-on. Then run a command from the CLI. Note that the core_boot hook is not called. In this case Publisher is creating several class instances that are later used during the import process, but since the hook is not called, the classes do not exist and the import is failing.

Environment Details:

  • Version: 7.2.9

Additional context

14:12:50 02/13/2023 No such property: 'publisher_assets_hooks' on ExpressionEngine\Legacy\Facade
14:12:50 02/13/2023 #0 /var/www/html/system/ee/ExpressionEngine/Legacy/Facade.php(35): ExpressionEngine\Legacy\Facade->get('publisher_asset...')
#1 /var/www/html/addons/publisher/addons/publisher/ext.publisher.php(1881): ExpressionEngine\Legacy\Facade->__get('publisher_asset...')
#2 /var/www/html/system/ee/legacy/libraries/Extensions.php(203): Publisher_ext->assets_save_row(Object(Assets_ft), Array)
#3 /var/www/html/system/ee/legacy/libraries/Extensions.php(108): EE_Extensions->call_class('Publisher_ext', 'assets_save_row', Array, Array)
#4 /var/www/html/system/user/addons/assets/ft.assets.php(1325): EE_Extensions->call('assets_save_row', Object(Assets_ft), Array)
#5 /var/www/html/system/user/addons/assets/ft.assets.php(1222): Assets_ft->_save_field(Array, Array)
#6 /var/www/html/system/ee/legacy/libraries/api/Api_channel_fields.php(383): Assets_ft->post_save('')
#7 /var/www/html/system/ee/ExpressionEngine/Model/Content/FieldFacade.php(239): Api_channel_fields->apply('post_save', Array)
#8 /var/www/html/system/ee/ExpressionEngine/Model/Content/ContentModel.php(74): ExpressionEngine\Model\Content\FieldFacade->postSave()
#9 /var/www/html/system/ee/ExpressionEngine/Model/Channel/ChannelEntry.php(438): ExpressionEngine\Model\Content\ContentModel->onAfterSave()
#10 [internal function]: ExpressionEngine\Model\Channel\ChannelEntry->onAfterSave()
#11 /var/www/html/system/ee/ExpressionEngine/Service/Model/Model.php(840): call_user_func_array(Array, Array)
#12 /var/www/html/system/ee/ExpressionEngine/Service/Model/Query/Update.php(49): ExpressionEngine\Service\Model\Model->emit('afterSave')
#13 /var/www/html/system/ee/ExpressionEngine/Service/Model/DataStore.php(275): ExpressionEngine\Service\Model\Query\Update->run()
#14 /var/www/html/system/ee/ExpressionEngine/Service/Model/DataStore.php(240): ExpressionEngine\Service\Model\DataStore->runQuery('Update', Object(ExpressionEngine\Service\Model\Query\Builder))
#15 /var/www/html/system/ee/ExpressionEngine/Service/Model/Query/Builder.php(72): ExpressionEngine\Service\Model\DataStore->updateQuery(Object(ExpressionEngine\Service\Model\Query\Builder))
#16 /var/www/html/system/ee/ExpressionEngine/Service/Model/Model.php(370): ExpressionEngine\Service\Model\Query\Builder->update()
#17 /var/www/html/system/ee/ExpressionEngine/Model/Content/ContentModel.php(219): ExpressionEngine\Service\Model\Model->save()
#18 /var/www/html/addons/datagrab/addons/datagrab/models/datagrab_model.php(783): ExpressionEngine\Model\Content\ContentModel->save()
#19 /var/www/html/addons/datagrab/addons/datagrab/Queue/Jobs/ImportItem.php(36): Datagrab_model->importItem(Array)
#20 /var/www/html/addons/datagrab/addons/datagrab/vendor-build/illuminate/queue/Jobs/Job.php(84): BoldMinded\DataGrab\Queue\Jobs\ImportItem->fire(Object(BoldMinded\DataGrab\Dependency\Illuminate\Queue\Jobs\DatabaseJob), Array)
#21 /var/www/html/addons/datagrab/addons/datagrab/vendor-build/illuminate/queue/Worker.php(352): BoldMinded\DataGrab\Dependency\Illuminate\Queue\Jobs\Job->fire()
#22 /var/www/html/addons/datagrab/addons/datagrab/vendor-build/illuminate/queue/Worker.php(310): BoldMinded\DataGrab\Dependency\Illuminate\Queue\Worker->process('default', Object(BoldMinded\DataGrab\Dependency\Illuminate\Queue\Jobs\DatabaseJob), Object(BoldMinded\DataGrab\Dependency\Illuminate\Queue\WorkerOptions))
#23 /var/www/html/addons/datagrab/addons/datagrab/vendor-build/illuminate/queue/Worker.php(142): BoldMinded\DataGrab\Dependency\Illuminate\Queue\Worker->runJob(Object(BoldMinded\DataGrab\Dependency\Illuminate\Queue\Jobs\DatabaseJob), 'default', Object(BoldMinded\DataGrab\Dependency\Illuminate\Queue\WorkerOptions))
#24 /var/www/html/addons/datagrab/addons/datagrab/models/datagrab_model.php(349): BoldMinded\DataGrab\Dependency\Illuminate\Queue\Worker->daemon('default', 'import_2', Object(BoldMinded\DataGrab\Dependency\Illuminate\Queue\WorkerOptions))
#25 /var/www/html/addons/datagrab/addons/datagrab/Commands/CommandImportRun.php(94): Datagrab_model->consumeJobs()
#26 /var/www/html/system/ee/ExpressionEngine/Cli/Cli.php(188): BoldMinded\DataGrab\Commands\CommandImportRun->handle()
#27 /var/www/html/system/ee/ExpressionEngine/Core/Core.php(143): ExpressionEngine\Cli\Cli->process()
#28 /var/www/html/system/ee/ExpressionEngine/Core/Core.php(115): ExpressionEngine\Core\Core->bootCli()
#29 /var/www/html/system/ee/ExpressionEngine/Boot/boot.php(184): ExpressionEngine\Core\Core->run(Object(ExpressionEngine\Core\Request))
#30 /var/www/html/system/ee/eecli.php(105): require_once('/var/www/html/s...')
#31 {main}
@intoeetive
Copy link
Contributor

@litzinger sorry for the delay on this!

Looking at the order of execution here, I wonder if this could be expected behavior.

core_boot gets called when EE_Controller, which is run for web requests, but not for CLI request - and that seems to be correct.

I think it might be better to add separate extension hook (e.g. cli_boot) when CLI is run. And then add-ons devs would choose either to run same code for both web and CLI extensions, or write different methods.

Thoughts?

@litzinger
Copy link
Contributor Author

Yeah, I think an cli_boot hook would be fine.

@intoeetive
Copy link
Contributor

@litzinger where do you think it's best to have the hook placed? I can think of running it just after Cli class was instantiated, or we can have it run a bit later, and pass it the instance of command class as a parameter

@litzinger
Copy link
Contributor Author

Having an instance of the command would be interesting and potentially helpful.

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