Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Within WordPress Users list, sorting by custom s2member columns empties the list #496

Closed
bridgeport opened this issue Mar 2, 2015 · 7 comments

Comments

@bridgeport
Copy link

How to reproduce:

Search for a user, such as the admin username.

Then click any of the following columns to sort the table:

  • Paid Subscr. ID
  • EOT Time
  • Of Logins

  • Last Login Time

The results list empties.

If you were to click on any of the other following columns (while the result list is empty):

  • Username
  • Name
  • E-mail
  • Registration Date

The results list suddenly reappears.

Confirmed in Pro version v150102 and v150225

Thanks.

@jaswrks
Copy link
Contributor

jaswrks commented Mar 2, 2015

@bridgeport Thank you for the report! :-)

Hmm, I was unable to reproduce this. Did you test this in a clean installation also?

Any indication in your PHP error logs as to what may have caused an error?

@bridgeport
Copy link
Author

@jaswsinc No, I didn't test this in a clean version. I hadn't thought of that. It's not a feature I use much so I only came across it accidentally.

On a live and a mirrored test environment (with less than half a dozen dummy registered users), the same thing occurs. For me, the key to reproducing this is for something to be within the "Search Users" input box, then you sort. If you sort without doing a search, everything works fine.

For clarity, this sorts the custom columns fine:
https://www.example.com/wp-admin/users.php?orderby=s2member_last_login_time

But as soon as you add a search argument to the query string, it results in an empty list:
https://www.example.com/wp-admin/users.php?orderby=s2member_last_login_time&s=a

The "s" variable can be anything. A single letter would suffice. As long as it's not empty.

@bridgeport
Copy link
Author

Any indication in your PHP error logs as to what may have caused an error?

Forgot to answer this part. Yes, debug.log does report the following only when those particular columns are sorted and a search argument exists within the query string:

WordPress database error Unknown column 'wp_users.ID' in 'on clause' for query SELECT SQL_CALC_FOUND_ROWS DISTINCT(`wp_users`.`ID`)  FROM `wp_users`, `wp_usermeta` LEFT JOIN `wp_usermeta` `m` ON (`wp_users`.`ID` = `m`.`user_id` AND `m`.`meta_key` = 'wp_s2member_last_login_time')  WHERE `wp_users`.`ID` = `wp_usermeta`.`user_id` AND ( (`wp_users`.`user_login` LIKE '%a%' OR `wp_users`.`user_nicename` LIKE '%a%' OR `wp_users`.`display_name` LIKE '%a%' OR `wp_users`.`user_email` LIKE '%a%' OR `wp_users`.`user_url` LIKE '%a%') OR ((`wp_usermeta`.`meta_key` = 'first_name' OR `wp_usermeta`.`meta_key` = 'last_name') AND `wp_usermeta`.`meta_value` LIKE '%a%') OR (`wp_usermeta`.`meta_key` = 'wp_s2member_subscr_id' AND `wp_usermeta`.`meta_value` LIKE '%a%') OR (`wp_usermeta`.`meta_key` = 'wp_s2member_custom' AND `wp_usermeta`.`meta_value` LIKE '%a%') OR (`wp_usermeta`.`meta_key` = 'wp_s2member_custom_fields' AND `wp_usermeta`.`meta_value` LIKE '%a%')) ORDER BY CAST(`m`.`meta_value` AS UNSIGNED) ASC LIMIT 20 made by WP_Users_List_Table->prepare_items, WP_User_Query->__construct, WP_User_Query->query

@jaswrks
Copy link
Contributor

jaswrks commented Mar 2, 2015

@bridgeport Thank you! ~ I'll follow-up here once I know more.

@jaswrks
Copy link
Contributor

jaswrks commented Mar 4, 2015

Recording corrupted query for future reference:

SELECT SQL_CALC_FOUND_ROWS DISTINCT(`wp_users`.`ID`) FROM `wp_users`, `wp_usermeta` LEFT JOIN `wp_usermeta` `m` ON (`wp_users`.`ID` = `m`.`user_id` AND `m`.`meta_key` = 'wp_s2member_auto_eot_time') WHERE `wp_users`.`ID` = `wp_usermeta`.`user_id` AND ( (`wp_users`.`user_login` LIKE '%s%' OR `wp_users`.`user_nicename` LIKE '%s%' OR `wp_users`.`display_name` LIKE '%s%' OR `wp_users`.`user_email` LIKE '%s%' OR `wp_users`.`user_url` LIKE '%s%') OR ((`wp_usermeta`.`meta_key` = 'first_name' OR `wp_usermeta`.`meta_key` = 'last_name') AND `wp_usermeta`.`meta_value` LIKE '%s%') OR (`wp_usermeta`.`meta_key` = 'wp_s2member_subscr_id' AND `wp_usermeta`.`meta_value` LIKE '%s%') OR (`wp_usermeta`.`meta_key` = 'wp_s2member_custom' AND `wp_usermeta`.`meta_value` LIKE '%s%') OR (`wp_usermeta`.`meta_key` = 'wp_s2member_custom_fields' AND `wp_usermeta`.`meta_value` LIKE '%s%')) ORDER BY CAST(`m`.`meta_value` AS UNSIGNED) ASC LIMIT 20

@jaswrks
Copy link
Contributor

jaswrks commented Mar 4, 2015

Next Release Changelog:

  • (s2Member/s2Member) Bug Fix: The list of users in the WordPress Dashboard was going blank in a particular scenario where a search was attempted in concert with a sortable s2Member column. Fixed in this release. Props to @bridgeport for finding this. See also this GitHub issue if you'd like technical details.

@jaswrks
Copy link
Contributor

jaswrks commented Mar 4, 2015

@bridgeport This has been corrected. Thank you!
~ Coming in the next release.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants