laruence / yaf

Fast php framework written in c, built in php extension
http://pecl.php.net/package/yaf
Other
4.52k stars 1.38k forks source link

使用了__get魔术方法后,当action不存在的时候,php进程会被直接终止,无法捕获错误。 #582

Closed zy2701 closed 1 year ago

zy2701 commented 1 year ago

具体的情况是: 控制器使用了__get魔术方法后,当action不存在的时候,php进程会被直接终止.。 windows+apache下显示:500 Internal Server Error 同时apache会记录一条错误日志:[core:error] [pid 5664:tid 1540] [client 127.0.0.1:56787] End of script output before headers: index.php

linux+nginx下显示:502 Bad Gateway 同时nginx会记录一条错误日志:recv() failed (104: Connection reset by peer) while reading response header from upstream

相同的情况是,php都没有错误日志被记录。 希望大佬下次再更新的时候,能把这个bug给解决一下。 这个问题存在于所有yaf版本。

yunx-lee commented 1 year ago

加上 actions 成员属性就好了

<?php

use Yaf\Controller_Abstract;

class HelloController extends Controller_Abstract {

    public $actions = [
        'foo' => 'Foo',
    ];

    public function worldAction() {
        $resp = $this->getResponse();
        $resp->setBody('hello-world');
    }

    public function __get($name) {

    }

}
zy2701 commented 1 year ago

确实成功了,这个好像在文档里没有相关说明,请问一下,从哪里可以看到详细说明吗

yunx-lee commented 1 year ago

这个没发现有什么说明,只是顺着问题追踪到 zend_API.c 大概4188行 zend_read_property_ex,读取 controller 的 actions 属性时core dumped 下断点发现 直到core dumped HelloControoler::__get 方法都没有被调用

时间有限,没有深究

zy2701 commented 1 year ago

十分感谢!!!