[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 19:27:25 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 borekb):

 I fully appreciate that going low-level is risky but I guess everyone who
 handles the `'query'` filter or anything that low-level understand what
 they are doing. For our plugin (VersionPress) there's not much else we can
 do because while WordPress itself might offer suitable hooks, some complex
 3rd party plugins don't and capturing their data on the DB level is the
 best we can try.

 The question is how do we hook into that low level. The `'query'` filter
 runs before the query itself (so we don't know, for example, what was the
 ID of the inserted entity, and there are other reasons why we don't want
 our code to run before the database query itself) and is hard to work with
 anyway (the query is just a string). And after the DB query finishes, I
 don't think there is a generic action that we could hook into at all, is
 there? So we ended up creating our own `wpdb` implementation that is set
 in the `db.php` file but that just feels terrible - we are not a db
 driver, we have conflicts with other plugins that decided to use db.php
 etc. We'd just like to avoid this if at all possible.

 All I'm asking in this ticket is to have some extensibility point for devs
 like us who need to go low-level. johnbillion had a good point about how
 all those insert and update hooks might not be enough if something is
 using the `query()` method directly so I'm not 100% sure my request should
 be taken literally. But I'm glad that we're discussing low-level
 extensibility - even something like a single `'after_query'` action would
 immensely help us.

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


More information about the wp-trac mailing list