liexusong / php-beast

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

php7.4无法编译 #113

Open haohetao opened 5 years ago

haohetao commented 5 years ago

环境 官方docker镜像php:7.4-rc-fpm 错误信息

root@86ba035b627d:/usr/src/myapp/php-beast-master# make /bin/bash /usr/src/myapp/php-beast-master/libtool --mode=compile cc -I. -I/usr/src/myapp/php-beast-master -DPHP_ATOM_INC -I/usr/src/myapp/php-beast-master/include -I/usr/src/myapp/php-beast-master/main -I/usr/src/myapp/php-beast-master -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/src/myapp/php-beast-master/beast.c -o beast.lo mkdir .libs cc -I. -I/usr/src/myapp/php-beast-master -DPHP_ATOM_INC -I/usr/src/myapp/php-beast-master/include -I/usr/src/myapp/php-beast-master/main -I/usr/src/myapp/php-beast-master -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/src/myapp/php-beast-master/beast.c -fPIC -DPIC -o .libs/beast.o /usr/src/myapp/php-beast-master/beast.c: In function 'filter_code_comments': /usr/src/myapp/php-beast-master/beast.c:198:5: warning: implicit declaration of function 'zend_strip'; did you mean 'zend_sort'? [-Wimplicit-function-declaration] zend_strip(TSRMLS_C); ^~~~~~ zend_sort /usr/src/myapp/php-beast-master/beast.c: In function 'cgi_compile_file': /usr/src/myapp/php-beast-master/beast.c:660:20: error: 'ZEND_HANDLE_FD' undeclared (first use in this function); did you mean 'ZEND_HANDLE_FP'? if (h->type == ZEND_HANDLE_FD) close(h->handle.fd); ^~~~~~ ZEND_HANDLE_FP /usr/src/myapp/php-beast-master/beast.c:660:20: note: each undeclared identifier is reported only once for each function it appears in /usr/src/myapp/php-beast-master/beast.c:660:52: error: 'union ' has no member named 'fd'; did you mean 'fp'? if (h->type == ZEND_HANDLE_FD) close(h->handle.fd); ^~ fp /usr/src/myapp/php-beast-master/beast.c:672:19: error: 'union ' has no member named 'fd'; did you mean 'fp'? h->handle.fd = default_file_handler->get_fd(default_file_handler); ^~ fp make: *** [Makefile:191: 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;
}

`