Allow some multisite illegal username characters and error get_results() on string

pennymachines
User www
User www
Posts: 79
Joined: Mon Feb 06, 2017 9:51 pm

Re: Allow some multisite illegal username characters

Post by pennymachines »

I return... :)
but sorry to report, now running 2.8.4 but still getting the error when I delete users:

Fatal error: Uncaught Error: Call to a member function get_results() on string in /home/www/mysite.com/wordpress/wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php:2067 Stack trace: #0 /home/www/mysite.com/wordpress/wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php(2114): WP_w3all_phpbb::wp_w3all_get_phpbb_user_info_by_email() #1 /home/www/mysite.com/wordpress/wp-content/plugins/wp-w3all-phpbb-integration/wp_w3all.php(1536): WP_w3all_phpbb::wp_w3all_phpbb_delete_user_signup() #2 /home/www/mysite.com/wordpress/wp-includes/class-wp-hook.php(326): w3all_remove_user_from_blog() #3 /home/www/mysite.com/wordpress/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #4 /home/www/mysite.com/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action() #5 /home/www/mysite.com/wordpress/wp-includes/ms-functions.php(246): do_action() #6 /home/www/mysite.com/wordpress/wp-admin/network/users.php(173): remove_user_from_blog() #7 {main} thrown in /home/www/mysite.com/wordpress/wp-content/plugins/wp-w3all-phpbb-integration/class.wp.w3all-phpbb.php on line 2067
User avatar
axew3
w3all User
w3all User
Posts: 2723
Joined: Fri Jan 22, 2016 5:15 pm
Location: Italy
Contact:

Re: Allow some multisite illegal username characters and error get_results() on string

Post by axew3 »

Hi! :D wow... OK! Let explain (but you already know the reason why it happen).
I will go deep on explain btw, and 2.8.5 will be released this night if possible, so to fix this, and two more secondary issues (one is about login on frontend pages, when with some plugin, the user seem to be logged out because the presented page is the login page after the login redirect, but in true the user is logged in (would be necessary to click into any link to see that it is in these cases).

About this error when on wp multisite and deleting an user (maybe it happen into more situations and it require to be definitively fixed):
Fatal error: Uncaught Error: Call to a member function get_results() on string
I assumed it was resolved, because the reason of this error, come out due to the (it is assumed) reset of all vars that are initialized when the plugin is parsed: on wp_w3all.php file, between all others, it is initialized the global var $w3all_phpbb_connection that contain as array the connection values for the phpBB db.
What it happen when we get
Fatal error: Uncaught Error: Call to a member function get_results() on string
??
the global var $w3all_phpbb_connection is somewhere overwritten and reset to be empty.
When the wp_w3all_get_phpbb_user_info_by_email($email) function is called it so return the error, because

Code: Select all

private static function w3all_db_connect(){
 global $w3all_phpbb_connection,$w3all_config_db,$w3all_config;
get an empty $w3all_phpbb_connection.

Solutions:

include a phpBB config file as it was on first plugin versions, right on the connection function, i applied it last time but after switched to the solution that get values from the db when the $w3all_phpbb_connection result to be empty:
So, into actual 2.8.4 file /class.wp.w3all-phpbb.php there this code added

Code: Select all

# get the phpBB connections values using a direct wpdb call
private static function get_w3all_config_db_if_empty(){
   global $wpdb;
   $wpdb_opt = (is_multisite()) ? WPW3ALL_MAIN_DBPREFIX . 'options' : $wpdb->prefix . 'options';
   $w3all_config_db = $wpdb->get_row("SELECT * FROM $wpdb_opt WHERE option_name = 'w3all_phpbb_dbconn'",ARRAY_A);
  if(!empty($w3all_config_db['option_value'])){
     $r = unserialize($w3all_config_db['option_value']);
   return $r;
  }
  return false;
}
and really should be not possible reason that the connection values are lost along the way. The unique reason of this, could be that not only the $w3all_phpbb_connection result to be empty at the time it is invoked, but also the $wpdb, that's very strange.
As seen by me last time into a wpms, it was empty because get_option was returning an empty value, the reason of this, into this specific configuration is still obscure to me and since it was an hard customized WP i not followed looking it.

I will test it again, and at the end a phpBB config file option can be provided.

In fact to test that it is the problem, if you change this part into actual code, on file /class.wp.w3all-phpbb.php

Code: Select all

   $w3all_config_db["dbhost"] = $dbc["w3all_phpbb_dbhost"];
   $w3all_config_db["dbport"] = $dbc["w3all_phpbb_dbport"];
   $w3all_config_db["dbname"] = $dbc["w3all_phpbb_dbname"];
   $w3all_config_db["dbuser"] = $dbc["w3all_phpbb_dbuser"];
   $w3all_config_db["dbpasswd"] = $dbc["w3all_phpbb_dbpasswd"];
   $w3all_config_db["table_prefix"] = $dbc["w3all_phpbb_dbtableprefix"];
assigning connection values manually, like so $w3all_config_db["dbname"] = 'my_db_name';
you'll see that the problem on deleting users on scenarios like your where i know the same happen (i've see the same into another mums) should result to be fixed.
See you later
Post Reply