WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#35235 closed defect (bug) (fixed)

remove_permastruct()

Reported by: swissspidy Owned by: swissspidy
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: Rewrite Rules Keywords: has-patch has-unit-tests commit
Focuses: Cc:
PR Number:

Description

As suggested in 35227#comment:3, it's worth adding a remove_permastruct() helper to make it easier cleaning up permastructs.

Attachments (2)

35235.diff (2.3 KB) - added by swissspidy 4 years ago.
35235.2.diff (3.0 KB) - added by swissspidy 4 years ago.

Download all attachments as: .zip

Change History (11)

@swissspidy
4 years ago

#1 @SergeyBiryukov
4 years ago

  • Component changed from General to Rewrite Rules

#2 @boonebgorges
4 years ago

A question about the semantics of the new function and method. remove_permastruct() will only allow for the removal of extra_permastructs, ie those that have been added via add_permastruct(). It won't be possible to use it to remove built-in, hardcoded permastructs like 'post_tag' or whatever. Is it worth considering a more descriptive name like remove_extra_permastruct()? Or is it enough to note the limitation in the documentation? (The latter seems right to me - I just want to get a second opinion on it.)

#3 follow-up: @swissspidy
4 years ago

I tried to make remove_permastruct() the counter part to add_permastruct(), so I'd suggest making this clear in the documentation for both functions ("Add/remove extra permastruct").

#4 in reply to: ↑ 3 @boonebgorges
4 years ago

Replying to swissspidy:

I tried to make remove_permastruct() the counter part to add_permastruct(), so I'd suggest making this clear in the documentation for both functions ("Add/remove extra permastruct").

This sounds good to me. Something along the following lines should work: "This function can only be used to remove permastructs that were added using add_permastruct(). Built-in permastructs cannot be removed."

@swissspidy
4 years ago

#5 @swissspidy
4 years ago

  • Keywords commit added

35235.2.diff is an updated patch with improved docs and slightly updated unit tests.

#6 @boonebgorges
4 years ago

35235.2.diff looks like a go to me.

#7 @swissspidy
4 years ago

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

In 36181:

Rewrite: Add a remove_permastruct() helper function.

It can be used to remove permastructs that were added using add_permastruct().

Fixes #35235.

#8 @dd32
4 years ago

In 36183:

Unit Tests: Fix the unit test added in [36181] to include the index in the comparison.

See #35235

#9 @DrewAPicture
4 years ago

In 36960:

Docs: Use a third-person singular verb for the DocBlock summary for remove_permastruct(), introduced in [36181].

See #35235. See #35986.

Note: See TracTickets for help on using tickets.