Fixes #644 Use PHP 7.4 with stable JPEG support

This commit is contained in:
cytopia 2019-11-20 11:28:25 +01:00
parent f4ddbfb15e
commit 2b58cb5153
No known key found for this signature in database
GPG Key ID: 6D56EDB8695128A2
10 changed files with 90 additions and 258 deletions

View File

@ -61,8 +61,11 @@ logs:
###
###
test-smoke-modules:
$(PWD)/tests/curl-vhosts.sh "modules"
$(PWD)/tests/php-vhosts.sh "modules"
$(PWD)/tests/modules-curl-vhosts.sh "modules"
$(PWD)/tests/modules-php-vhosts.sh "modules"
$(PWD)/tests/modules-fetch-tests.sh "modules-external"
$(PWD)/tests/modules-curl-vhosts.sh "modules-external"
$(PWD)/tests/modules-php-vhosts.sh "modules-external"
###

View File

@ -18,7 +18,7 @@ DISABLED_VERSIONS=()
echo
echo "# --------------------------------------------------------------------------------------------------"
echo "# [curl] ${1:-}"
echo "# [modules] curl ${1:-}"
echo "# --------------------------------------------------------------------------------------------------"
echo
@ -74,7 +74,7 @@ TLD_SUFFIX="$( "${SCRIPT_PATH}/../scripts/env-getvar.sh" "TLD_SUFFIX" )"
###
### Get vhost files
###
FILES="$( find "${TESTS}" -name '*.php' | sort )"
FILES="$( cd "${TESTS}" && find . -name '*.php' | sort )"
ERRORS=0
@ -85,9 +85,13 @@ echo "#-------------------------------------------------------------------------
echo
for file in ${FILES}; do
name="$( basename "${file}" )"
name="${file#./}"
if ! run "curl -sS --fail --header 'Host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/${name}' | tac | tac | grep -E '^OK$' >/dev/null" "${RETRIES}"; then
if ! run "curl -sS --fail --header 'Host: ${VHOST}.${TLD_SUFFIX}' -o /dev/null -I -w '%{http_code}' 'http://localhost:${HOST_PORT_HTTPD}/${name}' | tac | tac | grep -E '200'" "${RETRIES}"; then
run "curl -sS --header 'Host: ${VHOST}.${TLD_SUFFIX}' -o /dev/null -I -w '%{http_code}' 'http://localhost:${HOST_PORT_HTTPD}/${name}' || true"
ERRORS="$(( ERRORS + 1))"
fi
if ! run "curl -sS --fail --header 'Host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/${name}' | tac | tac | grep -E '^(OK|SKIP)$'" "${RETRIES}"; then
run "curl -sS --header 'Host: ${VHOST}.${TLD_SUFFIX}' 'http://localhost:${HOST_PORT_HTTPD}/${name}'"
ERRORS="$(( ERRORS + 1))"
fi
@ -105,14 +109,18 @@ echo "#-------------------------------------------------------------------------
echo
for file in ${FILES}; do
name="$( basename "${file}" )"
name="${file#./}"
if ! run "docker-compose exec -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}/${name}' | tac | tac | grep -E '^OK$' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then
run "docker-compose exec -T php curl 'http://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}/${name}'" "1" "${DVLBOX_PATH}"
if ! run "docker-compose exec -T php curl -sS --fail -o /dev/null -I -w '%{http_code}' 'http://${VHOST}.${TLD_SUFFIX}/${name}' | tac | tac | grep -E '200'" "${RETRIES}" "${DVLBOX_PATH}"; then
run "docker-compose exec -T php curl -sS -o /dev/null -I -w '%{http_code}' 'http://${VHOST}.${TLD_SUFFIX}/${name}'" "1" "${DVLBOX_PATH}"
ERRORS="$(( ERRORS + 1))"
fi
if ! run_fail "docker-compose exec -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}/${name}' 2>&1 | tac | tac | grep -Ei 'fatal|except|err|war|notice' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then
run "docker-compose exec -T php curl 'http://${VHOST}.${TLD_SUFFIX}:${HOST_PORT_HTTPD}/${name}'" "1" "${DVLBOX_PATH}"
if ! run "docker-compose exec -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}/${name}' | tac | tac | grep -E '^(OK|SKIP)$'" "${RETRIES}" "${DVLBOX_PATH}"; then
run "docker-compose exec -T php curl -sS 'http://${VHOST}.${TLD_SUFFIX}/${name}'" "1" "${DVLBOX_PATH}"
ERRORS="$(( ERRORS + 1))"
fi
if ! run_fail "docker-compose exec -T php curl -sS --fail 'http://${VHOST}.${TLD_SUFFIX}/${name}' 2>&1 | tac | tac | grep -Ei 'fatal|except|err|war|notice' >/dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then
run "docker-compose exec -T php curl -sS 'http://${VHOST}.${TLD_SUFFIX}/${name}'" "1" "${DVLBOX_PATH}"
ERRORS="$(( ERRORS + 1))"
fi
done

View File

@ -0,0 +1,63 @@
#!/usr/bin/env bash
# NOTE: Parsing curl to tac to circumnvent "failed writing body"
# https://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body
set -e
set -u
set -o pipefail
SCRIPT_PATH="$( cd "$(dirname "$0")" && pwd -P )"
DVLBOX_PATH="$( cd "${SCRIPT_PATH}/../.." && pwd -P )"
# shellcheck disable=SC1090
. "${SCRIPT_PATH}/../scripts/.lib.sh"
RETRIES=10
echo
echo "# --------------------------------------------------------------------------------------------------"
echo "# [modules] fetch external tests"
echo "# --------------------------------------------------------------------------------------------------"
echo
# -------------------------------------------------------------------------------------------------
# Pre-check
# -------------------------------------------------------------------------------------------------
if [ "${#}" -ne "1" ]; then
>&2 echo "Error, requires one argument: <TEST_DIR>"
exit 1
fi
# -------------------------------------------------------------------------------------------------
# Download Test directory from PHP-FPM via SVN
# -------------------------------------------------------------------------------------------------
VHOST="${1}"
# SVN allows to download a specific directory from GitHub so it is used instead of git cmd.
# The following ensures to download the module test directory
# Where to download from
TEST_REPO="https://github.com/devilbox/docker-php-fpm"
TEST_PATH="tests/mods/modules"
# Get current PHP_FPM git tag or branch
PHP_FPM_GIT_SLUG="$( \
grep -E '^[[:space:]]+image:[[:space:]]+devilbox/php-fpm:' "${DVLBOX_PATH}/docker-compose.yml" \
| perl -p -e 's/.*(base|mods|prod|work|)-//g'
)"
# Distinguish between tag or branch and build SVN path
if [[ ${PHP_FPM_GIT_SLUG} =~ ^[.0-9]+$ ]]; then
SVN_PATH="${TEST_REPO}/tags/${PHP_FPM_GIT_SLUG}/${TEST_PATH}"
else
SVN_PATH="${TEST_REPO}/branches/${PHP_FPM_GIT_SLUG}/${TEST_PATH}"
fi
# Cleanup and fetch data
run "docker-compose exec -T --user devilbox php rm -rf /shared/httpd/${VHOST} || true" "${RETRIES}" "${DVLBOX_PATH}"
run "docker-compose exec -T --user devilbox php mkdir -p /shared/httpd/${VHOST}" "${RETRIES}" "${DVLBOX_PATH}"
run "docker-compose exec -T --user devilbox php svn checkout ${SVN_PATH} /shared/httpd/${VHOST}/htdocs" "${RETRIES}" "${DVLBOX_PATH}"

View File

@ -18,7 +18,7 @@ DISABLED_VERSIONS=()
echo
echo "# --------------------------------------------------------------------------------------------------"
echo "# [PHP cli] ${1:-}"
echo "# [modules] php ${1:-}"
echo "# --------------------------------------------------------------------------------------------------"
echo
@ -63,11 +63,11 @@ fi
###
### Get vhost files
###
FILES="$( find "${TESTS}" -name '*.php' )"
FILES="$( cd "${TESTS}" && find . -name '*.php' | sort )"
for file in ${FILES}; do
name="$( basename "${file}" )"
if ! run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} | grep -E '^OK$' > /dev/null" "${RETRIES}" "${DVLBOX_PATH}"; then
name="${file#./}"
if ! run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} | grep -E '^(OK|SKIP)$'" "${RETRIES}" "${DVLBOX_PATH}"; then
run "docker-compose exec -T --user devilbox php php /shared/httpd/${VHOST}/htdocs/${name} || true" "1" "${DVLBOX_PATH}"
exit 1
fi

View File

@ -1,26 +0,0 @@
<?php
/**
* This page should print 'OK' if everything works,
* 'FAIL' or nothing if an error occured.
*/
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
$a = '1.234';
$b = '5';
$num1 = bcadd($a, $b); // 6
$num2 = bcadd($a, $b, 4); // 6.2340
if ($num1 != 6) {
echo 'FAIL: ' . $num1;
exit(1);
}
if ($num2 != 6.2340) {
echo 'FAIL: ' . $num2;
exit(1);
}
echo 'OK';

View File

@ -1,67 +0,0 @@
<?php
/**
* This page should print 'OK' if everything works,
* 'FAIL' or nothing if an error occured.
*/
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
// Create a blank image and add some text
if ( ($im = imagecreatetruecolor(640, 480)) === FALSE ) {
echo 'FAIL: imagecreatetruecolor()';
exit(1);
}
// First we create our stamp image manually from GD
if ( ($stamp = imagecreatetruecolor(100, 70)) === FALSE ) {
echo 'FAIL: imagecreatetruecolor()';
exit(1);
}
if (!imagefilledrectangle($stamp, 0, 0, 99, 69, 0x0000FF)) {
echo 'FAIL: imagefilledrectangle()';
exit(1);
}
if (!imagefilledrectangle($stamp, 9, 9, 90, 60, 0xFFFFFF)) {
echo 'FAIL: imagefilledrectangle()';
exit(1);
}
if (!imagestring($stamp, 5, 20, 20, 'libGD', 0x0000FF)) {
echo 'FAIL: imagestring()';
exit(1);
}
if (!imagestring($stamp, 3, 20, 40, '(c) 2007-9', 0x0000FF)) {
echo 'FAIL: imagestring()';
exit(1);
}
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// Merge the stamp onto our photo with an opacity of 50%
if (!imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50)) {
echo 'FAIL: imagecopymerge()';
exit(1);
}
// Save the image to file and free memory
if (!imagejpeg($im, 'image.jpg')) {
echo 'FAIL: imagejpeg()';
exit(1);
}
if (!imagedestroy($im)) {
echo 'FAIL: imagedestroy()';
unlink('image.jpg');
exit(1);
}
// Remove image after test
unlink('image.jpg');
echo 'OK';

View File

@ -1,67 +0,0 @@
<?php
/**
* This page should print 'OK' if everything works,
* 'FAIL' or nothing if an error occured.
*/
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
// Create a blank image and add some text
if ( ($im = imagecreatetruecolor(640, 480)) === FALSE ) {
echo 'FAIL: imagecreatetruecolor()';
exit(1);
}
// First we create our stamp image manually from GD
if ( ($stamp = imagecreatetruecolor(100, 70)) === FALSE ) {
echo 'FAIL: imagecreatetruecolor()';
exit(1);
}
if (!imagefilledrectangle($stamp, 0, 0, 99, 69, 0x0000FF)) {
echo 'FAIL: imagefilledrectangle()';
exit(1);
}
if (!imagefilledrectangle($stamp, 9, 9, 90, 60, 0xFFFFFF)) {
echo 'FAIL: imagefilledrectangle()';
exit(1);
}
if (!imagestring($stamp, 5, 20, 20, 'libGD', 0x0000FF)) {
echo 'FAIL: imagestring()';
exit(1);
}
if (!imagestring($stamp, 3, 20, 40, '(c) 2007-9', 0x0000FF)) {
echo 'FAIL: imagestring()';
exit(1);
}
// Set the margins for the stamp and get the height/width of the stamp image
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp);
$sy = imagesy($stamp);
// Merge the stamp onto our photo with an opacity of 50%
if (!imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50)) {
echo 'FAIL: imagecopymerge()';
exit(1);
}
// Save the image to file and free memory
if (!imagepng($im, 'image.png')) {
echo 'FAIL: imagepng()';
exit(1);
}
if (!imagedestroy($im)) {
echo 'FAIL: imagedestroy()';
unlink('image.png');
exit(1);
}
// Remove image after test
unlink('image.png');
echo 'OK';

View File

@ -1,42 +0,0 @@
<?php
/**
* This page should print 'OK' if everything works,
* 'FAIL' or nothing if an error occured.
*/
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
// Create a blank image and add some text
if ( ($im = imagecreatetruecolor(120, 20)) === FALSE ) {
echo 'FAIL: imagecreatetruecolor()';
exit(1);
}
if ( ($text_color = imagecolorallocate($im, 233, 14, 91)) === FALSE ) {
echo 'FAIL: imagecolorallocate()';
exit(1);
}
if (!imagestring($im, 1, 5, 5, 'WebP with PHP', $text_color)) {
echo 'FAIL: imagestring()';
exit(1);
}
// Save the image
if (!imagewebp($im, 'image.webp')) {
echo 'FAIL: imagewebp()';
exit(1);
}
// Free up memory
if (!imagedestroy($im)) {
echo 'FAIL: imagedestroy()';
unlink('image.webp');
exit(1);
}
// Remove image after test
unlink('image.webp');
echo 'OK';

View File

@ -1,40 +0,0 @@
<?php
/**
* This page should print 'OK' if everything works,
* 'FAIL' or nothing if an error occured.
*/
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
/* Set width and height in proportion of genuine PHP logo */
$width = 400;
$height = 210;
/* Create an Imagick object with transparent canvas */
$img = new Imagick();
if ($img->newImage($width, $height, new ImagickPixel('transparent')) !== TRUE) {
echo 'FAIL: imagecreatetruecolor()';
exit(1);
}
/* New ImagickDraw instance for ellipse draw */
$draw = new ImagickDraw();
/* Set purple fill color for ellipse */
$draw->setFillColor('#777bb4');
/* Set ellipse dimensions */
$draw->ellipse($width / 2, $height / 2, $width / 2, $height / 2, 0, 360);
/* Draw ellipse onto the canvas */
$img->drawImage($draw);
/* Reset fill color from purple to black for text (note: we are reusing ImagickDraw object) */
$draw->setFillColor('black');
if ($img->setImageFormat('png') !== TRUE) {
echo 'FAIL: imagecreatetruecolor()';
exit(1);
}
echo 'OK';

View File

@ -95,7 +95,7 @@ services:
# PHP
# ------------------------------------------------------------
php:
image: devilbox/php-fpm:${PHP_SERVER}-work-0.92
image: devilbox/php-fpm:${PHP_SERVER}-work-0.93
hostname: php
##