WordPress.org

Ready to get started?Download WordPress

Forums

Batch processing all the posts (15 posts)

  1. Blutarsky
    Member
    Posted 4 years ago #

    Hi mates, any chance to process all the posts, without using a query?
    I can't simply write a PHP batch, because I need some WP/plugins functionality

    Any hint? Some documents to start with? Any primer?

  2. Jonas Grumby
    Member
    Posted 4 years ago #

    What do you mean by "process"?

  3. Blutarsky
    Member
    Posted 4 years ago #

    I need to read each post (in a "batch" fashion), modify some post content and title, and store.

  4. Jonas Grumby
    Member
    Posted 4 years ago #

    I'm still not clear on what you are trying to do but the Search and Replace plugin may help.

  5. Blutarsky
    Member
    Posted 4 years ago #

    It's not a simple search & replace matter.
    I need quite long code running on each post, search & replace is unfit.
    Any other idea?

  6. Jonas Grumby
    Member
    Posted 4 years ago #

    Unless there is some common thing that you want to change on all the posts, I don't know of any way to do it in a batch fashion. I still don't really know what you are trying to do.

  7. Blutarsky
    Member
    Posted 4 years ago #

    As I have said, I need to change the contents in each post, from the first one to the last one but content modification in each post will change depending on post content itself.

  8. Jonas Grumby
    Member
    Posted 4 years ago #

    There is no way to make individual changes as a batch, in any program, anywhere...

    It defies the very explanation of what a batch process is.

  9. Blutarsky
    Member
    Posted 4 years ago #

    (′bach ′präs·es·iŋ)

    (computer science) A technique that uses a single program loading to process many individual jobs, tasks, or requests for service.

    In my case, iterate through ALL posts, from first one to last one; per each post do something (read post, modify contents, store post).

    While this could be achieved EASILY within WordPress environment, it actually can't , just because of timeout limitations.

  10. Mark / t31os
    Moderator
    Posted 4 years ago #

    Sounds to me like you need cron processes, for automated procedures..

    Try google and if not much help, check out this page to.

  11. Blutarsky
    Member
    Posted 4 years ago #

    No,no,no! :-)
    Is it possible that no one wrote some PHP code to iterate through all the posts of a WordPress install?

    Pseudocode:

    - Use proper SELECT to start
    - read first post
    (a) End of dataset? if not continue, otherwise exit
    - do the updates to the post content and title
    - save the post
    - read next post
    - goto (a)

  12. Mark / t31os
    Moderator
    Posted 4 years ago #

    - Use proper SELECT to start
    - read first post
    (a) End of dataset? if not continue, otherwise exit
    - do the updates to the post content and title
    - save the post
    - read next post
    - goto (a)

    What makes you think a Cron process couldn't do exactly what you've described?

    Else if it's just a series of "get a" adjust to "b", update "c", etc... write a script to do it..

    The WordPress database class for reference.
    http://codex.wordpress.org/Function_Reference/wpdb_Class

  13. Blutarsky
    Member
    Posted 4 years ago #

    Sorry for the duped post.

    Do you think can use that class avoiding timeouts? It's a quite lenghty job, I would say it would last some 20 minutes to run on some 3000 records....

    Maybe adjusting Apache & PHP timeouts..... What do you think?

  14. Mark / t31os
    Moderator
    Posted 4 years ago #

    No idea honestly, i'm simply offering some suggestions..

    If this a process you want automated i would suggest taking a further look at Cron processing, even if it means dividing the overall task into several smaller ones (that could help with timeout issues - maybe?).

    About as close as i've been to batch processing is writing the odd .bat file on windows to open up my apps or run a defrag, so i'm not speaking from experience.

    I'm not sure your question is nessarily specific to WordPress, the only element that makes this about WordPress is the fact you're performing operations on data in the WordPress database, but i don't think that means you necessarily need exclude other batch scripts as possibilities. I think the WP cron functions are the way to go personally, but it's not really something i've had experience with myself.

    Your question might be better suited posted on one of the following mailing lists.

    http://codex.wordpress.org/Mailing_Lists#Hackers
    http://codex.wordpress.org/Mailing_Lists#Professional

    I'll move your thread to the Advanced forum later today, this seems a little bit outside the scope of the regular "how do i do this on the blog" questions that typically reside in this forum. I'll let the thread have a little life here first though, then move it onto the Advanced section.

  15. wjm
    Member
    Posted 4 years ago #

    are you looking for this?

    in theory you can run a php script as long as needed,
    and you dont need apache to run php.

Topic Closed

This topic has been closed to new replies.

About this Topic