The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Run scheduled task from plugin?
I'm working on a plugin that needs to call for a scheduled task to run at that moment, without waiting for the next scheduled task run time.
Is there a way to force a scheduled task to run from inside the plugin code? Thanks, James |
#2
|
|||
|
|||
I haven't tested it, but looking at the code in admincp/cronadmin.php for running a scheduled task, I think this might work:
PHP Code:
I don't know, you may or may not want the ignore_user_abort and/or the set_time_limit calls in your plugin. |
#3
|
|||
|
|||
Thanks for your help.
I got the scheduled task ID from the Scheduled Task manager: Scheduled Task: Process FFMPEG queue (id: 31) I'm putting this code in the attachdata_postsave hook, so I tried changing it to this: Code:
if ($nextitem = $this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "cron WHERE cronid = 31")) { ignore_user_abort(1); @set_time_limit(0); require_once(DIR . '/includes/functions_cron.php'); include_once(DIR . '/' . $nextitem['filename']); } Code:
Fatal error: Call to a member function query_first() on a non-object in /home/forum321/public_html/includes/class_dm_attachment.php(659) : eval()'d code on line 99 |
#4
|
|||
|
|||
Hmm...seems like that should be right. You could try
PHP Code:
but I don't see why $this->registry wouldn't work. |
Благодарность от: | ||
Lynne |
#5
|
|||
|
|||
Thank you very much
That change appears to make it work as intended. My working code is now: Code:
global $vbulletin; if ($nextitem = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "cron WHERE cronid = 31")) { ignore_user_abort(1); @set_time_limit(0); require_once(DIR . '/includes/functions_cron.php'); include_once(DIR . '/' . $nextitem['filename']); } For example, I'm using echo commands in the scheduled task that are nice to show the progress in the AdminCP, but I'd like to hide them from the Manage Attachments window when attachdata_postsave is called from there. Currently all the echo outup from the scheduled task shows up at the top of the Manage Attachments window after the attachdata_postsave hook is called and processes the scheduled task. Thanks again, James |
#7
|
|||
|
|||
That works perfectly.
Thanks for all your help. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|