Yes, see post #5. However, the cron task doesn't set its script name.
However, I don't believe this is the problem, because when I run the cron job in the admincp, where the job runs as me, the phrase works. Only when the job runs by itself (as unregistered) does the phrase not work.
I'm guessing that somehow an unregistered cronjob has less rights, and doesn't get access to phrases?
Ok, I've done some more testing and discovered what the problem is.
basically /includes/cron/cleanup.php is the only cron job with a hook in it.
However, this file needs to have:
global $vbphrase;
At the top, otherwise phrases are not available to this file, nor the hook.
I could work around this by building my own cron file for what I am working on, but would have preferred to work without additional files.
It seems a little strange when there is an entire phrase group for scheduled tasks, yet phrases aren't available in the only cron job with a hook
Work-around solution to being unable to get phrases
I found one way to get around this for situations where you can't get $vbphrase into your routine for whatever reason. I just decided to pull the phrase out of the database. Obviously this isn't good for something that is executing many times on every page, but for occassional use (like in a cron job) it should be no drama.
Code:
$myphrase = pullphrase("the_name_of_my_phrase");
function pullphrase($phrasename, $language=-1)
{
global $db;
return implode("", $db->query_first("SELECT text FROM " . TABLE_PREFIX . "phrase WHERE varname = '$phrasename' AND languageid = $language"));
}
This could be easily modified to load up an entire phrase group with a single query.
I hope someone else who runs into the same kind of problems I did finds this and it makes life easier for them.