soflyy / oxygen-bugs-and-features

Bug Reports & Feature Requests for Oxygen
https://oxygenbuilder.com/
315 stars 30 forks source link

WP-CLI wp profile causes fatal PHP error #1808

Open KittenCodes opened 3 years ago

KittenCodes commented 3 years ago

Posted by @yazzou

Hello I am trying to knwo what is delaying site load on one of the sites running with oxygen. I use WP-CLI for that with the performance tool called "profile"

whenever i tape wp profile i got this fatal php error :

PHP Fatal error: Uncaught Error: Call to a member function verify_signature() on null in /var/www/mysite.com/htdocs/wp-content/plugins/oxygen/component-framework/includes/tree-shortcodes.php:537 Stack trace:

#0 /var/www/mysite.com/htdocs/wp-content/plugins/oxygen/component-framework/component-init.php(2133): parse_shortcodes('[ct_section ct_...', false)
#1 /var/www/mysite.com/htdocs/wp-content/plugins/oxygen/component-framework/component-init.php(2103): oxygen_get_combined_shortcodes(7299)
#2 /var/www/mysite.com/htdocs/wp-content/plugins/oxygen/component-framework/includes/templates.php(12): ct_template_shortcodes()
#3 /var/www/mysite.com/htdocs/wp-content/plugins/oxygen/component-framework/component-init.php(3856): ct_template_output(true)
#4 /var/www/mysite.com/htdocs/wp-includes/class-wp-hook.php(287): ct_register_widgets('')
#5 /var/www/mysite.com/htdocs/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
#6 /var/www/mysite.com/htdocs/wp-includes/plugin.php(484): WP_Hook->do_action(Array)
#7 /var/www/mysite.com in /var/www/mysite.com/htdocs/wp-content/plugins/oxygen/component-framework/includes/tree-shortcodes.php on line 537
lynt-smitka commented 3 years ago

The problem is caused by global variables. WP-CLI calls WP inside a function, the result is oxygen global vartiables aren't global for WP-CLI (reference: https://github.com/wp-cli/wp-cli/issues/4019). You can globalize $oxygen_signature variable in the signature.class.php as a workaround. Better solution is to avoid global varaibles and replace them with some class properties, but it requires to refactor bunch of code.