PDA

View Full Version : Cron Job Insight Required


J98680Bxxxxx
07-19-2008, 06:14 PM
Hi All,

I am having some trouble with a cron job not receiving vbulletin global variables. The cron job runs fine if activated manually from the ACP, but it fails to work as a standalone scheduled task.

The file content looks like this

<?php

error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db)) {exit;}

if ($vbulletin->options['mysettingname'] == 1){
... do something...
}
...

?>

Any call to "$vbulletin->options['mysettingname']" or to "vbphrase['myphrasename']" fails to work and even the function "construct_phrase(...)" fails to work and I ressorted to get the values directly from the "setting" and "phrase" tables in the database.

Is there any type of memory limitation in vbulletin for a hack/mod amount of settings/phrases used that might prevent global variables to be passed?

Any hint or insight is appreciated. :)

I read the recommendations by Lynne (https://vborg.vbsupport.ru/showpost.php?p=1438621&postcount=10) and Marco (https://vborg.vbsupport.ru/showpost.php?p=1438695&postcount=11), but to no avail.

Paul M
07-19-2008, 06:29 PM
$vbulletin->options should be available in cron jobs, what exactly makes you think they aren't ?

J98680Bxxxxx
07-19-2008, 07:23 PM
Their content happen to be empty when the cron job runs alone. When run manually, they are not empty. :confused:

Marco van Herwaarden
07-20-2008, 09:26 AM
Is the settinggroup in which these settings are stored loaded?

J98680Bxxxxx
07-20-2008, 11:34 AM
Settinggroup loaded with the product file. From a manual run of the cron job, the values of the different settings are available. But on its own as a scheduled job, those values do not seem to be available. Is there any special "include" instruction that must be specified at the very beginning of a cron file?

To have the cron file working as a standalone scheduled job, I have replaced (in the cron file) for example all occurrences of:

$cron_mysetting_varname = $vbulletin->options['mysetting_varname']

(resp. $cron_myphrase = $vbphrase['myphrase'])

with:

$get_setting = $vbulletin->db->query_read("SELECT * FROM `". TABLE_PREFIX ."setting` WHERE `varname` = 'mysetting_varname'");
$fetchsetting = $vbulletin->db->fetch_array($get_setting);
$cron_mysetting_varname = $fetchsetting['value'];

(resp.
$get_phrase = $vbulletin->db->query_read("SELECT * FROM `". TABLE_PREFIX ."phrase` WHERE `varname` = 'myphrase'");
$fetchphrase = $vbulletin->db->fetch_array($get_phrase);
$cron_myphrase = $fetchphrase['text'];
)