How to test an extension's run() mehtod?

Ernesto

Member
Hi, I'm debugging an extension somebody else made, and I want to execute its run() method so I can enter it with the debugger.
How do I do this?

PS: The extension is supposed to run with a daily cronjob, and I'm not sure how do extensions get hooked in cron, so maybe there's the solution?
 
@Ernesto - The extensions ran at the app init, so most likely your run() method runs each time a page is called. You can place some debug code inside it, like an exit statement with some message, then reload the web page and see if it gets triggered.
 
Thanks, I tried that, but it doesn't work, and it kind of makes sense, because I see all the processing in the plugin is hooked to the console_command_daily.
I know I could test this by executing that console command, but it also would trigger any other daily hooked process.
Is there a way to execute this particular extension from a console command?

PS: Also, if this run() method runs on every page load, when it hooks with "Yii::app()->hooks->addAction('console_command_daily', ..." does it hook multiple times?
How does mailwizz store this callback and run it just once daily?
 
Is there a way to execute this particular extension from a console command?
Hook it to another command in this case, console_command_clear_cache_before_process should do it just fine.

when it hooks with "Yii::app()->hooks->addAction('console_command_daily', ..." does it hook multiple times?
If multiple calls to Yii::app()->hooks->addAction('console_command_daily', ..." are made, it will be queued multiple times. Just keep in mind that this is request based, so it won't persist between requests.

How does mailwizz store this callback and run it just once daily?
It doesn't store them. Instead, the daily cronjob triggers the hook when it calls: Yii::app()->hooks->doAction('console_command_daily') and it executes all the actions attached in that request for that hook.
 
Back
Top