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

Install PHP5.2/5.3 on trusty #2049

Merged
merged 55 commits into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e4003ff
Install PHP5.2/5.3 on trusty
notnownikki Jul 27, 2017
c8d6e2d
Cannot request PHP5.2, request PHP7.1 and switch instead
notnownikki Jul 27, 2017
d8260ad
Work out why it's building both php versions...
notnownikki Jul 27, 2017
b1b226f
and again
notnownikki Jul 27, 2017
1b13149
tail build log to prevent travis aborting the job
notnownikki Jul 27, 2017
0c7a85a
Actually run the tail in the background this time...
notnownikki Jul 27, 2017
66dee1d
debugging again
notnownikki Jul 27, 2017
1897cab
better pre-built check, prevent phpbrew crash
notnownikki Jul 27, 2017
c8e13f7
Have a php-utils-bin dir, restore working directory after php build
notnownikki Jul 27, 2017
8aefb15
Confirm versions in the test output
notnownikki Jul 27, 2017
342d101
Make sure phpbrew is on the path
notnownikki Jul 27, 2017
46cfe03
Adding caching, so it's easier to work out why we're using the wrong …
notnownikki Jul 27, 2017
f3941b5
confirm versions in main script
notnownikki Jul 27, 2017
3860847
debugging
notnownikki Jul 27, 2017
c2305df
more debugging
notnownikki Jul 27, 2017
23ebced
even more debugging
notnownikki Jul 27, 2017
065d4f0
PHPUnit shim
notnownikki Jul 27, 2017
cc7bcb7
Path fix
notnownikki Jul 27, 2017
b437869
deeeeeeeeebug
notnownikki Jul 27, 2017
6027806
fix shim generation
notnownikki Jul 27, 2017
bf5b34c
Restore original working dir
notnownikki Jul 27, 2017
26af1ec
Echo versions used in test
notnownikki Jul 27, 2017
bf8a10e
shim fix
notnownikki Jul 27, 2017
37ac2fc
Dont use shared libs for openssl or mysql, patch openssl code to compile
notnownikki Jul 27, 2017
efcbd66
Fix patches
notnownikki Jul 27, 2017
bb4cab3
Move patches, finally get mysql compiling locally. Cry a lot.
notnownikki Jul 27, 2017
0497eeb
Re-enable the rest of the test matrix, re-enable caching
notnownikki Jul 27, 2017
773b772
Move php build/install into its own script, add patches
notnownikki Jul 27, 2017
484ca3a
phpunit shim exit with exit code of phpunit, fix revision of phpbrew
notnownikki Jul 27, 2017
dd54882
source, not spawn
notnownikki Jul 27, 2017
d87839d
Source, not spawn!
notnownikki Jul 27, 2017
bccc478
Fix relative paths
notnownikki Jul 27, 2017
658f352
Always make our utils dir
notnownikki Jul 27, 2017
2cfb5a5
do not use our phpunit shim unless running an old php version
notnownikki Jul 27, 2017
6d64fa5
Trying with old php version as well
notnownikki Jul 27, 2017
5ebf52f
Enable all tests again
notnownikki Jul 27, 2017
455e4b0
Merge branch 'master' into try/php-5-2-on-trusty
notnownikki Jul 27, 2017
a516690
Testing PHP5.3
notnownikki Jul 27, 2017
7b1346c
Enable all jobs again, enable cache for .phpbrew
notnownikki Jul 27, 2017
32c7533
Debug, cache is causing problems
notnownikki Jul 27, 2017
75d7f9f
apt-gets are failing
notnownikki Jul 27, 2017
a4f8ce9
Always install phpbrew if using old PHP
notnownikki Jul 27, 2017
e7667c3
Always install phpunit when using old PHP
notnownikki Jul 27, 2017
0abeba6
Fix path to phpunit3.6
notnownikki Jul 27, 2017
7ebc7d0
Better error checking, hopefully better caching too
notnownikki Jul 27, 2017
c2712d0
Bundle the phpbrew bashrc, better caching
notnownikki Jul 27, 2017
1c9948c
Always build both old PHPs, or we get cache races
notnownikki Jul 27, 2017
d41b45b
Reset php env after installing Symfony libs with pear under php5.2
notnownikki Jul 27, 2017
4447192
Fix order of phpbrew manual reset
notnownikki Jul 27, 2017
10ff765
Only make utils bin if using old PHP versions
notnownikki Jul 27, 2017
9309a3a
Simpler phpunit installation
notnownikki Jul 28, 2017
b973a38
Fix PHP version check
notnownikki Jul 28, 2017
d021c5d
Check phpunit catches failures
notnownikki Jul 28, 2017
5913b80
Revert phpunit fail test, add patches README
notnownikki Jul 28, 2017
6541cdb
Corrected comments in installer script
notnownikki Jul 28, 2017
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
19 changes: 8 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ cache:
directories:
- vendor
- $HOME/.composer/cache
# - $HOME/.phpbrew
# - $HOME/php-utils-bin

before_install:
- nvm install 7 && nvm use 7
Expand All @@ -22,9 +24,8 @@ matrix:
env: WP_VERSION=latest
- php: 5.6
env: WP_VERSION=latest
- php: 5.2
env: WP_VERSION=latest
dist: precise
- php: 7.1
env: WP_VERSION=latest SWITCH_TO_PHP=5.2
- php: 5.6
env: TRAVISCI=phpcs
- php: 7.1
Expand All @@ -35,14 +36,7 @@ before_script:
- |
if [[ ! -z "$WP_VERSION" ]] ; then
bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
if [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then
mkdir -p $HOME/phpunit-bin
wget -O $HOME/phpunit-bin/phpunit https://phar.phpunit.de/phpunit-4.8.phar
chmod +x $HOME/phpunit-bin/phpunit
export PATH=$PATH:$HOME/phpunit-bin/
else
composer global require "phpunit/phpunit=5.7.*"
fi
bash bin/install-php-phpunit.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this needs to be sourced rather than executed. Also, error handling? If this fails (and really the pre-existing script above as well), then it should fail the build.

fi
- |
if [[ "$TRAVISCI" == "phpcs" ]] ; then
Expand All @@ -65,6 +59,9 @@ script:
sleep .2 # Otherwise Travis doesn't want to print the whole message
exit 1
fi
echo Running with the following versions:
php -v
phpunit -v
# Check parser syntax
php lib/parser.php || exit 1
# Run PHPUnit tests
Expand Down
130 changes: 130 additions & 0 deletions bin/install-php-phpunit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
#!/bin/bash

if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]] || [[ ${SWITCH_TO_PHP:0:3} == "5.3" ]]; then
# install php runtime dependencies
sudo apt-get install -y curl libxml2 libfreetype6 libpng12-0 libjpeg8 libgd3 libxpm4 \
libltdl7 openssl gettext libgettextpo0 libmhash2 libmcrypt4 mysql-client

if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]]; then
PHPBREW_BUILT_CHECK=$HOME/.phpbrew/php/php-5.2.17/bin/php
else
PHPBREW_BUILT_CHECK=$HOME/.phpbrew/php/php-5.3.29/bin/php
fi

# php and phpunit installs should be cached, only build if they're not there.
if [ ! -f $PHPBREW_BUILT_CHECK ]; then

# install build dependencies for building php (yes, for phpbrew, php is a dependency)
sudo apt-get install -y php5-dev autoconf automake curl libcurl3-openssl-dev build-essential \
libxslt1-dev re2c libxml2-dev php5-cli bison libbz2-dev libreadline-dev libfreetype6-dev \
libpng12-dev libjpeg-dev libjpeg8-dev libgd-dev libltdl-dev libssl-dev libgettextpo-dev \
libicu-dev libmhash-dev libmcrypt-dev libmysqlclient-dev libmysqld-dev git

# install phpbrew for this user
mkdir $HOME/php-utils-bin
cd $HOME/php-utils-bin
curl -L -O https://github.com/phpbrew/phpbrew/raw/f6a422e1ba49293ee73bc4c317795c021bc57020/phpbrew
chmod +x phpbrew

# init with known --old to get 5.2 and 5.3
$HOME/php-utils-bin/phpbrew init
$HOME/php-utils-bin/phpbrew known --old

# build PHP and install PHPUnit
if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]]; then

# build PHP5.2
tail -F $HOME/.phpbrew/build/php-5.2.17/build.log &
TAIL_PID=$!
$HOME/php-utils-bin/phpbrew install --patch patches/node.patch --patch patches/openssl.patch 5.2 +default +mysql +pdo \
+gettext +phar +openssl -- --with-openssl-dir=/usr/include/openssl --enable-spl --with-mysql --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr
kill -TERM $TAIL_PID

# install PHPUnit 3.6. The only install method available is from source, using git branches old
# enough that they don't rely on any PHP5.3+ features. This clones each needed dependency
# and then we add the paths to the include_path by setting up an extra .ini file
PHP52_PATH=$HOME/.phpbrew/php/php-5.2.17
cd ${PHP52_PATH}/lib/php

# dependencies
git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/dbunit.git
git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/php-code-coverage.git
git clone --depth=1 --branch=1.3.2 git://github.com/sebastianbergmann/php-file-iterator.git
git clone --depth=1 --branch=1.1.1 git://github.com/sebastianbergmann/php-invoker.git
git clone --depth=1 --branch=1.1.2 git://github.com/sebastianbergmann/php-text-template.git
git clone --depth=1 --branch=1.0.3 git://github.com/sebastianbergmann/php-timer.git
git clone --depth=1 --branch=1.1.4 git://github.com/sebastianbergmann/php-token-stream.git
git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/phpunit-mock-objects.git
git clone --depth=1 --branch=1.1 git://github.com/sebastianbergmann/phpunit-selenium.git
git clone --depth=1 --branch=1.0.0 git://github.com/sebastianbergmann/phpunit-story.git

# and the version of phpunit that we expect to run with php 5.2
git clone --depth=1 --branch=3.6 git://github.com/sebastianbergmann/phpunit.git

# fix up the version number of phpunit
sed -i 's/@package_version@/3.6-git/g' phpunit/PHPUnit/Runner/Version.php

# now set up an ini file that adds all of the above to include_path for the PHP5.2 install
mkdir -p $HOME/.phpbrew/php/php-5.2.17/var/db
echo "include_path=.:${PHP52_PATH}/lib/php:${PHP52_PATH}/lib/php/dbunit:${PHP52_PATH}/lib/php/php-code-coverage:${PHP52_PATH}/lib/php/php-file-iterator:${PHP52_PATH}/lib/php/php-invoker:${PHP52_PATH}/lib/php/php-text-template:${PHP52_PATH}/lib/php/php-timer:${PHP52_PATH}/lib/php/php-token-stream:${PHP52_PATH}/lib/php/phpunit-mock-objects:${PHP52_PATH}/lib/php/phpunit-selenium:${PHP52_PATH}/lib/php/phpunit-story:${PHP52_PATH}/lib/php/phpunit" > ${PHP52_PATH}/var/db/path.ini

# symlink from $HOME/php-utils-bin to phpunit.php with the right version number. 'phpunit' will be aliased to this.
ln -s ${PHP52_PATH}/lib/php/phpunit/phpunit.php $HOME/php-utils-bin/phpunit-3.6

# one more PHPUnit dependency that we need to install using pear under PHP5.2
cd $HOME
export PHPBREW_RC_ENABLE=1
source $HOME/.phpbrew/bashrc
phpbrew use 5.2.17
pear channel-discover pear.symfony-project.com
pear install pear.symfony-project.com/YAML-1.0.2

else
# build PHP5.3
tail -F $HOME/.phpbrew/build/php-5.3.29/build.log &
TAIL_PID=$!
$HOME/php-utils-bin/phpbrew install --patch patches/node.patch --patch patches/openssl.patch 5.3 +default +mysql +pdo \
+gettext +phar +openssl -- --with-openssl-dir=/usr/include/openssl --enable-spl --with-mysql --with-mysqli=/usr/bin/mysql_config --with-pdo-mysql=/usr
kill -TERM $TAIL_PID
curl -L -o $HOME/php-utils-bin/phpunit-4.8 https://phar.phpunit.de/phpunit-4.8.9.phar
chmod +x $HOME/php-utils-bin/phpunit-4.8
fi
fi

# clean up build directory
rm -rf $HOME/.phpbrew/build/*

# all needed php versions and phpunit versions are installed, either from the above
# install script, or from travis cache, so switch to using them
cd $HOME
export PATH=$HOME/php-utils-bin:$PATH
export PHPBREW_RC_ENABLE=1
source $HOME/.phpbrew/bashrc
if [[ ${SWITCH_TO_PHP:0:3} == "5.2" ]]; then
# only switch if we're not already switched, or else phpbrew crashes
if [[ -z "$PHPBREW_PHP" ]]; then
phpbrew use 5.2.17
fi
alias phpunit=$HOME/php-utils-bin/phpunit-3.6
else
if [[ -z "$PHPBREW_PHP" ]]; then
phpbrew use 5.3.29
fi
alias phpunit=$HOME/php-utils-bin/phpunit-4.8
fi
elif [[ ${TRAVIS_PHP_VERSION:0:2} == "5." ]]; then
# all other PHP 5.x versions
mkdir -p $HOME/phpunit-bin
wget -O $HOME/phpunit-bin/phpunit https://phar.phpunit.de/phpunit-4.8.phar
chmod +x $HOME/phpunit-bin/phpunit
export PATH=$HOME/phpunit-bin/:$PATH
else
composer global require "phpunit/phpunit=5.7.*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be composer global require "phpunit/phpunit=6.*"

See also: https://core.trac.wordpress.org/ticket/41472

fi

# install a script that calls the right phpunit version, depending on the php version running
cp phpunit-shim.sh $HOME/php-utils-bin/phpunit
chmod +x $HOME/php-utils-bin/phpunit

# got to check our php-utils-bin first, as we're overriding travis' phpunit shim
export PATH=$HOME/php-utils-bin:$PATH
51 changes: 51 additions & 0 deletions bin/patches/node.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
--- ext/dom/node.c 2012-08-06 17:49:48.826716692 +0800
+++ ext/dom/node.c 2012-08-06 17:52:47.633484660 +0800
@@ -1895,9 +1895,17 @@ static void dom_canonicalization(INTERNA
RETVAL_FALSE;
} else {
if (mode == 0) {
+#ifdef LIBXML2_NEW_BUFFER
+ ret = xmlOutputBufferGetSize(buf);
+#else
ret = buf->buffer->use;
+#endif
if (ret > 0) {
+#ifdef LIBXML2_NEW_BUFFER
+ RETVAL_STRINGL((char *) xmlOutputBufferGetContent(buf), ret, 1);
+#else
RETVAL_STRINGL((char *) buf->buffer->content, ret, 1);
+#endif
} else {
RETVAL_EMPTY_STRING();
}
--- ext/dom/documenttype.c 2012-08-06 18:02:16.019640870 +0800
+++ ext/dom/documenttype.c 2012-08-06 18:06:16.612228905 +0800
@@ -205,7 +205,13 @@ int dom_documenttype_internal_subset_rea
if (buff != NULL) {
xmlNodeDumpOutput (buff, NULL, (xmlNodePtr) intsubset, 0, 0, NULL);
xmlOutputBufferFlush(buff);
+
+#ifdef LIBXML2_NEW_BUFFER
+ ZVAL_STRINGL(*retval, xmlOutputBufferGetContent(buff),
+ xmlOutputBufferGetSize(buff), 1);
+#else
ZVAL_STRINGL(*retval, buff->buffer->content, buff->buffer->use, 1);
+#endif
(void)xmlOutputBufferClose(buff);
return SUCCESS;
}
--- ext/simplexml/simplexml.c 2012-08-06 18:10:44.621017026 +0800
+++ ext/simplexml/simplexml.c 2012-08-06 18:12:48.016270419 +0800
@@ -1417,7 +1417,12 @@ SXE_METHOD(asXML)

xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 0, ((xmlDocPtr) sxe->document->ptr)->encoding);
xmlOutputBufferFlush(outbuf);
+#ifdef LIBXML2_NEW_BUFFER
+ RETVAL_STRINGL((char *)xmlOutputBufferGetContent(outbuf),
+ xmlOutputBufferGetSize(outbuf), 1);
+#else
RETVAL_STRINGL((char *)outbuf->buffer->content, outbuf->buffer->use, 1);
+#endif
xmlOutputBufferClose(outbuf);
}
} else {
52 changes: 52 additions & 0 deletions bin/patches/openssl.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
--- ext/openssl/xp_ssl.c
+++ ext/openssl/xp_ssl.c
@@ -328,10 +328,12 @@ static inline int php_openssl_setup_cryp
sslsock->is_client = 1;
method = SSLv23_client_method();
break;
+#ifndef OPENSSL_NO_SSL2
case STREAM_CRYPTO_METHOD_SSLv2_CLIENT:
sslsock->is_client = 1;
method = SSLv2_client_method();
break;
+#endif
case STREAM_CRYPTO_METHOD_SSLv3_CLIENT:
sslsock->is_client = 1;
method = SSLv3_client_method();
@@ -348,10 +350,12 @@ static inline int php_openssl_setup_cryp
sslsock->is_client = 0;
method = SSLv3_server_method();
break;
+#ifndef OPENSSL_NO_SSL2
case STREAM_CRYPTO_METHOD_SSLv2_SERVER:
sslsock->is_client = 0;
method = SSLv2_server_method();
break;
+#endif
case STREAM_CRYPTO_METHOD_TLS_SERVER:
sslsock->is_client = 0;
method = TLSv1_server_method();
@@ -629,9 +633,11 @@ static inline int php_openssl_tcp_sockop
case STREAM_CRYPTO_METHOD_SSLv23_CLIENT:
sock->method = STREAM_CRYPTO_METHOD_SSLv23_SERVER;
break;
+#ifndef OPENSSL_NO_SSL2
case STREAM_CRYPTO_METHOD_SSLv2_CLIENT:
sock->method = STREAM_CRYPTO_METHOD_SSLv2_SERVER;
break;
+#endif
case STREAM_CRYPTO_METHOD_SSLv3_CLIENT:
sock->method = STREAM_CRYPTO_METHOD_SSLv3_SERVER;
break;
@@ -911,9 +917,11 @@ php_stream *php_openssl_ssl_socket_facto
if (strncmp(proto, "ssl", protolen) == 0) {
sslsock->enable_on_connect = 1;
sslsock->method = STREAM_CRYPTO_METHOD_SSLv23_CLIENT;
+#ifndef OPENSSL_NO_SSL2
} else if (strncmp(proto, "sslv2", protolen) == 0) {
sslsock->enable_on_connect = 1;
sslsock->method = STREAM_CRYPTO_METHOD_SSLv2_CLIENT;
+#endif
} else if (strncmp(proto, "sslv3", protolen) == 0) {
sslsock->enable_on_connect = 1;
sslsock->method = STREAM_CRYPTO_METHOD_SSLv3_CLIENT;
13 changes: 13 additions & 0 deletions bin/phpunit-shim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

PHP_VERSION=`php -v`

if [[ ${PHP_VERSION:0:7} == "PHP 5.2" ]]; then
phpunit-3.6 "$@"
elif [[ ${PHP_VERSION:0:7} == "PHP 5.3" ]]; then
phpunit-4.8 "$@"
else
`which phpunit` "$@"
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't this need exit $? or some option-y equivalent?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it does. Will add :)


exit $?