Patch for fixing most out of memory errors when importing
|Reported by:||mark8barnes||Owned by:||anonymous|
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.
- Firstly, create a function that duplicates the _save_post_hook function and remove the rewrite commands from it.
- Then remove_action('save_post', '_save_post_hook', 5, 2) and add_action('save_post', 'custom_function', 5, 2).
- Perform the import.
- Reverse the remove/add actions.
- 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.