[wp-trac] [WordPress Trac] #29710: Add hooks to wpdb's insert(), update(), delete() and similar methods

WordPress Trac noreply at wordpress.org
Mon Sep 22 17:34:34 UTC 2014


#29710: Add hooks to wpdb's insert(), update(), delete() and similar methods
-------------------------+------------------------------
 Reporter:  borekb       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Database     |     Version:  trunk
 Severity:  normal       |  Resolution:
 Keywords:  2nd-opinion  |     Focuses:
-------------------------+------------------------------

Comment (by nacin):

 Replying to [comment:4 borekb]:
 > Let me ask the other way around - what would be the reasons not to
 include the proposed hooks? One reason that comes to mind is that list of
 available hooks would grow. Is there anything else I'm possibly missing?
 These hooks would still greatly help us, even if there might still be
 situation where we'll need to do something extra.

 I have a strong aversion to adding low-level hooks in strange places, and
 intuition here has paid great dividends down the line as we make further
 adjustments. Placing filters on queries means we can't tweak a query
 without possibly breaking filters — this is a nightmare that we continue
 to deal with in a number of areas. The "dumb" `query` filter offers
 absolutely zero expectations for the developer as to what will be
 received.

 These are proposed transactional actions, rather than filters. This is a
 little better, but still awkward. The actual SQL for a particular query is
 a terrible way to identify it, as it could easily change in a future
 version. This means what you can actually do is limited. What do you
 actually want to do here? Parse the query with regex? That is fraught. It
 encourages bad developer behavior and is pretty much guaranteed to break
 in the future.

 You'd be better served looking one level up. Nearly all DB queries in
 WordPress, such as those performing CRUD operations for posts, comments,
 etc., have transactional hooks both before and after queries. These were
 mostly added back in 2.9 and 3.0, and happen to be used pretty extensively
 by VaultPress.

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


More information about the wp-trac mailing list