Skip to content

PHP8 extension support? #1161

@rieschl

Description

@rieschl

Bug Report

Out of curiosity I wanted to try running the test pipeline (Docker), mainly phpunit tests of one of our projects on PHP8 beta2 to see if there are any code errors, when I discovered that the MongoDB extension cannot be built in php8 because of some C errors (apparently... I don't really understand those C exceptions).

Environment

I used the Docker image php:8.0.0beta2 with pickle as replacement for pecl (pecl isn't available anymore in php8).
That's the Dockerfile

FROM php:8.0.0beta2

RUN \
    apt-get update -yqq \
    && apt-get install -y gnupg git wget zlib1g-dev zlibc zlib1g zlib1g-dev libicu-dev g++ libzip4 libzip-dev \
        unzip openssh-client libc6 libgcc1 ca-certificates lsb-release xdg-utils wget openssl \
    \
    && docker-php-ext-install zip \
    \
    && wget https://github.com/FriendsOfPHP/pickle/releases/download/v0.6.0/pickle.phar -O /usr/local/bin/pickle \
    && chmod +x /usr/local/bin/pickle \
    \
    && pickle install --defaults --no-interaction mongodb \
    && docker-php-ext-enable mongodb

Expected and Actual Behavior

Well, the expected behavior is the extension being built successfully. Instead some exceptions are thrown.
To rule out pickle as source of error I tried the same Dockerfile with php:7.4-cli without error.

Debug Log

The Docker image build process errors on pickle install --defaults --no-interaction mongodb with the following error:

2: mkdir .libs
2:  cc -I. -I/tmp/mongodb/mongodb-1.8.0 -I/tmp/pickle-df53dcc69def9406150485674c8742825c40ef02/include -I/tmp/pickle-df53dcc69def9406150485674c8742825c40ef02/main -I/tmp/mongodb/mongodb-1.8.0 -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 -I/tmp/mongodb/mongodb-1.8.0/src/libmongoc/src/common/ -I/tmp/mongodb/mongodb-1.8.0/src/libmongoc/src/libbson/src/ -I/tmp/mongodb/mongodb-1.8.0/src/libmongoc/src/libbson/src/jsonsl/ -I/tmp/mongodb/mongodb-1.8.0/src/libmongoc/src/libmongoc/src/ -I/tmp/mongodb/mongodb-1.8.0/src/BSON/ -I/tmp/mongodb/mongodb-1.8.0/src/MongoDB/ -I/tmp/mongodb/mongodb-1.8.0/src/MongoDB/Exception/ -I/tmp/mongodb/mongodb-1.8.0/src/MongoDB/Monitoring/ -I/tmp/mongodb/mongodb-1.8.0/src/contrib/ -DHAVE_CONFIG_H -g -O2 -c /tmp/mongodb/mongodb-1.8.0/php_phongo.c  -fPIC -DPIC -o .libs/php_phongo.o
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c: In function 'php_phongo_dispatch_handlers':
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:2315:20: warning: passing argument 1 of 'zend_call_method' from incompatible pointer type [-Wincompatible-pointer-types]
2:    zend_call_method(value, NULL, NULL, name, strlen(name), NULL, 1, z_event, NULL);
2:                     ^~~~~
2: In file included from /tmp/mongodb/mongodb-1.8.0/php_phongo.c:27:
2: /usr/local/include/php/Zend/zend_interfaces.h:41:16: note: expected 'zend_object *' {aka 'struct _zend_object *'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
2:  ZEND_API zval* zend_call_method(zend_object *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval, uint32_t param_count, zval* arg1, zval* arg2);
2:                 ^~~~~~~~~~~~~~~~
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c: In function 'php_phongo_command_failed':
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:2401:52: warning: passing argument 2 of 'zend_update_property_string' from incompatible pointer type [-Wincompatible-pointer-types]
2:   zend_update_property_string(default_exception_ce, &p_event->z_error, ZEND_STRL("message"), tmp_error.message);
2:                                                     ^~~~~~~~~~~~~~~~~
2: In file included from /usr/local/include/php/main/php.h:35,
2:                  from /tmp/mongodb/mongodb-1.8.0/php_phongo.c:22:
2: /usr/local/include/php/Zend/zend_API.h:390:81: note: expected 'zend_object *' {aka 'struct _zend_object *'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
2:  ZEND_API void zend_update_property_string(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, const char *value);
2:                                                                     ~~~~~~~~~~~~~^~~~~~
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:2402:50: warning: passing argument 2 of 'zend_update_property_long' from incompatible pointer type [-Wincompatible-pointer-types]
2:   zend_update_property_long(default_exception_ce, &p_event->z_error, ZEND_STRL("code"), tmp_error.code);
2:                                                   ^~~~~~~~~~~~~~~~~
2: In file included from /usr/local/include/php/main/php.h:35,
2:                  from /tmp/mongodb/mongodb-1.8.0/php_phongo.c:22:
2: /usr/local/include/php/Zend/zend_API.h:387:79: note: expected 'zend_object *' {aka 'struct _zend_object *'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
2:  ZEND_API void zend_update_property_long(zend_class_entry *scope, zend_object *object, const char *name, size_t name_length, zend_long value);
2:                                                                   ~~~~~~~~~~~~~^~~~~~
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c: In function 'php_phongo_extract_handshake_data':
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:2544:55: error: expected ')' before 'TSRMLS_CC'
2:    phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"%s\" handshake option to be a string, %s given", key, PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(zvalue));
2:                                                        ^~~~~~~~~~
2:                                                        )
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:2544:3: error: too few arguments to function 'phongo_throw_exception'
2:    phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"%s\" handshake option to be a string, %s given", key, PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(zvalue));
2:    ^~~~~~~~~~~~~~~~~~~~~~
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:185:6: note: declared here
2:  void phongo_throw_exception(php_phongo_error_domain_t domain, const char* format, ...)
2:       ^~~~~~~~~~~~~~~~~~~~~~
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c: In function 'php_phongo_set_handshake_data':
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:2619:56: error: expected ')' before 'TSRMLS_CC'
2:     phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"driver\" driver option to be an array, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(driver));
2:                                                         ^~~~~~~~~~
2:                                                         )
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:2619:4: error: too few arguments to function 'phongo_throw_exception'
2:     phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Expected \"driver\" driver option to be an array, %s given", PHONGO_ZVAL_CLASS_OR_TYPE_NAME_P(driver));
2:     ^~~~~~~~~~~~~~~~~~~~~~
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:185:6: note: declared here
2:  void phongo_throw_exception(php_phongo_error_domain_t domain, const char* format, ...)
2:       ^~~~~~~~~~~~~~~~~~~~~~
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c: In function 'php_phongo_std_get_gc':
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:3523:33: warning: passing argument 1 of 'zend_std_get_properties' from incompatible pointer type [-Wincompatible-pointer-types]
2:   return zend_std_get_properties(object);
2:                                  ^~~~~~
2: In file included from /usr/local/include/php/Zend/zend.h:366,
2:                  from /usr/local/include/php/main/php.h:31,
2:                  from /tmp/mongodb/mongodb-1.8.0/php_phongo.c:22:
2: /usr/local/include/php/Zend/zend_object_handlers.h:191:21: note: expected 'zend_object *' {aka 'struct _zend_object *'} but argument is of type 'zval *' {aka 'struct _zval_struct *'}
2:  ZEND_API HashTable *zend_std_get_properties(zend_object *object);
2:                      ^~~~~~~~~~~~~~~~~~~~~~~
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c: In function 'zm_startup_mongodb':
2: /tmp/mongodb/mongodb-1.8.0/php_phongo.c:3546:36: warning: assignment to 'zend_object_get_gc_t' {aka 'struct _zend_array * (*)(struct _zend_object *, struct _zval_struct **, int *)'} from incompatible pointer type 'HashTable * (*)(zval *, zval **, int *)' {aka 'struct _zend_array * (*)(struct _zval_struct *, struct _zval_struct **, int *)'} [-Wincompatible-pointer-types]
2:   phongo_std_object_handlers.get_gc = php_phongo_std_get_gc;
2:                                     ^
2: make: *** [Makefile:560: php_phongo.lo] Error 1

Is there something missing on my side or needs the extension some work to run on PHP8?

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions