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

WordPress Trac noreply at wordpress.org
Wed Mar 15 07:17:25 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           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 The code I use is as follows.


 {{{#!php
 <?php

     $list_number = 20;
     $paged       = $_GET['paged'] ?? 1;
     if($paged == 1){
         $paged = 0;
     }
     else{
         $paged = ($paged - 1) * $list_number;
     }

     $user_arg = [
         'role__in' => ['customer'],
         'paged'    => ($paged + 1),
         'offset'   => ($paged + 1),
         'number'   => $list_number,
         'orderby'  => 'order',
         'order'    => 'DESC',
     ];

     $search_text = esc_attr(trim($_GET['s']));

     if(!empty($search_text)){
         $user_arg['search']         = '*'.$search_text.'*';
     }

     $user_query = new WP_User_Query($user_arg);

     print_r($user_query);
 }}}




 but it doesn't give me results.

 This is the sql it created.

 {{{#!sql
 SELECT SQL_CALC_FOUND_ROWS wp_users.* FROM wp_users INNER JOIN wp_usermeta
 ON ( wp_users.ID = wp_usermeta.user_id ) WHERE 1=1 AND (
   (
     ( wp_usermeta.meta_key = 'wp_capabilities' AND wp_usermeta.meta_value
 LIKE
 '{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}\"customer\"{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}'
 )
   )
 ) AND (user_login LIKE
 '{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}zua.apex{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}'
 OR user_url LIKE
 '{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}zua.apex{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}'
 OR user_email LIKE
 '{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}zua.apex{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}'
 OR user_nicename LIKE
 '{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}zua.apex{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}'
 OR display_name LIKE
 '{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}zua.apex{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}'
 OR user_url LIKE
 '{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}zua.apex{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}'
 OR display_name LIKE
 '{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}zua.apex{931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}')
 ORDER BY user_login DESC LIMIT 1, 20
 }}}

 {931f21fb875f553b7863c5e753239abe423e792b6f5ad7e8c4386d251442470c}

 I have no idea why it's making them. When I change this expression to %,
 it finds results.

 I tried changing the expressions but failed.

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


More information about the wp-trac mailing list