[wp-trac] [WordPress Trac] #35236: remove_rewrite_tag()

WordPress Trac noreply at wordpress.org
Tue Jan 5 15:32:58 UTC 2016


#35236: remove_rewrite_tag()
--------------------------------------+------------------
 Reporter:  swissspidy                |       Owner:
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  4.5
Component:  Rewrite Rules             |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------

Comment (by boonebgorges):

 Replying to [comment:3 swissspidy]:
 > Ah, thanks for pointing this out! For `WP_Rewrite::$rewritereplace` it
 is indeed important.
 >
 > For example, when you register custom post types, `'(.+)'` gets added to
 `WP_Rewrite::$rewritereplace` multiple times. We only want to remove this
 once from the array, not all occurrences.
 >
 > The positions of tags, regexes and query strings inside the arrays need
 to be in sync because we remove them that way.
 >
 > Rewrite tags are unique because you can't add one twice (it gets updated
 instead).
 >
 > I now switched to using `end()` and `assertContains()` where needed and
 added some more tests.

 Oh, interesting. Another strategy would be to stash a copy of the array
 before running `remove_rewrite_tag()`, and then compare it to the array
 after running `remove_rewrite_tag()`. But what you have here looks like it
 should work :)

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35236#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list