soflyy/oxygen-bugs-and-features

Oxygen Builder conflict with Ultimate Membership Pro plugin

Opened this issue · 2 comments

Describe the bug
Hello Oxygen, We have a plugin conflict we have observed with Oxygen and WP Indeed's Ultimate Membership Pro. Both plugins work fine on their own, but when active together, they produce repeating PHP Warnings that eventually bog down our server unless we manually clear it by deleting the buildup. Even then, it just re-populates and keeps going on and on. The only way we can stop the errors from bogging down the log is to disable writing on the log, but that is not a good practice. Even then, it causes massive load on the server from all of the warnings being spit out.

See my log which is attached. You will need to view your logs on your end to see this repeating Warning as I am using an Oxygen demo site. This will happen when ONLY Oxygen and UM Pro are active together and you go clicking around the website links. What I do to test is I view all all pages one by one and the errors start multiplying within the log, sometimes not stopping and just repeating every second. I wanted to know what could be done on your end to bridge the gaps between the two plugins and possibly fix this error. Let me know if you need any more details. I added the logs, a demo site link/login, and a copy of the plugin.

SUMMARY: While these are just warnings, they cause a massive load issue on our server and interfere with functions of the plugin such as photo uploading on membership profiles. Just wanting to know if anything can be done on the Oxygen Team's end. I attached a copy of the plugin for further tests if the staging/demo site is not enough.

SANDBOX Link: https://oxygen-qtwmsz76k3zwl.oxygen-demo.qsandbox.org/
Sandbox login: https://oxygen-qtwmsz76k3zwl.oxygen-demo.qsandbox.org/wp-admin
Sandbox Username: demo
Sandbox Password: elFdMo4XB*SyX&G7p3qed%pC

RELEVANT CONTENT:

Membership Plugin:
indeed-membership-pro.zip

Error Log:
blank-demo_igvdev_net.php.error.log

Errors That Repeat:
[10-Jan-2024 19:01:06 UTC] PHP Warning: Attempt to read property "ID" on null in /home/cleweb/public_html/blank-demo/wp-content/plugins/indeed-membership-pro/public/functions.php on line 65
[10-Jan-2024 19:01:06 UTC] PHP Warning: Attempt to read property "ID" on null in /home/cleweb/public_html/blank-demo/wp-content/plugins/indeed-membership-pro/public/functions.php on line 83
[10-Jan-2024 19:01:06 UTC] PHP Warning: Attempt to read property "ID" on null in /home/cleweb/public_html/blank-demo/wp-content/plugins/indeed-membership-pro/public/functions.php on line 65
[10-Jan-2024 19:01:06 UTC] PHP Warning: Attempt to read property "ID" on null in /home/cleweb/public_html/blank-demo/wp-content/plugins/indeed-membership-pro/public/functions.php on line 83

Video Walkthrough of how I see/find the errors:
https://www.youtube.com/watch?v=301bsnUArC4

Please let me know if anything else is needed and I will see what I am able to provide!

Thank You,
Ryan

Hello @igvsupport,

The issue comes from "Indeed Ultimate Membership Pro" plugin calling the global $current_user; variable within their /public/functions.php file, which returns null when Oxygen is active. You may want to contact the developer of that plugin to see if they know any workarounds for scenarios like this.

They may contact our support team at support@oxygenbuilder.com for any Oxygen-related questions.

Hello @igvsupport,

The issue comes from "Indeed Ultimate Membership Pro" plugin calling the global $current_user; variable within their /public/functions.php file, which returns null when Oxygen is active. You may want to contact the developer of that plugin to see if they know any workarounds for scenarios like this.

They may contact our support team at support@oxygenbuilder.com for any Oxygen-related questions.

I patched this in the install.
I do not think OXYGEN is to blame here.
What I see going on is as follows:

Within wp-content/plugins/indeed-membership-pro/public/functions.php
the file /wp-includes/pluggable contains the function wp_get_current_user() does NOT actually get loaded until after the plugins are loaded.

QED: wp_get_current_user does not even exist when indeed-membership-pro attempts to fire its own ihc_test_if_must_block() function. The LOAD ORDER for WordPress was not considered when ihc_test_if_must_block() was written and called

The 'hack' I applied within : indeed-membership-pro/public/functions.php - is as follows

///////// here it the patch, dropped into line 1 of IMP functions file
add_action('init','patch_user_into_init');
function patch_user_into_init(){
    if(!function_exists('wp_get_current_user')) {
        include(ABSPATH . "wp-includes/pluggable.php");  // had to pull this in here...
    }
  $current_user = wp_get_current_user();
  return $current_user;
}
/////////


// then skip to the IMP function here: 
function ihc_test_if_must_block($block_or_show, $user_levels, $target_levels, $post_id=-1, $usedLocation='' ){

	global $current_user; // this does NOT EXIST YET because of load order

    //here is where we are going to patch this ID problem
	if(!isset($current_user->ID) || empty($current_user->ID) || $current_user->ID == NULL) {
	    $current_user = patch_user_into_init(); // errors out. yuk 
            //- fine, then I will remake using patch_user_into_init() function above
            // which works but is certainly dirty to pull in wp-includes/pluggable.php here
	}

For further context please have "Indeed Ultimate Membership Pro" plugin Author carefully examine: https://wordpress.stackexchange.com/questions/71406/is-there-a-flowchart-for-wordpress-loading-sequence

because the patch I have here is not the ideal way to handle this...