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

Revive PHP 7 connector #153

Merged
merged 32 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5828dd1
Update .gitignore with generated and Vim files
Totktonada Mar 19, 2020
d1fc1fb
travis-ci: temporary reduce testing (php 7.0 only)
Totktonada Mar 16, 2020
18e3cf9
test: disable persistent connection testing
Totktonada Mar 16, 2020
da326bc
test: eliminate warning re unsafe yaml.load()
Totktonada Mar 16, 2020
ab5c8e4
test: support tarantool 1.6-2.4 in instance file
Totktonada Mar 16, 2020
7fb1ad3
test: fix connection failure test for ipv4 only env
Totktonada Mar 18, 2020
c7b5675
test: fix failed name resolution test for some envs
Totktonada Mar 18, 2020
a8e31f3
test: allow to verify all configurations locally
Totktonada Mar 18, 2020
5626040
Properly initialize Tarantool instance properties
Totktonada Mar 18, 2020
999f47a
test: remove phpunit's TAP output configuration
Totktonada Mar 26, 2020
dc89778
travis-ci: install appropriate phpunit version
Totktonada Mar 18, 2020
60d820a
test: remove phpunit.phar from the repository
Totktonada Mar 18, 2020
1c742e5
test: support phpunit-7
Totktonada Mar 19, 2020
59aa1f6
travis-ci: enable PHP 7.1 in testing
Totktonada Mar 19, 2020
623bbbf
Raise exception for update by an absent field name
Totktonada Mar 20, 2020
5deede2
test: eliminate phpunit-8 deprecation warnings
Totktonada Mar 20, 2020
0f49c1a
travis-ci: enable PHP 7.2 in testing
Totktonada Mar 20, 2020
3d0962b
Support PHP 7.3
Apr 3, 2019
27d099a
test: support phpunit-9
Totktonada Mar 23, 2020
f8f4aee
travis-ci: enable PHP 7.3 in testing
Totktonada Mar 23, 2020
08fbd78
Eliminate -Wformat warning on GCC 9.2.0
Totktonada Mar 23, 2020
2fdbe88
travis-ci: enable PHP 7.4 in testing
Totktonada Mar 24, 2020
bf6980f
test: support both Python 2 & 3 in the test runner
Totktonada Mar 24, 2020
ebeae6a
travis-ci: verify CentOS / Fedora packages
Totktonada Mar 24, 2020
9542034
build: allow to test RPM / Deb packages locally
Totktonada Mar 25, 2020
f6e968f
build/debian: enable the extension by default
Totktonada Mar 25, 2020
67c9444
travis-ci: verify Deb packages for PHP 7.0
Totktonada Mar 25, 2020
f0b3f15
build/debian: eliminate hardcoded PHP 7.0 version
Totktonada Mar 25, 2020
261efae
travis-ci: verify Deb packages for PHP 7.1+
Totktonada Mar 25, 2020
9e1ebc5
test: use four spaces indentation instead of tabs
Totktonada Mar 26, 2020
cb45afa
Allow null as offset in select() with strict types
Totktonada Mar 26, 2020
f85d359
test: use strict types mode
Totktonada Mar 26, 2020
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Makefile.in
/aclocal.m4
/compile
/configure
/configure.ac
/depcomp
/install-sh
/missing
Expand All @@ -17,6 +18,7 @@ Makefile.in
/config.guess
/config.h
/config.h.in
/config.h.in~
/config.log
/config.nice
/config.status
Expand All @@ -43,4 +45,4 @@ debian/php5-tarantool.debhelper.log
debian/php5-tarantool.substvars
debian/php5-tarantool/
build
.*.swp
.*.sw[a-z]
182 changes: 130 additions & 52 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,138 @@
sudo: required
services:
- docker
os: linux
dist: xenial

language: php

php:
- 7.0
- 7.1
- nightly
# gh-151: disable tarantoo-2.2 due to lack of support the new
# _index format.
#
# Disable tarantool-1.6 and 1.7 on php 7.1-7.4, because
# php-7.[1-4]-cli docker images are based on Debian Buster, but we
# have no tarantool-1.[6-7] packages for this distribution.
jobs:
include:
# PHP 7.0
# -------
- php: 7.0
env: TARANTOOL_VERSION=1.6
- php: 7.0
env: TARANTOOL_VERSION=1.7
- php: 7.0
env: TARANTOOL_VERSION=1.9
- php: 7.0
env: TARANTOOL_VERSION=1.10
- php: 7.0
env: TARANTOOL_VERSION=2.1
# - php: 7.0
# env: TARANTOOL_VERSION=2.2
- php: 7.0
env: TARANTOOL_VERSION=2.3
- php: 7.0
env: TARANTOOL_VERSION=2.4

# PHP 7.1
# -------
- php: 7.1
env: TARANTOOL_VERSION=1.9
- php: 7.1
env: TARANTOOL_VERSION=1.10
- php: 7.1
env: TARANTOOL_VERSION=2.1
# - php: 7.1
# env: TARANTOOL_VERSION=2.2
- php: 7.1
env: TARANTOOL_VERSION=2.3
- php: 7.1
env: TARANTOOL_VERSION=2.4

# PHP 7.2
# -------
- php: 7.2
env: TARANTOOL_VERSION=1.9
- php: 7.2
env: TARANTOOL_VERSION=1.10
- php: 7.2
env: TARANTOOL_VERSION=2.1
# - php: 7.2
# env: TARANTOOL_VERSION=2.2
- php: 7.2
env: TARANTOOL_VERSION=2.3
- php: 7.2
env: TARANTOOL_VERSION=2.4

# PHP 7.3
# -------
- php: 7.3
env: TARANTOOL_VERSION=1.9
- php: 7.3
env: TARANTOOL_VERSION=1.10
- php: 7.3
env: TARANTOOL_VERSION=2.1
# - php: 7.3
# env: TARANTOOL_VERSION=2.2
- php: 7.3
env: TARANTOOL_VERSION=2.3
- php: 7.3
env: TARANTOOL_VERSION=2.4

# PHP 7.4
# -------
- php: 7.4
env: TARANTOOL_VERSION=1.9
- php: 7.4
env: TARANTOOL_VERSION=1.10
- php: 7.4
env: TARANTOOL_VERSION=2.1
# - php: 7.4
# env: TARANTOOL_VERSION=2.2
- php: 7.4
env: TARANTOOL_VERSION=2.3
- php: 7.4
env: TARANTOOL_VERSION=2.4

# RPM packages
# ------------
# Note: CentOS 6 & 7 do not provide PHP 7.*.
# Note: Fedora < 25 do not provide PHP 7.*.
- env: OS=el DIST=8
- env: OS=fedora DIST=25
- env: OS=fedora DIST=26
- env: OS=fedora DIST=27
- env: OS=fedora DIST=28
- env: OS=fedora DIST=29
- env: OS=fedora DIST=30
- env: OS=fedora DIST=31

# Deb packages
# ------------
# Debian < 8 (Stretch) do not provide PHP 7.*.
# Ubuntu < 16.04 (Xenial) do not provide PHP 7.*.
- env: OS=debian DIST=stretch
- env: OS=debian DIST=buster
- env: OS=ubuntu DIST=xenial
- env: OS=ubuntu DIST=bionic
- env: OS=ubuntu DIST=disco
- env: OS=ubuntu DIST=eoan

python:
- 2.7

cache: false

env:
global:
- PRODUCT=php-tarantool
matrix:
- OS=el DIST=6 PACK=rpm
- OS=el DIST=7 PACK=rpm
- OS=fedora DIST=22 PACK=rpm
- OS=fedora DIST=23 PACK=rpm
- OS=fedora DIST=rawhide PACK=rpm
- OS=ubuntu DIST=trusty PACK=deb
- OS=ubuntu DIST=precise PACK=deb
- OS=ubuntu DIST=wily PACK=deb
# phpize is, currently, broken on xenial. can't test, still not stable
# - OS=ubuntu DIST=xenial PACK=deb
- OS=debian DIST=jessie PACK=deb
- OS=debian DIST=wheezy PACK=deb
- OS=debian DIST=stretch PACK=deb
- OS=debian DIST=sid PACK=deb
- PACK=none

# multiple php version exclusion matrix
matrix:
fast_finish: true
allow_failures:
- env: OS=el DIST=6 PACK=rpm
- env: OS=el DIST=7 PACK=rpm
- env: OS=fedora DIST=22 PACK=rpm
- env: OS=fedora DIST=23 PACK=rpm
- env: OS=fedora DIST=rawhide PACK=rpm
- env: OS=ubuntu DIST=precise PACK=deb
- env: OS=ubuntu DIST=trusty PACK=deb
- env: OS=ubuntu DIST=wily PACK=deb
- env: OS=debian DIST=jessie PACK=deb
- env: OS=debian DIST=wheezy PACK=deb
- env: OS=debian DIST=stretch PACK=deb
- env: OS=debian DIST=sid PACK=deb

script:
- git clone https://github.com/tarantool/build.git
- bash build/pack/travis.sh

notifications:
email: true
irc: false
- |
if [ -n "${TARANTOOL_VERSION}" ]; then
./test.sh
elif [ -n "${OS}" ] && [ -n "${DIST}" ]; then
git clone --depth 1 https://github.com/packpack/packpack.git
./packpack/packpack
if [ "${OS}" = "el" ]; then
export OS=centos
fi
docker run \
--volume "$(realpath .):/tarantool-php" \
--workdir /tarantool-php \
--rm \
"${OS}:${DIST}" \
./test.pkg.sh
else
exit 1
fi
5 changes: 3 additions & 2 deletions debian/control → debian/control.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ Source: php-tarantool
Priority: optional
Maintainer: Dmitry E. Oboukhov <unera@debian.org>
Build-Depends: debhelper (>= 8),
php7.0-dev | php-all-dev,
php-all-dev,
pkg-config
Section: php
Standards-Version: 3.9.4
Homepage: https://github.com/tarantool/tarantool-php
VCS-Browser: https://github.com/tarantool/tarantool-php
VCS-Git: git://github.com/tarantool/tarantool-php.git

Package: php7.0-tarantool
# Package name is preprocessed in debian/prebuild.sh.
Package: php${phpversion}-tarantool
Architecture: any
Priority: optional
Conflicts: libtarantool-php
Expand Down
18 changes: 18 additions & 0 deletions debian/prebuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -exu # Strict shell (w/o -o pipefail)

# Preserve DEBIAN_FRONTEND=noninteractive. It prevents packages
# like tzdata from asking configuration parameters interactively.
#
# See https://github.com/packpack/packpack/issues/7
SUDO="sudo -E"

${SUDO} apt-get update > /dev/null
${SUDO} apt-get -y install php-all-dev

phpversion=$(php-config --version | sed 's/^\([0-9]\+\.[0-9]\).*/\1/')

cd /build/php-tarantool-*
sed -e "s/\${phpversion}/${phpversion}/" debian/control.in > debian/control
rm debian/control.in
25 changes: 17 additions & 8 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,32 @@

include /usr/share/cdbs/1/rules/debhelper.mk

phpapi = $(shell php-config7.0 --phpapi)
DEB_PACKAGE := $(strip $(shell egrep '^Package: ' debian/control | \
cut -f 2 -d ':'))

phpversion = $(shell echo $(DEB_PACKAGE) | \
sed -e 's/^php\([0-9.]\+\)-tarantool$$/\1/')
phpapi = $(shell php-config$(phpversion) --phpapi)
version = $(shell dpkg-parsechangelog \
|grep ^Version|awk '{print $$2}'|sed 's/-.*//')

makebuilddir/php7.0-tarantool::
makebuilddir/php$(phpversion)-tarantool::
phpize
./configure
make
echo "php:Depends=phpapi-$(phpapi)" > debian/php7.0-tarantool.substvars
echo "php:Depends=phpapi-$(phpapi)" > debian/php$(phpversion)-tarantool.substvars

install/php7.0-tarantool::
install -m 0755 -d debian/php7.0-tarantool/usr/lib/php/$(phpapi)/
install -m 0755 -d debian/php7.0-tarantool/etc/php/7.0/mods-available/
install/php$(phpversion)-tarantool::
install -m 0755 -d debian/php$(phpversion)-tarantool/usr/lib/php/$(phpapi)/
install -m 0755 -d debian/php$(phpversion)-tarantool/etc/php/$(phpversion)/mods-available/
install -m 0755 modules/tarantool.so \
debian/php7.0-tarantool/usr/lib/php/$(phpapi)/
debian/php$(phpversion)-tarantool/usr/lib/php/$(phpapi)/
echo extension=tarantool.so \
> debian/php7.0-tarantool/etc/php/7.0/mods-available/tarantool.ini
> debian/php$(phpversion)-tarantool/etc/php/$(phpversion)/mods-available/tarantool.ini
# Enable the extension.
install -m 0755 -d debian/php$(phpversion)-tarantool/etc/php/$(phpversion)/cli/conf.d
ln -s /etc/php/$(phpversion)/mods-available/tarantool.ini \
debian/php$(phpversion)-tarantool/etc/php/$(phpversion)/cli/conf.d/50-tarantool.ini

clean::
phpize --clean
Expand Down
10 changes: 5 additions & 5 deletions lib/tarantool_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,20 @@ def execute_no_reconnect(self, command):
if not command:
return
cmd = command.replace('\n', ' ') + '\n'
self.socket.sendall(cmd)
self.socket.sendall(cmd.encode())

bufsiz = 4096
res = ""
res = b""

while True:
buf = self.socket.recv(bufsiz)
if not buf:
break
res = res + buf
if (res.rfind("\n...\n") >= 0 or res.rfind("\r\n...\r\n") >= 0):
if (res.rfind(b"\n...\n") >= 0 or res.rfind(b"\r\n...\r\n") >= 0):
break

return yaml.load(res)
return yaml.safe_load(res)

class TarantoolServer(object):
default_tarantool = {
Expand Down Expand Up @@ -245,7 +245,7 @@ def start(self):
self.generate_configuration()
if self.script:
shutil.copy(self.script, self.script_dst)
os.chmod(self.script_dst, 0777)
os.chmod(self.script_dst, 0o777)
args = self.prepare_args()
self.process = subprocess.Popen(args,
cwd = self.vardir,
Expand Down
56 changes: 56 additions & 0 deletions src/php_tarantool.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,62 @@
# define smart_string_free_ex(...) smart_str_free_ex(__VA_ARGS__)
#endif

#if PHP_VERSION_ID < 70300
# define GC_SET_REFCOUNT(p, rc) do { \
GC_REFCOUNT((p)) = (rc); \
} while(0)
#endif /* PHP_VERSION_ID < 70300 */

#if PHP_VERSION_ID < 70300

# define ARRAY_PROTECT_RECURSION(data) do { \
if (Z_TYPE_P((data)) == IS_ARRAY && \
ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P((data)))) \
{ \
Z_ARRVAL_P((data))->u.v.nApplyCount++; \
} \
} while(0)

# define ARRAY_UNPROTECT_RECURSION(data) do { \
if (Z_TYPE_P((data)) == IS_ARRAY && \
ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P((data)))) \
{ \
Z_ARRVAL_P((data))->u.v.nApplyCount--; \
} \
} while(0)

# define ARRAY_IS_RECURSIVE(data) ( \
Z_TYPE_P(data) == IS_ARRAY && \
ZEND_HASH_APPLY_PROTECTION(Z_ARRVAL_P((data))) && \
Z_ARRVAL_P((data))->u.v.nApplyCount > 1 \
)

#else /* PHP_VERSION_ID < 70300 */

# define ARRAY_PROTECT_RECURSION(data) do { \
if (Z_TYPE_P((data)) == IS_ARRAY && \
!(GC_FLAGS(Z_ARRVAL_P((data))) & GC_IMMUTABLE)) \
{ \
GC_PROTECT_RECURSION(Z_ARRVAL_P((data))); \
} \
} while(0)

# define ARRAY_UNPROTECT_RECURSION(data) do { \
if (Z_TYPE_P((data)) == IS_ARRAY && \
!(GC_FLAGS(Z_ARRVAL_P((data))) & GC_IMMUTABLE)) \
{ \
GC_UNPROTECT_RECURSION(Z_ARRVAL_P((data))); \
} \
} while(0)

# define ARRAY_IS_RECURSIVE(data) ( \
Z_TYPE_P((data)) == IS_ARRAY && \
!(GC_FLAGS(Z_ARRVAL_P((data))) & GC_IMMUTABLE) && \
GC_IS_RECURSIVE(Z_ARRVAL_P((data))) \
)

#endif /* !(PHP_VERSION_ID < 70300)) */

extern zend_module_entry tarantool_module_entry;
#define phpext_tarantool_ptr &tarantool_module_entry

Expand Down
Loading