[wp-trac] [WordPress Trac] #40672: Undefined property `requireForceForDelete` prevents deleting terms in Backbone.js client
WordPress Trac
noreply at wordpress.org
Fri May 5 00:38:02 UTC 2017
#40672: Undefined property `requireForceForDelete` prevents deleting terms in
Backbone.js client
----------------------------------+-----------------------------
Reporter: caercam | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.7.4
Severity: normal | Keywords:
Focuses: javascript, rest-api |
----------------------------------+-----------------------------
The REST API Backbone.js client makes it possible to delete terms using
Backbone Model's `destroy()` function. However, when it comes to models
that can't be trashed (like `Category` and `Tag`), an additional
`force=true` URL parameter is required to avoid a
`rest_trash_not_supported` error. When the Models are created from
endpoints in the `constructFromSchema()` function, a
`requireForceForDelete` property is set to `true` to have the required
`force` parameter later added to the URL.
Problem is, the `requireForceForDelete` property is only set for Models
that have a parent in their route, overriding the Model's default
`wp.api.WPApiBaseModel.initialize()` function; if the Model does not have
a parent, the default `wp.api.WPApiBaseModel.initialize()` function is
used, `requireForceForDelete` is `undefined`, and the `DELETE` API request
fails because of the missing `force` parameter.
Not sure exactly why there's a difference between Models based on whether
or not they have parents, but the end result is that it's not possible to
properly delete terms without having the `requireForceForDelete` added to
the Model before calling `destroy()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40672>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list