Freemius / freemius-php-sdk

https://freemius.com
22 stars 13 forks source link

Conflict if used in a WordPress site where another plugin has activated freemius wordpress sdk #14

Open alanef opened 4 years ago

alanef commented 4 years ago

If used in a wordpress site that has active plugins that use freemius wordpress-sdk there is a conflict

[17-Jan-2020 14:11:11 UTC] PHP Fatal error: Cannot make non static method Freemius_Api_Base::Test() static in class Freemius_Api_WordPress in /home/badlywi red/public_html/wp-content/plugins/fullworks-anti-spam-pro/includes/vendor/freemius/wordpress-sdk/includes/sdk/FreemiusWordPress.php on line 704 [17-Jan-2020 14:11:11 UTC] PHP Stack trace: [17-Jan-2020 14:11:11 UTC] PHP 1. {main}() /home/mydomain/public_html/wp-admin/plugins.php:0 [17-Jan-2020 14:11:11 UTC] PHP 2. require_once() /home/mydomain/public_html/wp-admin/plugins.php:10 [17-Jan-2020 14:11:11 UTC] PHP 3. do_action() /home/mydomain/public_html/wp-admin/admin.php:367 [17-Jan-2020 14:11:11 UTC] PHP 4. WP_Hook->do_action() /home/mydomain/public_html/wp-includes/plugin.php:478 [17-Jan-2020 14:11:11 UTC] PHP 5. WP_Hook->apply_filters() /home/mydomain/public_html/wp-includes/class-wp-hook.php:312 [17-Jan-2020 14:11:11 UTC] PHP 6. wp_update_plugins() /home/mydomain/public_html/wp-includes/class-wp-hook.php:288 [17-Jan-2020 14:11:11 UTC] PHP 7. set_site_transient() /home/mydomain/public_html/wp-includes/update.php:334 [17-Jan-2020 14:11:11 UTC] PHP 8. apply_filters() /home/mydomain/public_html/wp-includes/option.php:1832 [17-Jan-2020 14:11:11 UTC] PHP 9. WP_Hook->apply_filters() /home/mydomain/public_html/wp-includes/plugin.php:206 [17-Jan-2020 14:11:11 UTC] PHP 10. FS_Plugin_Updater->pre_set_site_transient_update_plugins_filter() /home/mydomain/public_html/wp-includes/class-wp-hook .php:290 [17-Jan-2020 14:11:11 UTC] PHP 11. Freemius->get_update() /home/mydomain/public_html/wp-content/plugins/fullworks-anti-spam-pro/includes/vendor/freemius/ wordpress-sdk/includes/class-fs-plugin-updater.php:517 [17-Jan-2020 14:11:11 UTC] PHP 12. Freemius->check_updates() /home/mydomain/public_html/wp-content/plugins/fullworks-anti-spam-pro/includes/vendor/freemi us/wordpress-sdk/includes/class-freemius.php:18962 [17-Jan-2020 14:11:11 UTC] PHP 13. Freemius->_fetch_newer_version() /home/mydomain/public_html/wp-content/plugins/fullworks-anti-spam-pro/includes/vendor /freemius/wordpress-sdk/includes/class-freemius.php:20514 [17-Jan-2020 14:11:11 UTC] PHP 14. Freemius->_fetch_latest_version() /home/mydomain/public_html/wp-content/plugins/fullworks-anti-spam-pro/includes/vendo r/freemius/wordpress-sdk/includes/class-freemius.php:18917 [17-Jan-2020 14:11:11 UTC] PHP 15. Freemius->get_api_site_or_plugin_scope() /home/mydomain/public_html/wp-content/plugins/fullworks-anti-spam-pro/include s/vendor/freemius/wordpress-sdk/includes/class-freemius.php:20358 [17-Jan-2020 14:11:11 UTC] PHP 16. Freemius->get_api_site_scope() /home/mydomain/public_html/wp-content/plugins/fullworks-anti-spam-pro/includes/vendor/f reemius/wordpress-sdk/includes/class-freemius.php:21644

alanef commented 4 years ago

I'll close this - it was actually a conflict with another plugin using Freemius API - needed to check class

alanef commented 4 years ago

I will re open - as it is an incompatibility betweem php-sdk and wordpress-sdk

The Freemius_Api_Base differs between SDks as in php-sdk it has a method Test but in wordpress-sdk the base classes doesnt not have a method Test - but the class Freemius_Api_WordPres extends Freemius_Api_Base with a static method Test

Ideally Freemius_Api_Base should be the same in both libraries and the Test extended in a simplar way.

mnelson4 commented 3 years ago

I just encountered this too

juanobrach commented 3 years ago

Same here!

sushmak02 commented 2 years ago

I am facing the same issue! Is there any fix available for this?

mnelson4 commented 2 years ago

My workaround was to edit the code in the Freemius PHP SDK so it was namespaced

mnelson4 commented 2 years ago

And actually, I didn’t do those changes myself. Leo from Freemius did it and sent me the modified copy. If you ask Freemius support they can send you that copy (or maybe they’ll see this is a more general issue that merits fixing more permanently.)

alanef commented 2 years ago

A better solution to name space - perhaps if should just be updated in the library here?

polevaultweb commented 2 years ago

Just encountered this too

alanef commented 2 years ago

Yes this library is unsafe to use in a wordpress site, plugin or theme - should use the WordPress SDK instead.

I only use this library on non WordPress apps where I want to access freemius data

selimmw commented 2 years ago

Same problem, Any solution?

alanef commented 2 years ago

The solution is not to use this library in WordPress use this https://github.com/Freemius/wordpress-sdk instead

selimmw commented 2 years ago

Hi @alanef Just tested the same result, what should I do now?

alanef commented 2 years ago

I don't understand what you mean. If you are not using the library in WP then you can't get the message. Have you gone through the normal steps of debugging / searching? In any case a mentioned don't use the library in WP, which means don't use any plugin or theme that incorrectly loads the library.