[wp-trac] [WordPress Trac] #40672: Undefined property `requireForceForDelete` prevents deleting terms in Backbone.js client

WordPress Trac noreply at wordpress.org
Fri May 5 14:11:06 UTC 2017


#40672: Undefined property `requireForceForDelete` prevents deleting terms in
Backbone.js client
--------------------------+-----------------------------------
 Reporter:  caercam       |       Owner:  adamsilverstein
     Type:  defect (bug)  |      Status:  assigned
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  REST API      |     Version:  4.7.4
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:  javascript, rest-api
--------------------------+-----------------------------------

Comment (by caercam):

 >To clarify, when you try to delete a Category or Tag model you can a
 failure response from the api?

 Exactly.

 >Can you provide some code snippets demonstrating what you are trying to
 do?

 {{{
 var category = new wp.api.models.Category( { id : 123 } );
 category.destroy();
 }}}

 Provided that you have the `wp-api` script loaded -- and the category
 `123` exists, or you'll normally get a 404 -- the API response will be:

 {{{
 {
     code: "rest_trash_not_supported",
     data: {
         status: 501
     },
     message: "Terms do not support trashing. Set force=true to delete."
 }
 }}}

 >I will look into why the has parent distinction is in place for the
 requireForceForDelete property. This should be based on whether the
 endpoint supports the trash, right?

 Makes sense to me. For now that's kind of hard-coded in `wp-api.js` -- see
 [https://core.trac.wordpress.org/browser/trunk/src/wp-includes/js/wp-
 api.js#L1213] -- so the only Models having the `requireForceForDelete`
 property defined are `PostRevision`, `PageRevision` and `UsersMe`. The
 other Models that support trashing shouldn't be concerned, but `Category`
 and `Tag` are made impossible to delete, unless you add the
 `requireForceForDelete` property yourself before calling `destroy()`.

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


More information about the wp-trac mailing list