[wp-trac] [WordPress Trac] #57926: WordPress WP_User_query generate SQL Problem

WordPress Trac noreply at wordpress.org
Wed Mar 15 11:04:16 UTC 2023


#57926: WordPress WP_User_query generate SQL Problem
-----------------------------+------------------------------
 Reporter:  hasanyuksektepe  |       Owner:  (none)
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  General          |     Version:  6.1.1
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+------------------------------

Comment (by craigfrancis):

 Hi Hasan,

 Just to confirm, are you looking at the SQL from `$user_query->request`?

 At this point it still uses the "placeholder escape string", which is
 (usually) a random value surrounded by "{}".

 It's used to "escape anything that resembles a printf() placeholder",
 where it's simply a search and replace for the "%" character.

 It is a bit of a weird feature, where I believe it was originally designed
 to allow the SQL string to go though `wpdb::prepare()` multiple times.

 Just before the SQL is actually sent to the database, all of these are
 converted back to a "%", via `wpdb::remove_placeholder_escape()`; and this
 is done via a 'query' filter.

 It sounds like you're doing that last step yourself, so you can run the
 SQL manually.

 To get the results normally, you can call `$user_query->get_results()`.

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


More information about the wp-trac mailing list