Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.3 support #132

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: c

env:
- MO_PHP_VERSION=7.3.2
- MO_PHP_VERSION=7.2.2
- MO_PHP_VERSION=7.1.2
- MO_PHP_VERSION=7.0.16
Expand Down
2 changes: 1 addition & 1 deletion .travis/ext_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi

if [ "$PHP_MAJOR" -eq "7" ] ;then
#ls -a $MO_EX_DIR |grep memcached || printf "\n" | $PHP_PECL install -f --ignore-errors memcached-3.0.2
ls -a $MO_EX_DIR |grep memcached || (wget http://pecl.php.net/get/memcached-3.0.2.tgz && tar xf memcached-3.0.2.tgz && cd memcached-3.0.2 && $PHP_IZE && ./configure --with-php-config=$PHP_CONF --disable-memcached-sasl && make && make install)
ls -a $MO_EX_DIR |grep memcached || (wget http://pecl.php.net/get/memcached-3.1.0.tgz && tar xf memcached-3.1.0.tgz && cd memcached-3.1.0 && $PHP_IZE && ./configure --with-php-config=$PHP_CONF --disable-memcached-sasl && make && make install)
else
#ls -a $MO_EX_DIR |grep memcached || printf "\n" | $PHP_PECL install -f --ignore-errors memcached-2.2.0
ls -a $MO_EX_DIR |grep 1memcached || (wget http://pecl.php.net/get/memcached-2.2.0.tgz && tar xf memcached-2.2.0.tgz && cd memcached-2.2.0 && $PHP_IZE && ./configure --with-php-config=$PHP_CONF --disable-memcached-sasl && make && make install)
Expand Down
4 changes: 3 additions & 1 deletion .travis/php_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ function build()
# prepare
param_general="--disable-all $param_debug"
param_sapi="--enable-cli --enable-cgi"
if [ ${version:0:3} == "7.3" ]; then
param_ext="--without-libzip"
# hack for PHP 5.2
if [ ${version:0:3} == "5.2" ]; then
elif [ ${version:0:3} == "5.2" ]; then
# pcre: run-tests.php
# spl: spl_autoload_register in trace's tests
param_ext="--with-pcre-regex --enable-spl"
Expand Down
4 changes: 1 addition & 3 deletions .travis/php_get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ logit "version: $version"
# choose source
tarfile="php-${version}.tar.bz2"

if version_ge $1 "7.2.0"; then
url="http://101.96.10.58/am1.php.net/distributions/${tarfile}"
elif version_ge $1 "5.4.0"; then
if version_ge $1 "5.4.0"; then
url="http://php.net/get/$tarfile/from/this/mirror"
else
url="http://museum.php.net/php5/$tarfile"
Expand Down
13 changes: 9 additions & 4 deletions molten.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
} \
}while(0)

#if PHP_VERSION_ID < 70300
#define MO_HASH_FLAG_PERSISTENT HASH_FLAG_PERSISTENT
#else
#define MO_HASH_FLAG_PERSISTENT IS_ARRAY_PERSISTENT
#endif

PHP_FUNCTION(molten_curl_setopt);
PHP_FUNCTION(molten_curl_exec);
Expand Down Expand Up @@ -176,16 +181,16 @@ static void molten_reload_curl_function()
orig->common.fn_flags = ZEND_ACC_PUBLIC;
//Set orig handle
if(!strcmp(p->orig_func,"curl_setopt")) {
origin_curl_setopt = pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT);
origin_curl_setopt = pemalloc(sizeof(zend_internal_function), MO_HASH_FLAG_PERSISTENT);
memcpy(origin_curl_setopt, orig, sizeof(zend_internal_function));
} else if (!strcmp(p->orig_func,"curl_exec")) {
origin_curl_exec = pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT);
origin_curl_exec = pemalloc(sizeof(zend_internal_function), MO_HASH_FLAG_PERSISTENT);
memcpy(origin_curl_exec, orig, sizeof(zend_internal_function));
} else if (!strcmp(p->orig_func,"curl_setopt_array")) {
origin_curl_setopt_array = pemalloc(sizeof(zend_internal_function) , HASH_FLAG_PERSISTENT);
origin_curl_setopt_array = pemalloc(sizeof(zend_internal_function) , MO_HASH_FLAG_PERSISTENT);
memcpy(origin_curl_setopt_array, orig, sizeof(zend_internal_function));
} else if (!strcmp(p->orig_func,"curl_reset")) {
origin_curl_reset = pemalloc(sizeof(zend_internal_function), HASH_FLAG_PERSISTENT);
origin_curl_reset = pemalloc(sizeof(zend_internal_function), MO_HASH_FLAG_PERSISTENT);
memcpy(origin_curl_reset, orig, sizeof(zend_internal_function));
}
function_add_ref(orig);
Expand Down
4 changes: 4 additions & 0 deletions php7_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ static inline void mo_array_merge(zval *dest, zval *src TSRMLS_DC)
static inline void array_init_persist(zval *arg ZEND_FILE_LINE_DC)
{
ZVAL_NEW_PERSISTENT_ARR(arg);
#if PHP_VERSION_ID < 70300
_zend_hash_init(Z_ARRVAL_P(arg), 0, ZVAL_PTR_DTOR, 1 ZEND_FILE_LINE_RELAY_CC);
#else
_zend_hash_init(Z_ARRVAL_P(arg), 0, ZVAL_PTR_DTOR, 1);
#endif
}

static inline void array_free_persist(zval *arg)
Expand Down
4 changes: 2 additions & 2 deletions tests/bug_connect_error_db_7.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Warning: mysqli::query(): invalid object or resource mysqli

Warning: mysqli_connect(): (HY000/2002): %s on line 7

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line 8
Warning: mysqli_query() expects parameter 1 to be mysqli, %s given in %s on line 8

Warning: mysqli_prepare() expects parameter 1 to be mysqli, boolean given in %s on line 9
Warning: mysqli_prepare() expects parameter 1 to be mysqli, %s given in %s on line 9

Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, null given in %s on line 10

Expand Down
2 changes: 1 addition & 1 deletion tests/molten_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ include 'mysqli_execute.inc';
mysqli_exec($true_db, "select * from configs_not_exist");
?>
--EXPECTF--
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, boolean given in %s on line 10
Warning: mysqli_stmt_execute() expects parameter 1 to be mysqli_stmt, %s given in %s on line 10
{"traceId":"%s","name":"mysqli_connect","version":"%s","id":"%s","parentId":"%s","timestamp":%d,"duration":%d,"annotations":[{"value":"cs","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}},{"value":"cr","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}}],"binaryAnnotations":[{"key":"sa","value":"true","endpoint":{"serviceName":"mysql","ipv4":"%s","port":%d}},{"key":"db.instance","value":"%s","endpoint":{"serviceName":"test","ipv4":"%s"}}]}
{"traceId":"%s","name":"mysqli_query","version":"%s","id":"%s","parentId":"%s","timestamp":%d,"duration":%d,"annotations":[{"value":"cs","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}},{"value":"cr","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}}],"binaryAnnotations":[{"key":"db.statement","value":"select * from configs_not_exist","endpoint":{"serviceName":"test","ipv4":"%s"}},{"key":"db.type","value":"mysql","endpoint":{"serviceName":"test","ipv4":"%s"}},{"key":"sa","value":"true","endpoint":{"serviceName":"mysql","ipv4":"%s","port":%d}},{"key":"db.instance","value":"%s","endpoint":{"serviceName":"test","ipv4":"%s"}}]}
{"traceId":"%s","name":"mysqli_prepare","version":"%s","id":"%s","parentId":"%s","timestamp":%d,"duration":%d,"annotations":[{"value":"cs","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}},{"value":"cr","timestamp":%d,"endpoint":{"serviceName":"test","ipv4":"%s"}}],"binaryAnnotations":[{"key":"db.statement","value":"select * from configs_not_exist","endpoint":{"serviceName":"test","ipv4":"%s"}},{"key":"db.type","value":"mysql","endpoint":{"serviceName":"test","ipv4":"%s"}},{"key":"sa","value":"true","endpoint":{"serviceName":"mysql","ipv4":"%s","port":%d}},{"key":"db.instance","value":"%s","endpoint":{"serviceName":"test","ipv4":"%s"}}]}
Expand Down