转到PHP7.1后,在我的Wordpress插件中获得“ PHP致命错误:Uncaught TypeError”

时间:2019-02-04 05:03:46

标签: php wordpress php-7 php-7.1

当我尝试为我的Wordpress实例安装新服务器并使用插件进行付款时,出现错误,当尝试创建运行功能时,错误为 “ PHP致命错误:未被捕获的TypeError” 可能是因为我们将实例PHP 5.6移到了具有PHP 7.1的新服务器上。 我们在Apache / PHP日志中收到此错误:

[Sat Feb 02 17:49:52.255570 2019] [php7:error] [pid 15655]
[client XXX.XX.XX.XXX:47110] PHP Fatal error:
Uncaught TypeError: Argument 1 passed to Moip\\Resource\\MoipResource::__construct()
must be an instance of Moip\\Moip, boolean given, 
called in /var/www/xxxxxxxx/www/wp-content/plugins/woo-moip-official/src/Controller/Moip_Connects.php on line 109 and defined in 
/var/www/xxxxxxxx/www/wp-content/plugins/woo-moip-official/vendor/moip/moip-sdk-php/src/Resource/MoipResource.php:56\nStack 
trace:\n#0 /var/www/xxxxxxxxx/www/wp-content/plugins/woo-moip-official/src/Controller/Moip_Connects.php(109): 
Moip\\Resource\\MoipResource->__construct(false)\n#1 /var/www/xxxxxxxx/www/wp-content/plugins/woo-moip-official/src/Controller/Moip_Connects.php(85): 
Woocommerce\\Moip\\Controller\\Moip_Connects->set_token_notification()\n#2
/var/www/xxxxxxxx/www/wp-includes/class-wp-hook.php(286): Woocommerce\\Moip\\Controller\\Moip_Connects->authorize_api('')\n#3 /var/www/xxxxxxxx/www/wp-includes/class-wp-hook.php(310):
WP_Hook->apply_filters('', Array)\n#4 /var/www/xxxxxxxx/www/wp-
includes/plugin.php(453 in /var/www/xxxxxxxx/www/wp-content/plugins/woo-moip-official/vendor/moip/moip-sdk-php/src/Resource/MoipResource.php on line 56

Moip_Connects.php中的第109行是$ webhook = new Webhook($ this-> moip_sdk-> moip);在代码中:

public function set_token_notification()
{
    try {
        $webhook  = new Webhook( $this->moip_sdk->moip );
        $response = $webhook->create();

        if ( $response->token ) {
            $this->setting->set( 'webhook_token', $response->token );
            $this->setting->set( 'webhook_id', $response->id );
        }

        unset( $webhook );

    } catch( Exception $e ) {
        error_log( $e->__toString() );
    }

}

第56行是代码中的公共函数__construct(Moip $ moip):

/*Create a new instance.
*
* @param \Moip\Moip $moip
*/
public function __construct(Moip $moip)
{
    $this->moip = $moip;
    $this->data = new stdClass();
    $this->initialize();
}

如何为PHP 7.1解决此问题?

0 个答案:

没有答案