Make WordPress Core

Opened 15 years ago

Closed 9 years ago

#11384 closed defect (bug) (duplicate)

rewrite->flush() needlessly deletes the rewrite_rules option

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.9
Component: Rewrite Rules Keywords: has-patch needs-testing needs-unit-tests
Focuses: performance Cc:

Description

All sorts of cache-related plugins hook into the update_option_rewrite_rules and force-flush whatever they're caching when rewrite_rules are updated.

When a page is saved, WP_Rewrite::flush() mindlessly deletes the rewrite_rule option, triggering all sorts of cache flushing that may or may not be necessary.

The attached patch keeps the rewrite_rules option intact when a soft refresh occurs.

Tests done:

  • non-verbose rules used, page changes parent: no refresh
  • verbose rules used, page changes parent: refresh

Dunno what else needs to be testing...

Attachments (2)

11384.diff (1.2 KB) - added by Denis-de-Bernardy 15 years ago.
11384.patch (1.1 KB) - added by brokenflipside 9 years ago.
Refreshed

Download all attachments as: .zip

Change History (13)

#1 @rmccue
14 years ago

Patch still applies cleanly.

#2 @nacin
14 years ago

  • Keywords early removed
  • Milestone changed from 3.0 to 3.1

#3 @nacin
14 years ago

  • Milestone changed from Awaiting Triage to Future Release

#4 @nacin
11 years ago

  • Component changed from Performance to Rewrite Rules
  • Focuses performance added

#6 @chriscct7
9 years ago

  • Keywords needs-refresh added

@brokenflipside
9 years ago

Refreshed

#7 follow-up: @brokenflipside
9 years ago

  • Keywords needs-testing added; needs-refresh removed

I have refreshed the patch but can't determine how to test it properly. :(

#8 in reply to: ↑ 7 @DrewAPicture
9 years ago

  • Keywords needs-unit-tests added
  • Milestone changed from Future Release to 4.5

Hi @brokenflipside, thanks for the refresh! Let's also add a changelog entry to the DocBlock for the new parameter while we're at it. More on changelogs in the core contributor handbook.

Replying to brokenflipside:

I have refreshed the patch but can't determine how to test it properly. :(

A good place to start would be phpunit/tests/rewrite.php. I'd suggest taking a look at how some of the other methods are being tested.

For example, start by declaring the $wp_rewrite global in order to access running the method, then perhaps test the existence of the option before and after the method is run.

#9 follow-up: @SergeyBiryukov
9 years ago

#29107 has a related patch, should we perhaps merge them?

#10 in reply to: ↑ 9 @swissspidy
9 years ago

Replying to SergeyBiryukov:

#29107 has a related patch, should we perhaps merge them?

I updated the patch there. Does this perhaps already fix this ticket because the option is only ever updated and not deleted?

#11 @swissspidy
9 years ago

  • Milestone 4.5 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

After [36254] I'll consider this a duplicate of #29107, as the option now never gets deleted.

Feel free to reopen if I'm wrong.

Note: See TracTickets for help on using tickets.