[wp-trac] [WordPress Trac] #7193: Patch for fixing most out of memory errors when importing

WordPress Trac wp-trac at lists.automattic.com
Fri Jun 27 16:00:45 GMT 2008


#7193: Patch for fixing most out of memory errors when importing
----------------------------+-----------------------------------------------
 Reporter:  mark8barnes     |       Owner:  anonymous
     Type:  defect          |      Status:  new      
 Priority:  high            |   Milestone:  2.7      
Component:  Administration  |     Version:           
 Severity:  major           |    Keywords:           
----------------------------+-----------------------------------------------
 It's fairly common to run out of memory when importing. It seems a main
 reason for this is that the rewrite rules are flushed every time a post is
 created. On one of my blogs, this uses up over 1Mb of memory that you
 don't get back (it has 200 static pages and the /%post-name%/ permalink
 structure).

 It seems to me that there's an easy fix for each of the importers. The fix
 should also save on processing time.

 1. Firstly, create a function that duplicates the _save_post_hook function
 and remove the rewrite commands from it.

 2. Then remove_action('save_post', '_save_post_hook', 5, 2) and
 add_action('save_post', 'custom_function', 5, 2).

 3. Perform the import.

 4. Reverse the remove/add actions.

 5. Flush the rewrite rules.

 Perhaps a more elegant solution would be to provide a hook or variable
 that could be passed to _save_post_hook that would prevent the rewrite
 rules flushing. That way it saves having duplicate code in two functions.

-- 
Ticket URL: <http://trac.wordpress.org/ticket/7193>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list