Forums | using bulk update for future posts

You must be logged in to post Login Register

Search Forums:


 






using bulk update for future posts

UserPost

8:42 am
June 19, 2009


dianacris

Member

posts 4

I'm using stripshow (nice plugin btw) but am having trouble with future posts.  Let me first say that I have modified the code and I realize that may preclude me from getting much assistance, but figured this would be the best place to start asking.

I had the site created on a test server and used the bulk upload to create several weeks of posts.  The dates for most of the comics are in the future.  My goal is to upload several weeks worth at a time so that I don't have to upload them daily.  In fact, I have comics for Mon-Fri publication thru the end of July.  At first, all the posts would display, despite the publish date in the future.  I figured it had to do with the time — most had the correct date but a time of 00:00.  So, I modified the code to insert the comics with a time of 01:00 AM.  That seemed to work because the future posts were not published but showed as scheduled.  All posts this week, including today's, have published as expected.

However, I deployed everything earlier this week to the web server and notified everyone that the site was out there.  But, the posts are not publishing again.  I keep getting a "missed schedule" on the posts.  This morning's had to be "forced" to publish by modifying the publish date/time.

Any suggestions on what could cause the difference between the two environments?  Both servers are using WP 2.7 and stripshow 1.8.1

TIA for any help.

8:48 am
June 19, 2009


Brad

Admin

posts 233

I'll have to test this. Can you send me your files via PM? I would like to set up a test environment with the same dates you're using.

9:48 am
June 19, 2009


Brad

Admin

posts 233

OK, well, I clearly misunderstood the way WordPress handles future posts. Apparently, they're given a post status of 'future' rather than 'published'… I didn't think that was the case. I'll do some testing and add this feature into 2.0.

10:34 am
June 19, 2009


Brad

Admin

posts 233

Interestingly, while I have replicated the issue on stripShow 1.8.1, stripshow 2.0 betas don't have the problem. Future posts are correctly marked "future." I must have inadvertently stumbled upon the cause of the issue when I was overhauling the bulk import code.

10:44 am
June 19, 2009


Brad

Admin

posts 233

Post edited 7:53 pm – September 21, 2009 by Brad


OK, I figured out what the difference was. stripShow 1.x doesn't put anything for the GMT post time… I had added this in 2.x, and it now works.

If you want to patch your 1.x installation to do this, replace the stripshow_bulk_update function with:

function stripshow_bulk_update() {
global $wpdb;
$count = 0;
$filenames = glob('../'.get_option('stripshow_comicdir').'*'); // get array of all files in the comic directory
if ($fp = opendir('../'.get_option('stripshow_comicdir'))) {
  while (($file = readdir($fp)) !== FALSE) {
if (is_file('../'.get_option('stripshow_comicdir').$file) && preg_match('/([d]{4}[-/]*[d]{2}[-/]*[d]{2}).*.(gif|jpg|png|htm|html|txt)$/i', $file,$rawdate)) { // look for real files that have dates in their names.
$timestamp = strtotime($rawdate[1]);
$gmt_date = date('Y-m-d H:i:s',$timestamp+(get_option('gmt_offset')*-3600));
$current_date = date('Y-m-d',$timestamp);
$full_date = date('l, F j, Y',$timestamp);
$querystring = stripshow_db_query() . " AND (DATE(post_date) = '$current_date')";
$results = $wpdb->get_row($querystring); // do a MySQL query for any posts with this date
if (!$results) { // There is no  blog entry for this date.
$title = "Comic for ".$full_date;
$myPost = array(
'user_ID' => 1,
'action' => 'post',
'post_author' => 1,
'temp_ID]' => -1139182474,
'post_title' => $title,
'content' => 'This is a placeholder.',
'post_pingback' => 1,
'prev_status' => 'draft',
'publish' => 'Publish',
'referredby' => 'redo',
'advanced_view' => 1,
'comment_status' => 'open',
'ping_status' => 'open',
'post_password' => ",
'post_name' => $current_date,
'post_category' => Array
(
'0′ => get_option('stripshow_category')
),

'post_status' => 'publish',
'post_author_override' => 1,
'excerpt' => ",
'trackback_url' => ",
'metakeyinput' => ",
'metavalue' => ",
'newcat' => ",
'post_content' => 'This is the comic for '.$full_date.'.',
'post_excerpt' => ",
'post_parent' => ",
'to_ping' => ",
'post_date_gmt' => $gmt_date,
'post_date' => $current_date);
$id = wp_insert_post($myPost);
if ($id) $count++;
}
  }
}
  closedir($fp);
}
  return $count;
}

8:28 am
June 20, 2009


dianacris

Member

posts 4

I replaced my bulk update function with your code and experienced the same problem.  My test server worked fine — the post showed up today as scheduled — but on the main site it did not.  I got a "missed schedule" error again.

Any other suggestions?  I'm at a loss.

10:51 am
June 21, 2009


Brad

Admin

posts 233

Hmmm. I'm not sure what the "missed schedule" error means in WordPress — I've never encountered it. I've searched around and see a WordPress forum thread with people complaining of this issue: http://wordpress.org/support/topic/221086

Do regular blog posts (not comics) added using Add New, scheduled for a future date, show up normally when that time comes around?

Try this as a test: Write a post, with a time of five minutes from now. Wait five minutes. See if it posts.

8:48 am
June 23, 2009


dianacris

Member

posts 4

Thanks for the help!  I don't have any regular blog posts on the site right now, and don't expect to in the future, but I think the Add New and scheduled for a future date works because I'm pretty sure I tried it on my test site when I first started this process.  I was so excited I wouldn't have to write/find code to keep future comics from displaying.

However, I found a plugin called Scheduled MIAs (http://blog.5ubliminal.com/?s=scheduled+mia) which has done the trick!  The posts are publishing when they're supposed to and I don't have any more missed schedule errors. 

One thing I didn't mention earlier because I was trying to focus on one thing at a time … whenever I upload new comics, it will create duplicate posts for any future posts.  I tracked it down to the stripshow_incat_query.  The query string it returns is excluding the future posts so the bulk update is creating these posts again.  When I uploaded my test comic on Sat (which would publish on Sunday) I got 30 comics instead of 1.  The other 30 were the June/July ones that are in the future.  Not too hard to delete them, and since they were future posts they didn't show up on the site duplicated, but it was just a nuisance.

Again, thanks for your help!  This has been an interesting experience!  I greatly appreciate you and anyone else who creates plugins.  Without them, there's no way my site would be up and running!

9:06 am
June 23, 2009


Brad

Admin

posts 233

dianacris said:
One thing I didn't mention earlier because I was trying to focus on one thing at a time … whenever I upload new comics, it will create duplicate posts for any future posts.  I tracked it down to the stripshow_incat_query.  The query string it returns is excluding the future posts so the bulk update is creating these posts again. 

Ahh… that's something I should look into. That behavior is clearly not desirable.



  • Donate

    While I don't maintain stripShow for a living, I wouldn't say no to a little donation, if you think the plugin is worth it...

  • Advertisements