aaemnnosttv / wp-cli-login-command

Log in to WordPress with secure passwordless magic links.
https://aaemnnost.tv/wp-cli-commands/login/
MIT License
292 stars 47 forks source link

Fatal Error with buddyboss-platform #70

Closed jcatello closed 10 months ago

jcatello commented 11 months ago

Seems when using buddyboss-platform there is a conflict with one of their functions

PHP Fatal error:  Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "bp_member_switching_clear_olduser_cookie" not found or invalid function name in /home/nginx/domains/domain.com/public/wp-includes/class-wp-hook.php:312
Stack trace:
#0 /home/nginx/domains/domain.com/public/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
#1 /home/nginx/domains/domain.com/public/wp-includes/plugin.php(517): WP_Hook->do_action()
#2 /home/nginx/domains/domain.com/public/wp-content/mu-plugins/wp-cli-login-server.php(226): do_action()
#3 /home/nginx/domains/domain.com/public/wp-content/mu-plugins/wp-cli-login-server.php(136): WP_CLI_Login\WP_CLI_Login_Server->loginUser()
#4 /home/nginx/domains/domain.com/public/wp-content/mu-plugins/wp-cli-login-server.php(110): WP_CLI_Login\WP_CLI_Login_Server->run()
#5 /home/nginx/domains/domain.com/public/wp-content/mu-plugins/wp-cli-login-server.php(23): WP_CLI_Login\WP_CLI_Login_Server::handle()
#6 /home/nginx/domains/domain.com/public/wp-includes/class-wp-hook.php(310): WP_CLI_Login\init_server_from_request()
#7 /home/nginx/domains/domain.com/public/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters()
#8 /home/nginx/domains/domain.com/public/wp-includes/plugin.php(517): WP_Hook->do_action()
#9 /home/nginx/domains/domain.com/public/wp-settings.php(495): do_action()
#10 /home/nginx/domains/domain.com/public/wp-config.php(119): require_once('...')
#11 /home/nginx/domains/domain.com/public/wp-load.php(50): require_once('...')
#12 /home/nginx/domains/domain.com/public/wp-blog-header.php(13): require_once('...')
#13 /home/nginx/domains/domain.com/public/index.php(17): require('...')
#14 {main}
  thrown in /home/nginx/domains/domain.com/public/wp-includes/class-wp-hook.php on line 312

Files:

buddyboss-platform/bp-members/bp-members-functions.php

Function:

function bp_member_switching_clear_olduser_cookie( $clear_all = true ) {
        $auth_cookie = bp_member_switching_get_auth_cookie();
        if ( ! empty( $auth_cookie ) ) {
                array_pop( $auth_cookie );
        }
        if ( $clear_all || empty( $auth_cookie ) ) {

                /** This filter is documented in wp-includes/pluggable.php */
                if ( ! apply_filters( 'send_auth_cookies', true ) ) {
                        return;
                }

                $expire = time() - 31536000;
                setcookie( BP_MEMBER_SWITCHING_COOKIE, ' ', $expire, SITECOOKIEPATH, COOKIE_DOMAIN );
                setcookie( BP_MEMBER_SWITCHING_SECURE_COOKIE, ' ', $expire, SITECOOKIEPATH, COOKIE_DOMAIN );
                setcookie( BP_MEMBER_SWITCHING_OLDUSER_COOKIE, ' ', $expire, COOKIEPATH, COOKIE_DOMAIN );
        } else {
                if ( BP_Core_Members_Switching::secure_auth_cookie() ) {
                        $scheme = 'secure_auth';
                } else {
                        $scheme = 'auth';
                }

                $old_cookie = end( $auth_cookie );

                $old_user_id = wp_validate_auth_cookie( $old_cookie, $scheme );
                if ( $old_user_id ) {
                        $parts = wp_parse_auth_cookie( $old_cookie, $scheme );
                        bp_member_switching_set_olduser_cookie( $old_user_id, true, $parts['token'] );
                }
        }
}
aaemnnosttv commented 11 months ago

@jcatello that error is from WP trying to call a function that is hooked to the filter by name, but does not exist at the time the filter runs. It can be reproduced locally via wp shell like so:

wp> add_filter('my_filter', 'does_not_exist')
=> phar:///usr/local/bin/wp/vendor/wp-cli/shell-command/src/WP_CLI/Shell/REPL.php:52:
bool(true)
wp> apply_filters('my_filter', 'foo')
TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function "does_not_exist" not found or invalid function name in file /var/www/html/wp-includes/class-wp-hook.php on line 310
Stack trace:
  1. TypeError->() /var/www/html/wp-includes/class-wp-hook.php:310
  2. WP_Hook->apply_filters() /var/www/html/wp-includes/plugin.php:205
  3. apply_filters() phar:///usr/local/bin/wp/vendor/wp-cli/shell-command/src/WP_CLI/Shell/REPL.php:46
  4. eval() phar:///usr/local/bin/wp/vendor/wp-cli/shell-command/src/WP_CLI/Shell/REPL.php:46
  5. WP_CLI\Shell\REPL->start() phar:///usr/local/bin/wp/vendor/wp-cli/shell-command/src/Shell_Command.php:52
  6. Shell_Command->__invoke() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:100
  7. call_user_func() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php:100
  8. WP_CLI\Dispatcher\CommandFactory->WP_CLI\Dispatcher\{closure}() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:491
  9. call_user_func() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php:491
 10. WP_CLI\Dispatcher\Subcommand->invoke() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:431
 11. WP_CLI\Runner->run_command() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:454
 12. WP_CLI\Runner->run_command_and_exit() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:1269
 13. WP_CLI\Runner->start() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php:28
 14. WP_CLI\Bootstrap\LaunchRunner->process() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php:83
 15. WP_CLI\bootstrap() phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php:32
 16. include() phar:///usr/local/bin/wp/php/boot-phar.php:20
 17. include() /usr/local/bin/wp:4

They're probably hooking the function on the filter by name in one place and loading the function somewhere else so that when it's triggered by the login command that the function referenced isn't defined.

aaemnnosttv commented 10 months ago

Closing for now as this appears to be an issue in the buddyboss-platform plugin.