WeChat Pay is successful, but apache always reports the wrong Call to a member function write () on null.

72    public static function ERROR($msg)
73    {
74        $debugInfo = debug_backtrace();
75        $stack = "[";
76        foreach($debugInfo as $key => $val){
77            if(array_key_exists("file", $val)){
78                $stack .= ",file:" . $val["file"];
79            }
80            if(array_key_exists("line", $val)){
81                $stack .= ",line:" . $val["line"];
82            }
83            if(array_key_exists("function", $val)){
84                $stack .= ",function:" . $val["function"];
85            }
86        }
87        $stack .= "]";
88        self::$instance->write(8, $stack . $msg);
89    }
try{

    $tools = new JsApiPay();
    $openId = $tools->GetOpenid();

    //
    $input = new WxPayUnifiedOrder();
    $input->SetBody("test");
    $input->SetAttach("test");
    $input->SetOut_trade_no("sdkphp".date("YmdHis"));
    $input->SetTotal_fee("1");
    $input->SetTime_start(date("YmdHis"));
    $input->SetTime_expire(date("YmdHis", time() + 600));
    $input->SetGoods_tag("test");
    $input->SetNotify_url("http://www.baidu.com/sdkphp/example/notify.php");
    $input->SetTrade_type("JSAPI");
    $input->SetOpenid($openId);
    $config = new WxPayConfig();
    $order = WxPayApi::unifiedOrder($config, $input);
    $jsApiParameters = $tools->GetJsApiParameters($order);
} catch(Exception $e) {
63    Log::ERROR(json_encode($e));
}

PHP Fatal error: Uncaught Error: Call to a member function write () on null in / * * / log.php:88nStack trace:n-sharp0
/ * * / jsapi.php (63): Log::ERROR ("{}") n-sharp1 {main} n

this is the new version of WeChat Pay demo, updated in July this year. According to this prompt, there should be an error when initiating the payment, but the payment is indeed successful and the asynchronous callback is also successful. This error always appears in the apache error log a minute or two after the payment is successful. I have tried to remove the try catch when the payment was initiated, but at this time there will be other fatal error, asking for advice

.
Php
Jul.06,2021

Let me translate this passage into Chinese for you:

 Call to a member function write() on null in /**/log.php:88
null write()
What does

mean? This means that where you call write , the object instance in line 88 of log.php is null.

what causes it? It is most likely that you have not instantiated the object of this method.

that is, self::$instance this object is not instantiated.

The reason for the problem with

is that I commented out the program written to the log. Awkward

Menu