- May
- 27th
- 2008
WP-o-Matic : Cron job done! but no campaigns processed
Posted by MaEl in: Bits-and-Bytes Comments (37)
After struggling to make cron job work properly, now it doesn’t process the campaigns. It processes the campaigns only if the campaign is new. For the 2nd time, it doesn’t worked. the campaigns status in dashboard still showing next! even if I manually access the secret WP-o-Matic cron url. Browsing the source code and I found out that there are several bugs in the wpomatic.php. The process stucked at getCampaigns function.
function getCampaigns($args = '')
{
global $wpdb;
extract(WPOTools::getQueryArgs($args, array('fields' => '*',
'search' => '',
'orderby' => 'created_on',
'ordertype' => 'DESC',
'where' => '',
'unparsed' => false,
'limit' => null)));
if(! empty($search))
$where .= " AND title LIKE '%{$search}%' ";
if($unparsed)
$where .= " AND active = 1 AND (frequency + lastactive) < ". current_time('timestamp', true) . " ";
$sql = "SELECT $fields FROM `{$this->db['campaign']}` WHERE 1 = 1 $where "
. "ORDER BY $orderby $ordertype $limit";
return $wpdb->get_results($sql);
}
And that tell me why it does work for the first time only. The data for ‘lastactive’ is in ’2008-05-27 01:00:00′ format while the ‘frequency’ is in second. We need to use UNIX_TIMESTAMP to convert the ‘lastactive’ to second. So, that the math can work.
Now that the cron work but it always processed the campaign.. like avoiding the ‘frequency’ value. Again, I checked the data in ‘lastactive’ and I found out that it was the GMT time. Subtract the GMT value should do it.
Here’s the final codes
replace
if($unparsed)
$where .= " AND active = 1 AND (frequency + lastactive) < ". current_time('timestamp', true) . " ";
with
if($unparsed)
$where .= " AND active = 1 AND (frequency + UNIX_TIMESTAMP(lastactive)) < ". (current_time('timestamp',1) - ($gmt ? 0 : (get_option('gmt_offset') * 3600))) . " ";
Now, Cron work nicely!
Updated June 02, 2008
This is unofficial fix!! modify at your own risk
please visit http://devthought.com/wp-o-matic-the-wordpress-rss-agreggator/ or http://wpomatic.lighthouseapp.com
« Clarkconnect DynDNS,EveryDNS updater | WP-Geo resetting image stylesheet »
37 Responses to “WP-o-Matic : Cron job done! but no campaigns processed”
Leave a Reply
May 28th, 2008 at 1:20 am
[...] error I looked to wpomatic code but never came to conclusion. and search google accordingly, found pixca.net post describing it in detail and sorting the [...]
May 28th, 2008 at 10:30 pm
Great Post Problem Solve nice work men
thx
May 30th, 2008 at 1:17 pm
thanks I’m having the same problem I’ll give this a try
June 1st, 2008 at 12:15 pm
Users should know this then causes process frequency to be delayed by the offset.
June 2nd, 2008 at 9:21 pm
frequency delayed by the offset?? I’ve verified the mysql data for my WP-o-Matic installation (WordPress 2.5.1 & WP-o-Matic 1.0RC3-7) and the date is in GMT value. Try check the mysql data
June 3rd, 2008 at 1:28 am
Thanks for the code. I had the same problem as you, works fine now!!! Excellent job. Thank you
June 16th, 2008 at 3:00 am
Thank you, this is what I was looking for!
June 25th, 2008 at 2:07 am
A glorious patch – thank you so much!!!
June 26th, 2008 at 2:26 pm
Hi,
Is the patch the same for every timezone? Or should it be adapted if your in GMT +2 hours?
June 27th, 2008 at 10:35 pm
IT WORKED!!!!!
June 27th, 2008 at 11:31 pm
oh and if you are having problems with wpomatic and firefox 3… and adding campaigns..
usually it will say cannot parse rss feed..
what i had to do is clear my cache after adding a each new rss feed, copy the rss url and then wait a minute. then save the campaign. dont know why but that works. took me 5 hours to find that out on my own lol
June 28th, 2008 at 2:34 am
Thanks for the fix. Meanwhile, for those in Dreamhost: have you gotten image-caching to work? Thought I’d ask just in case someone is w/ them as well.
June 28th, 2008 at 2:40 pm
To fix the time that is displayed in the Dashboard for the Next Campaigns to process, change lines 164-165 in wpomatic.php from:
$cl = $this->getCampaignRemaining($campaign);
to:
$cl = $this->getCampaignRemaining($campaign, get_option('gmt_offset'));
This calculated time is not actually used by the code that processes the campaigns.
To correctly display the crontab code, change line 34 in inc/admin/home.php from:
# Cron command / url
$this->cron_command = attribute_escape('*/20 * * * * '. $this->getCommand() . ' ' . dirname(__FILE__) . '/cron.php?code=' . get_option('wpo_croncode'));
to:
# Cron command / url
$this->cron_command = attribute_escape('*/20 * * * * '. $this->getCommand() . ' ' . $this->pluginpath . '/cron.php?code=' . get_option('wpo_croncode'));
July 8th, 2008 at 2:57 am
Thanks so much for the fix! The cron job not working was driving me crazy.
July 8th, 2008 at 2:12 pm
Didn’t work here. I mean, there’s the server time, the time configured on wp, the local time, the local settings (for non English) time format… it’s a pain in the ass.
Can you please tell me all your date formats and settings?!
Thanks
July 8th, 2008 at 2:27 pm
Why not just forget this time calculations, GMT and offsets nightmares and just fetch the damn feeds everytime the cron is called?!
July 8th, 2008 at 3:09 pm
Any clue on where should I look next in order to try to fix it?
Strange thing is that althought I put 0 d 0 h 10 min frequency, I always get a 7h waiting time to process the campain. Something is very wrong with my time settings.
Could it be the non english version of wp?!
July 8th, 2008 at 3:45 pm
I know what my problem is. My server is in USA and I’m in Europe. There’s a huge 7 hours gap between what current_time wp function gives for current time and my actual current time!
July 9th, 2008 at 2:23 am
There’s only one way I could put it to work:
Instead of:
- ($gmt ? 0 : (get_option(‘gmt_offset’) * 3600))
I used:
+ (7 * 3600)
July 9th, 2008 at 1:57 pm
For those confused by the instructions given by Bart Schipper above, he made a typo error.
“To fix the time that is displayed in the Dashboard for the Next Campaigns to process, change lines 164-165 in wpomatic.php”
should be “change line 34 in inc/admin/home.php”
And …
“To correctly display the crontab code, change line 34 in inc/admin/home.php from:”
should be “change lines 164-165 in wpomatic.php”
I also found that the crontab code in my wp-o-matic 1.0RC3-7 wpomatic.php was already amended to include Bart’s changes above.
July 30th, 2008 at 9:46 am
That’s funny- I had to modiy two instances of 1.0RC3-7 as above to make them work. However, an instance of 1.0RC4-6 which came modified almost identically does NOT work!- same problem- CRON apparently runs but nothing processed.
Any ideas??
August 22nd, 2008 at 12:59 am
[...] del módulo wpomatic.php, se genera una llamada a SQL que es incorrecta según varios programadores (lo [...]
August 25th, 2008 at 11:17 am
Will give it a try. Thanks for the code!
September 6th, 2008 at 8:54 pm
it worked like a charm!
September 10th, 2008 at 4:48 pm
Your patch is nice, Thanks
I am newbie with cone jobs and i want that cron run everyday 12:00 pm daily, plz give an exaple command so i understand what to put in cpanel cron jobs commands, bcoz i dont understand wp-o-matic given command .
September 11th, 2008 at 1:37 am
Haven’t using cpanel for a while now. Put this code in your cron (maybe in advance mode)
0 12 * * * /usr/bin/curl http://YOUR_DOMAIN_NAME.com/wp-content/plugins/wp-o-matic/cron.php?code=xxxxx
run at 12.00PM daily
xxxxx is the secret code that wp-o-matic gave you. Hope that helps
September 13th, 2008 at 11:44 am
In wpomatic.php I changed line 447
$campaigns = $this->getCampaigns(‘unparsed=1′);
to this
$campaigns = $this->getCampaigns();
Cronjob work fine now.
October 2nd, 2008 at 12:57 am
[...] MaEl reports that the lastactive columb is in timestamp format, whilst the frequency column is in seconds, you need to convert the lastactive date to be UNIX_TIMESTAMP to get the maths to work correctly. What, didn’t you spot that yourself? [...]
October 25th, 2008 at 6:05 pm
thanks…
October 29th, 2008 at 7:56 pm
thanks…
December 8th, 2008 at 1:47 pm
problems wordpress 2.6.5 / wp-o-matic 1.0RC4-6 no procesa campañas help
December 18th, 2008 at 12:04 pm
I have the same problem with aimar. the cron runs fine in RC4.6 but does not process any posts
I did this solution
In wpomatic.php I changed line 447
$campaigns = $this->getCampaigns(’unparsed=1′);
to this
$campaigns = $this->getCampaigns();
Cronjob work fine now.
but it slows down my website to a halt
December 18th, 2008 at 1:10 pm
Friends
I’m have the same problem of the original poster. I’m running
WordPress 2.7 and 1.0RC4-6 and I tried to use the fix posted but no luck with the automatic fetching and when i try a manual fetch that doesn’t work. any have any suggestions?
January 15th, 2009 at 8:50 pm
i have the same problem. i checked the file and it was ok like you sugest to change… any suggestions? how can i check if the cron job is done or working?
January 23rd, 2009 at 3:45 am
WP-o-Matic is AWESOME for syndication! Glad you invest your time in it!
I’m running WordPress 2.7 and 1.0RC4-6. I have tried every fix I can find and the cron job won’t work. Doing a manual fetch works fine however.
June 21st, 2009 at 2:03 am
I was checking today the new version with this update included, but cron is still not working.
Which is the best time settings to do each cron job?
October 3rd, 2009 at 5:43 am
I’m having some issues with this plugin. I have some 100 campaigns set up, and the cron job added, but only 80 campaigns seem to be processed…. Any idea why?