Hey all,
I am working with OJS for the first time and I am trying to add a new ScheduledTask. I have it running and can see that the ScheduledTask was executed however even if I do a fatalError in any of the ScheduledTasks such as OpenAddressNotification then it doesn’t get outputted when I run the cron manually like so:
I just get an empty output on the command line which indicates everything ran successfully and I can see the last_run time in the scheduled_tasks table is updated.
See my added ScheduledTask below that I am trying to execute and spit errors out to the command line…
<?php
/**
* @defgroup tasks
*/
/**
* @file classes/tasks/OpenAccessNotification.inc.php
*
*/
import('lib.pkp.classes.scheduledTask.ScheduledTask');
class EmailArticlePublished extends ScheduledTask {
/**
* Constructor.
*/
function EmailArticlePublished() {
parent::ScheduledTask();
}
/**
* @see ScheduledTask::getName()
*/
function getName() {
return __('admin.scheduledTask.EmailArticlePublished');
}
function sendNotification () {
fatalError('Email Sent');
}
function sendNotifications ($articles) {
import('classes.mail.MailTemplate');
$email = new MailTemplate('OPEN_ACCESS_NOTIFY', $articles->getPrimaryLocale(), false, $articles, false, true);
$email->setSubject('email');
$email->setFrom('test@gmail.com');
$email->addRecipient('lnorman137@gmail.com');
$mimeBoundary = '==boundary_' . md5(microtime());
$templateMgr =& TemplateManager::getManager();
$templateMgr->assign('body', $email->getBody($articles->getPrimaryLocale()));
$templateMgr->assign('mimeBoundary', $mimeBoundary);
$email->addHeader('MIME-Version', '1.0');
$email->setContentType('multipart/alternative; boundary="'.$mimeBoundary.'"');
$email->setBody($templateMgr->fetch('subscription/openAccessNotifyEmail.tpl'));
$templateMgr->assign_by_ref('publishedArticles', $publishedArticles);
$email->send();
$this->sendNotification();
}
/**
* @see ScheduledTask::executeActions()
*/
function executeActions() {
$articleDao =& DAORegistry::getDAO('PublishedArticle');
$articles =& $articleDao->getLatestPublishedArticles();
fatalError('failed!');
$this->sendNotifications($articles);
return true;
}
}
?>
And I have added it to the scheduledTasks.xml and I know it’s running but none of my errors are being outputted?
<task class="classes.tasks.EmailArticlePublished">
<descr>Send automated email to all article authors and editors once the article has been published</descr>
<frequency month="0"/>
</task>
Any help is appreciated.
Thanks!