liexusong / php-beast

PHP source code encrypt module (PHP源码加密扩展)
1.71k stars 505 forks source link

php 7.4.0 下编译错误 #119

Open kakuilan opened 4 years ago

kakuilan commented 4 years ago
/usr/local/src/php-beast-master/beast.c: In function 'cgi_compile_file':
/usr/local/src/php-beast-master/beast.c:660:20: error: 'ZEND_HANDLE_FD' undeclared (first use in this function)
     if (h->type == ZEND_HANDLE_FD) close(h->handle.fd);
                    ^
/usr/local/src/php-beast-master/beast.c:660:20: note: each undeclared identifier is reported only once for each function it appears in
/usr/local/src/php-beast-master/beast.c:660:51: error: 'union <anonymous>' has no member named 'fd'
     if (h->type == ZEND_HANDLE_FD) close(h->handle.fd);
                                                   ^
/usr/local/src/php-beast-master/beast.c:672:18: error: 'union <anonymous>' has no member named 'fd'
         h->handle.fd = default_file_handler->get_fd(default_file_handler);
                  ^
make: *** [beast.lo] Error 1
abxuz commented 4 years ago

对比了下PHP7.4的代码,里面zend_stream_type这个枚举类型跟以前不一样了,没有了ZEND_HANDLE_FD这个类型。我目前的解决方案是把beast.c里面

` if (h->type == ZEND_HANDLE_FP) fclose(h->handle.fp); if (h->type == ZEND_HANDLE_FD) close(h->handle.fd);

/*
 * Get file handler and free context
 */
switch (default_file_handler->type) {
case BEAST_FILE_HANDLER_FP:
    h->type = ZEND_HANDLE_FP;
    h->handle.fp = default_file_handler->get_fp(default_file_handler);
    break;
case BEAST_FILE_HANDLER_FD:
    h->type = ZEND_HANDLE_FD;
    h->handle.fd = default_file_handler->get_fd(default_file_handler);
    break;
}

`

注释掉了部分代码,变成以下的代码,编译过去了。准备测一下好不好用。

` if (h->type == ZEND_HANDLE_FP) fclose(h->handle.fp); //if (h->type == ZEND_HANDLE_FD) close(h->handle.fd);

/*
 * Get file handler and free context
 */
switch (default_file_handler->type) {
case BEAST_FILE_HANDLER_FP:
    h->type = ZEND_HANDLE_FP;
    h->handle.fp = default_file_handler->get_fp(default_file_handler);
    break;
//case BEAST_FILE_HANDLER_FD:
    //h->type = ZEND_HANDLE_FD;
    //h->handle.fd = default_file_handler->get_fd(default_file_handler);
    //break;
}

`

shushenghong commented 4 years ago

改下来好用吗?

abxuz commented 4 years ago

@shushenghong 目前一个线上项目用下来,没有发现什么问题。

citizen233 commented 3 years ago

@kakuilan 已解决 #136