Make WordPress Core

Opened 17 years ago

Closed 17 years ago

#7193 closed defect (bug) (fixed)

Patch for fixing most out of memory errors when importing

Reported by: mark8barnes's profile mark8barnes Owned by:
Milestone: 2.7 Priority: high
Severity: major Version:
Component: Administration Keywords:
Focuses: Cc:

Description

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.
  1. Then remove_action('save_post', '_save_post_hook', 5, 2) and add_action('save_post', 'custom_function', 5, 2).
  1. Perform the import.
  1. Reverse the remove/add actions.
  1. 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.

Change History (4)

#1 @ryan
17 years ago

(In [9101]) Don't flush rules for every post imported. see #7193

#2 @DD32
17 years ago

(In [9101]) Don't flush rules for every post imported. see #7193

Do the rewrite rules still need flushing for every page addition? Unless Verbose rules are enabled (Which could be checked in that codeblock too) the rules don't change with a new page AFAIK?

#3 @ryan
17 years ago

Yeah, we should check for verbose.

#4 @ryan
17 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Let's do that in another ticket. Closing this one.

Note: See TracTickets for help on using tickets.