Teapot
Well-known member
I'm having some trouble with a cron job that is working, but produces an error in the error log every time it runs. For the life of me, I can't work out why:
The code that's run by this cron is this:
CreativeCorner_CronEntry_Views
CreativeCorner_Model_Works
Anyone have any ideas as to what could be causing this issue?
As always, thanks very much for your time.
Code:
ErrorException: Cannot modify header information - headers already sent by (output started at /home/pcharms/public_html/library/CreativeCorner/Model/Works.php:1) - deferred.php:21
array(3) {
["url"] => string(34) "http://pokecharms.com/deferred.php"
["_GET"] => array(0) {
}
["_POST"] => array(4) {
["_xfRequestUri"] => string(106) "/admin.php?cron/CCorner_UpdateViews/run&_xfToken=1%2C1385546511%2Cb5031f692efcb2484c1938be253b33308cbe40f1"
["_xfNoRedirect"] => string(1) "1"
["_xfToken"] => string(8) "********"
["_xfResponseType"] => string(4) "json"
}
}
The code that's run by this cron is this:
CreativeCorner_CronEntry_Views
Code:
<?php
class CreativeCorner_CronEntry_Views
{
public static function runViewUpdate()
{
XenForo_Model::create('CreativeCorner_Model_Works')->updateWorkViews();
}
}
CreativeCorner_Model_Works
Code:
<?php
class CreativeCorner_Model_Works extends XenForo_Model
{
// [unrelated/unexecuted code removed...]
public function updateWorkViews()
{
$db = $this->_getDb();
$db->query('
UPDATE cc_work
INNER JOIN (
SELECT work_id, COUNT(*) AS total
FROM cc_work_view
GROUP BY work_id
) AS new_count ON (new_count.work_id = cc_work.work_id)
SET cc_work.view_count = cc_work.view_count + new_count.total
');
$db->query('TRUNCATE TABLE cc_work_view');
}
// [...]
}
As always, thanks very much for your time.