Problem with batch create

First, I'll tell you that I blew up my site (after a backup) to move to WPMU 2.9.1 last night, along with the latest Multi-DB, plus the cets_default_user_role plugin, TypePadAntiSpam, Default theme and Smart YouTube.

The issue I'm having with the Batch plugin at this point is that it seems to be jumping around in the CSV file. The first time I tried it (under 2.8.6), it worked almost perfectly (although it DID create a couple of the users and blogs out of order).

My CSV had 5271 lines then, just as it does now.

Last night, the plugin decided to start at line 1092. Blew up the DB and started again. This time it added the second line from the bottom first, then the bottom line, then the 4th line, then the third, then it started adding the rest in order.

While for many, this might work just fine, let me give you a QUICK explanation of why it's unacceptable for ME, and I need to find a fix. My site creates a blog for all 5271 US soldiers who have been killed in the wars in Iraq and Afghanistan (which then get taken over by their families). My CSV is sorted by their date of death. So the first blog that gets created (which is at the bottom of my CSV file) is the first soldier killed. And on an ongoing basis, the most recent blogs created will be the most recent KIA's. It's a small detail, but an important one for all the tweaking and record keeping it allows me to do later.

How do I fix this? It would appear it ISN'T the CSV, because I've reuploaded the same file three times now, and the plugin attacks it differently every time.

Should I try building in a 2-second delay between runs of the loop?

Best,
Neil

PS - I should also add that the counter never updates - it never tells me how many blogs are left in the queue waiting to be created.

  • crsneil

    Upon further investigation, I find that the batch-create script doesn't appear to order the queue. It DOES go through the CSV from bottom to top, but as I looked at the DB tables themselves I see that the blog that's SUPPOSED to get created 4th is at the top of the list in the DB.

    And sure enough, when I process the queue, that blog gets added first.

    Where should I add the "ORDER BY" to the DB query so the script actually processes my CSV in order as advertised?

    To me, it looks like the addition needs to be made in line 298 of the script...

    $query = "SELECT batch_create_ID, batch_create_blog_name, batch_create_blog_title, batch_create_user_name, batch_create_user_pass, batch_create_user_email FROM " . $wpdb->base_prefix . "batch_create_queue WHERE batch_create_site = '" . $current_site->id . "' LIMIT 1";

    Should be...

    $query = "SELECT batch_create_ID, batch_create_blog_name, batch_create_blog_title, batch_create_user_name, batch_create_user_pass, batch_create_user_email FROM " . $wpdb->base_prefix . "batch_create_queue WHERE batch_create_site = '" . $current_site->id . "' ORDER BY batch_create_id DESC LIMIT 1";

    ...am I close?

    -- N

  • crsneil

    Talking to myself this much probably requires a trip to my shrink. However, wanted to update for posterity that I made the above edit to line 298, CSV now gets processed in the correct order.

    Also added

    sleep(3);

    as line 305 just for the heck of it.

    Script still doesn't update the queue count though. And with 5000+ lines in the CSV, a cool additional feature would not only be to have the counter work, but to provide an estimate on how much longer the queue will take.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.