I started suffering server crashes when using S2Member with WDesk. My host identified a bug in both products and I included their analysis below.
- Please fix this bug
Thanks
James
My WordPress installation uses S2Member.
Thanks for writing! We’re sorry to hear you’re having trouble.
We see what’s wrong. You wrote this:
By design S2Member looks for
the following code in .htaccess and if it is not present adds it.BEGIN s2Member GZIP exclusions
RewriteEngine On RewriteBase premium RewriteCond %{QUERY_STRING} (^| ?|&)s2member_file_download =.+ [OR] RewriteCond %{QUERY_STRING} (^| ?|&)no-gzip =1 RewriteRule .* - [E=no-gzip:1] # END s2Member GZIP exclusionsThis code conflicts with your hosting and causes 500 errors.
This isn’t a conflict with our hosting, though; the line “RewriteBase premium” is clearly wrong, and won’t work on any hosting. It’s supposed to be “RewriteBase /”, not “RewriteBase premium”.
We’ve looked into that for you, and the error is caused by a conflict between two plugins, “s2Member Framework” and “WSDesk - WordPress Support Desk” (the “premium” version). Both of these plugins are doing something they shouldn’t, and using them together causes this problem (it wouldn’t happen if only one or the other was used).
The technical description that you can forward to the authors of both plugins is this:
In “WSDesk - WordPress Support Desk”, the “wsdesk.php” file sets a variable called “$base” to the value “premium” at line 54:
switch (‘BASIC’) {
case ‘PREMIUM’:
$conflict = ‘basic’;
$base = ‘premium’;
It then makes that variable “global” at line 105:
function eh_crm_update_function() {
global $base;
Making it global means that its value can “leak” into other code.
In “s2Member Framework”, the
“src/includes/templates/cfg-files/s2member-files.php” file also looks for a global variable called “$base” at line 6:
global /* A Multisite $base
configuration? */ $base;
$ws_plugin__s2member_temp_s_base = (!empty($base)) ? $base : c_ws_plugin__s2member_utils_urls::parse_url (network_home_url (’/’), PHP_URL_PATH);
If it finds such a variable, it uses its contents (“premium”) instead of using the WordPress “network_home_url” value.
The bug is caused by “s2Member Framework” using a completely unexpected value of “$base” set by the unrelated “WSDesk - WordPress Support Desk”
plugin.
The solution to this is for both developers to prefix their variable names, instead of using generic names like “$base”. For example, the variable could be called “$ws_desk_base” in “WSDesk - WordPress Support Desk”, and called “$s2_member_base” in “s2Member Framework”. The WordPress programmer site says that all variables should be prefixed like that:
https://developer.wordpress.org/plugins/plugin-basics/best-practices/
If either one of these plugins followed that rule, the problem would not happen (although both of them should fix it).