Merge pull request #88 from patzerr/wrapPhpClass-with-changed-namespace
authorGaetano Giunta <giunta.gaetano@gmail.com>
Wed, 8 Dec 2021 23:18:49 +0000 (00:18 +0100)
committerGitHub <noreply@github.com>
Wed, 8 Dec 2021 23:18:49 +0000 (00:18 +0100)
Made it possible to wrap namespaced classes with a different namespace

18 files changed:
.gitattributes
.github/workflows/ci.yml [new file with mode: 0644]
.travis.yml [deleted file]
NEWS
README.md
composer.json
doc/manual/phpxmlrpc_manual.adoc
lib/xmlrpc_wrappers.inc
src/Client.php
src/Value.php
tests/6HTTPTest.php
tests/ci/Dockerfile
tests/ci/docker/entrypoint.sh
tests/ci/setup/setup_apache.sh
tests/ci/setup/setup_code_coverage.sh
tests/ci/setup/setup_php.sh
tests/ci/setup/setup_php_travis.sh [deleted file]
tests/ci/vm.sh

index fdd5354..5b0bb2d 100644 (file)
@@ -4,10 +4,10 @@ demo/ export-ignore
 doc/ export-ignore
 extras/ export-ignore
 
+.github/ export-ignore
 tests/ export-ignore
 .editorconfig export-ignore
 .gitattributes export-ignore
 .gitignore export-ignore
-.travis.yml export-ignore
 pakefile.php export-ignore
 phpunit.xml.dist export-ignore
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644 (file)
index 0000000..d4d2fc9
--- /dev/null
@@ -0,0 +1,98 @@
+name: CI
+
+on: [push]
+
+jobs:
+    test:
+        runs-on: ${{ matrix.operating-system }}
+        env:
+            HTTPSERVER: localhost
+            URI: /demo/server/server.php
+            HTTPSSERVER: localhost
+            HTTPSURI: /demo/server/server.php
+            PROXYSERVER: localhost:8080
+            # @todo check: is this necessary as well on GHA runners?
+            # was: Travis currently compiles PHP with an oldish cURL/GnuTLS combination;
+            # to make the tests pass when Apache has a bogus SSL cert whe need the full set of options below.
+            HTTPSVERIFYHOST: 0
+            HTTPSIGNOREPEER: 1
+            SSLVERSION: 0
+            DEBUG: 0
+        strategy:
+            fail-fast: false
+            matrix:
+                # @see https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
+                # @todo fix: atm our tests fail when using ubuntu 20 (focal) and php 5.6 - 7.1, when using
+                #       an ssl stream context for connecting to localhost via https
+                operating-system: ['ubuntu-18.04'] # @todo add 'windows-latest'
+                # @todo use an older version of phpunit to enable testing on php 5.3 - 5.5 . Also: we will most likely
+                #       have to resort to using shivammathur/setup-php@v2 instead of sury's ppa to get php installed
+                php: ['8.1', '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6']
+        steps:
+            -
+                uses: actions/checkout@v2
+            # Although this action is useful, we prefer to use the same script to set up php that we use for the
+            # docker image used for local testing. This allows us to make sure that script is always in good shape
+            #-
+            #    uses: shivammathur/setup-php@v2
+            #    with:
+            #        php-version: ${{ matrix.php }}
+            #        extensions: curl, dom, mbstring, xsl
+            #        ini-values: 'cgi.fix_pathinfo=1, always_populate_raw_post_data=-1'
+            #        #tools: phpunit/phpunit:a_version_compatible_with_php_5.3-5.5
+            #        # NB: this disables xdebug completely
+            #        coverage: none
+            -
+                # @todo add env setup scripts for windows
+                run: |
+                    chmod 755 ./tests/ci/setup/*.sh
+                    sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_perl.sh
+                    sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_apache.sh
+                    sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_privoxy.sh
+                    sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_php.sh ${{ matrix.php }}
+                    sudo --preserve-env=GITHUB_ACTIONS ./tests/ci/setup/setup_composer.sh
+            # Avoid downloading composer deps on every workflow. Is this useful/working for us?
+            #-
+            #    uses: actions/cache@v2
+            #    with:
+            #        path: /tmp/composer-cache
+            #        key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
+            -
+                run: 'composer install'
+            -
+                if: ${{ matrix.php == '7.4' }}
+                run: |
+                    ./tests/ci/setup/setup_code_coverage.sh enable
+                    ./vendor/bin/phpunit -v --coverage-clover=coverage.clover tests
+                    wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover
+            -
+                if: ${{ matrix.php != '7.4' }}
+                run: './vendor/bin/phpunit -v tests'
+            -
+                run: 'python3 demo/client/python/test.py'
+            -
+                run: 'perl demo/client/perl/test.pl'
+            -
+                if: ${{ failure() }}
+                run: |
+                    #env
+                    #php -i
+                    #ps auxwww
+                    #dpkg --list | grep php
+                    #ps auxwww | grep fpm
+                    #pwd
+                    #sudo env
+                    #systemctl status apache2.service
+                    #ls -la /etc/apache2/mods-enabled
+                    #ls -la /etc/apache2/conf-enabled
+                    #ls -la /etc/apache2/mods-available
+                    #ls -la /etc/apache2/conf-available
+                    #ls -la /etc/apache2/sites-available/
+                    #sudo cat /etc/apache2/envvars
+                    #sudo cat /etc/apache2/sites-available/000-default.conf
+                    #ls -ltr /var/log
+                    #ls -ltr /var/log/apache2
+                    sudo cat /var/log/privoxy/*
+                    sudo cat /var/log/apache2/error.log
+                    sudo cat /var/log/apache2/other_vhosts_access.log
+                    sudo cat /var/log/php*.log
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644 (file)
index 378e3b2..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-language: php
-
-# As of May 2019, Travis is deprecating VMs based on Precise, which means that we can only test on php >= 5.6 going forward
-# (nb: this is not necessarily true yet - and we can use a different base for each php version, but we'll have to
-# adapt composer.json plus the apache / env setup scripts to accommodate that...)
-dist: xenial
-
-env:
-    global:
-        - HTTPSERVER=localhost
-        - URI=/demo/server/server.php
-        - HTTPSSERVER=localhost
-        - HTTPSURI=/demo/server/server.php
-        - PROXYSERVER=localhost:8080
-        # Travis currently compiles PHP with an oldish cURL/GnuTLS combination;
-        # to make the tests pass when Apache has a bogus SSL cert whe need the full set of options below
-        - HTTPSVERIFYHOST=0
-        - HTTPSIGNOREPEER=1
-        - SSLVERSION=0
-        - DEBUG=0
-
-php:
-  #- 5.3
-  #- 5.4
-  #- 5.5
-  - 5.6
-  - 7.0
-  - 7.1
-  - 7.2
-  - 7.3
-  - 7.4
-  - 8.0
-
-before_install:
-  # @todo stop useless daemons to save memory: snapd, dockerd, ...
-  # This is mandatory or the 'apt-get install' calls following will fail
-  - sudo apt-get update -qq
-  # Just in case there are git misconfigurations: make sure scripts are executable
-  - sudo chmod 755 ./tests/ci/setup/*.sh
-  - sudo ./tests/ci/setup/setup_perl.sh
-  - sudo ./tests/ci/setup/setup_apache.sh
-  - sudo ./tests/ci/setup/setup_privoxy.sh
-  - ./tests/ci/setup/setup_php_travis.sh
-
-install:
-  - composer install
-
-before_script:
-  # Output what version of phpunit we got going
-  #- ./vendor/bin/phpunit --version
-  # Enable code coverage for a single version of php
-  - if [ "$TRAVIS_PHP_VERSION" = "7.4" ]; then ./tests/ci/setup/setup_code_coverage.sh enable && export PHPUNIT_OPTS="--coverage-clover=coverage.clover"; fi
-
-script:
-    - ./vendor/bin/phpunit -v $PHPUNIT_OPTS tests
-    - python3 demo/client/python/test.py
-    - perl demo/client/perl/test.pl
-
-after_failure:
-  # Troubleshoot test env build problems
-  #- ps auxwww
-  #- 'sudo find /etc/php | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"'
-  #- php -i
-  #- ls -la /run/php
-  #- ls -ltr /var/log
-  #- sudo ls -ltr /var/log/apache2
-  #- 'sudo find /etc/apache2 | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"'
-
-  # Show as much info as we can to help developers
-  - sudo cat /var/log/privoxy/*
-  - sudo cat /var/log/apache2/error.log
-  - sudo cat /var/log/apache2/other_vhosts_access.log
-  - sudo cat /var/log/php*.log
-
-after_script:
-  # Upload code-coverage to Scrutinizer
-  - if [ -f coverage.clover ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
-  # Upload code-coverage CodeClimate - disabled as it does not support php 8 atm
-  #- if [ -f coverage.clover ]; then CODECLIMATE_REPO_TOKEN=7fa6ee01e345090e059e5e42f3bfbcc8692feb8340396382dd76390a3019ac13 ./vendor/bin/test-reporter --coverage-report=coverage.clover; fi
-
-# reduce depth (history) of git checkout
-git:
-    depth: 1
diff --git a/NEWS b/NEWS
index f10f1ef..edd3106 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
 XML-RPC for PHP version 4.6.0 - unreleased
 
+* fixed: compatibility with php 8.1
+
 * improved: when encoding utf8 text into us-ascii xml, use character entity references for characters number 0-31
   (ascii non printable characters), as we were already doing when encoding iso-8859-1 text into us-ascii xml
 
@@ -16,6 +18,8 @@ XML-RPC for PHP version 4.6.0 - unreleased
 
 * new: method `XMLParser::parse()` acquired a 4th argument
 
+* improved: Continuous Integration is now running on Github Actions instead of Travis
+
 
 XML-RPC for PHP version 4.5.2 - 2021/1/11
 
index c71e0f6..a8b9474 100644 (file)
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@ The full sequence of operations is:
     # and, once you have finished all testing related work:
     ./tests/ci/vm.sh cleanup
 
-By default tests are run using php 7.0 in a Container based on Ubuntu 16 Xenial.
+By default tests are run using php 7.0 in a Container based on Ubuntu 18 Bionic.
 You can change the version of PHP and Ubuntu in use by setting the environment variables PHP_VERSION and UBUNTU_VERSION
 before building the Container.
 
@@ -64,5 +64,5 @@ Use of this software is subject to the terms in the [license.txt](license.txt) f
 [![Latest Stable Version](https://poser.pugx.org/phpxmlrpc/phpxmlrpc/v/stable)](https://packagist.org/packages/phpxmlrpc/phpxmlrpc)
 [![Total Downloads](https://poser.pugx.org/phpxmlrpc/phpxmlrpc/downloads)](https://packagist.org/packages/phpxmlrpc/phpxmlrpc)
 
-[![Build Status](https://travis-ci.com/gggeek/phpxmlrpc.svg)](https://travis-ci.com/gggeek/phpxmlrpc)
+[![Build Status](https://github.com/gggeek/phpxmlrpc/actions/workflows/ci.yml/badge.svg)](https://travis-ci.com/gggeek/phpxmlrpc)
 [![Code Coverage](https://scrutinizer-ci.com/g/gggeek/phpxmlrpc/badges/coverage.png)](https://scrutinizer-ci.com/g/gggeek/phpxmlrpc)
index 04c4361..9fd5985 100644 (file)
@@ -10,7 +10,7 @@
     },
     "_comment::tests": "The dev packages below require a minimum of php 5.6, even though we support php 5.3. Can we manage to do better?",
     "require-dev": {
-        "phpunit/phpunit": "^5.0 || ^8.5.12",
+        "phpunit/phpunit": "^5.0 || ^8.5.14",
         "phpunit/phpunit-selenium": "*",
         "yoast/phpunit-polyfills": "*",
         "ext-curl": "*",
index 97f5ccd..f945537 100644 (file)
@@ -139,7 +139,7 @@ lib/*:: a compatibility layer for applications which still rely on version 3 of
 
 src/*:: the XML-RPC library classes. You can autoload these via Composer, or via a dedicated Autoloader class
 
-tests/*:: the test suite for the library, written using PhpUnit, and the configuration to run it on Travis
+tests/*:: the test suite for the library, written using PhpUnit, and the configuration to run it either on GitHub Actions or in a local Docker container
 
 
 [[bugs]]
@@ -1953,7 +1953,7 @@ Backward compatibility is maintained via _lib/xmlrpc.inc_, _lib/xmlrpcs.inc_ and
 
 * improved: a specific option allows users to decide the version of SSL to use for https calls.
   This is useful f.e. for the testing suite, when the server target of calls has no proper ssl certificate,
-  and the cURL extension has been compiled with GnuTLS (such as on Travis VMs)
+  and the cURL extension has been compiled with GnuTLS
 
 * improved: the function `wrap_php_function()` now can be used to wrap closures (it is now a method btw)
 
index cec3374..4331c36 100644 (file)
@@ -87,7 +87,7 @@ function wrap_php_class($className, $extraOptions=array())
  * @see PhpXmlRpc\Wrapper::wrapXmlrpcMethod
  * @param xmlrpc_client $client
  * @param string $methodName
- * @param int|array $extraOptions the usage of an int as signature number is deprecated, use an option in $extraOptions
+ * @param int|array $extraOptions the usage of an int as signature number is deprecated, use an option 'signum' in $extraOptions
  * @param int $timeout            deprecated, use an option in $extraOptions
  * @param string $protocol        deprecated, use an option in $extraOptions
  * @param string $newFuncName     deprecated, use an option in $extraOptions
@@ -112,8 +112,10 @@ function wrap_xmlrpc_method($client, $methodName, $extraOptions=0, $timeout=0, $
         // backwards compat: return string instead of callable
         $extraOptions['return_source'] = true;
         $wrapped = $wrapper->wrapXmlrpcMethod($client, $methodName, $extraOptions);
-        eval($wrapped['source']);
-        $wrapped = $wrapped['function'];
+        if (is_array($wrapped)) {
+            eval($wrapped['source']);
+            $wrapped = $wrapped['function'];
+        }
     } else {
         $wrapped = $wrapper->wrapXmlrpcMethod($client, $methodName, $extraOptions);
     }
index 4e03d3e..6d71c01 100644 (file)
@@ -325,7 +325,7 @@ class Client
     }
 
     /**
-     * Set attributes for SSL communication: SSL version to use. Best left at 0 (default value ): let cURL decide
+     * Set attributes for SSL communication: SSL version to use. Best left at 0 (default value): let cURL decide
      *
      * @param int $i
      */
@@ -785,6 +785,7 @@ class Client
             $contextOptions['ssl']['verify_peer'] = $this->verifypeer;
             $contextOptions['ssl']['verify_peer_name'] = $this->verifypeer;
         }
+
         $context = stream_context_create($contextOptions);
 
         if ($timeout <= 0) {
@@ -807,6 +808,7 @@ class Client
                 $err = error_get_last();
                 $this->errstr = $err['message'];
             }
+
             $this->errstr = 'Connect error: ' . $this->errstr;
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['http_error'], $this->errstr . ' (' . $this->errno . ')');
 
index 1e7e288..ec43fc1 100644 (file)
@@ -518,6 +518,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      *
      * @return integer
      */
+    #[\ReturnTypeWillChange]
     public function count()
     {
         switch ($this->mytype) {
@@ -538,6 +539,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      * @return \ArrayIterator
      * @internal required to be public to implement an Interface
      */
+    #[\ReturnTypeWillChange]
     public function getIterator()
     {
         switch ($this->mytype) {
@@ -558,6 +560,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      * @param mixed $value
      * @throws \Exception
      */
+    #[\ReturnTypeWillChange]
     public function offsetSet($offset, $value)
     {
         switch ($this->mytype) {
@@ -603,6 +606,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      * @param mixed $offset
      * @return bool
      */
+    #[\ReturnTypeWillChange]
     public function offsetExists($offset)
     {
         switch ($this->mytype) {
@@ -623,6 +627,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      * @param mixed $offset
      * @throws \Exception
      */
+    #[\ReturnTypeWillChange]
     public function offsetUnset($offset)
     {
         switch ($this->mytype) {
@@ -646,6 +651,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      * @return mixed|Value|null
      * @throws \Exception
      */
+    #[\ReturnTypeWillChange]
     public function offsetGet($offset)
     {
         switch ($this->mytype) {
index 74b8a01..ea0487b 100644 (file)
@@ -9,7 +9,7 @@ include_once __DIR__ . '/5ServerTest.php';
 
 /**
  * Tests which stress http features of the library.
- * Each of these tests iterates over (almost) all of the 'localhost' tests
+ * Each of these tests iterates over (almost) all the 'localhost' tests
  */
 class HTTPTest extends ServerTest
 {
index 15104e6..d8c4443 100644 (file)
@@ -1,4 +1,4 @@
-ARG UBUNTU_VERSION=xenial
+ARG UBUNTU_VERSION=bionic
 
 FROM ubuntu:${UBUNTU_VERSION}
 
index b2c75c3..e3565ab 100644 (file)
@@ -57,6 +57,9 @@ sed -e "s?^listen.group =.*?listen.group = ${USERNAME}?g" --in-place "${FPMCONF}
 
 echo "[$(date)] Running Composer..."
 
+# @todo if there is a composer.lock file present, there are chances it might be a leftover from when running the
+#       container using a different php version. We should then back it up / do some symlink magic to make sure that
+#       it matches the current php version and a hash of composer.json...
 sudo "${USERNAME}" -c "cd ${TESTS_ROOT_DIR} && composer install"
 
 trap clean_up TERM
index 193d399..b29cde2 100755 (executable)
@@ -2,7 +2,7 @@
 
 # Install and configure apache2
 # Has to be run as admin
-# @todo make this work across all apache versions (precise to focal)
+# @todo make this work across all ubuntu versions (precise to focal)
 
 set -e
 
@@ -11,15 +11,23 @@ SCRIPT_DIR="$(dirname -- "$(readlink -f "$0")")"
 DEBIAN_FRONTEND=noninteractive apt-get install -y apache2
 
 # set up Apache for php-fpm
-# @see https://github.com/travis-ci/travis-ci.github.com/blob/master/docs/user/languages/php.md#apache--php
 
 a2enmod rewrite proxy_fcgi setenvif ssl
 
+# in case mod-php was enabled (this is the case at least on GHA's ubuntu with php 5.x and shivammathur/setup-php)
+# @todo silence errors in a smarter way
+rm /etc/apache2/mods-enabled/php* || true
+
 # configure apache virtual hosts
 
 cp -f "$SCRIPT_DIR/../config/apache_vhost" /etc/apache2/sites-available/000-default.conf
 
-if [ -n "${TRAVIS}" ]; then
+# default apache siteaccess found in GHA Ubuntu. We remove it just in case
+if [ -f /etc/apache2/sites-available/default-ssl.conf ]; then
+    rm /etc/apache2/sites-available/default-ssl.conf
+fi
+
+if [ -n "${GITHUB_ACTIONS}" ]; then
     echo "export TESTS_ROOT_DIR=$(pwd)" >> /etc/apache2/envvars
 else
     echo "export TESTS_ROOT_DIR=/var/www/html" >> /etc/apache2/envvars
index 145de3d..11309a6 100755 (executable)
@@ -3,44 +3,25 @@
 # @todo add 'query' action
 # @todo avoid reloading php-fpm if config did not change
 
-# Note: we have php set up either via phpenv (TRAVIS=true), Ubuntu packages (PHP_VERSION=default) or Sury packages.
+# Note: we have php set up either via Ubuntu packages (PHP_VERSION=default) or Sury packages.
 #       xdebug comes either at version 2 or 3
 
 set -e
 
-if [ "$TRAVIS" != true ]; then
-    PHPCONFDIR_CLI=$(php -i | grep 'Scan this dir for additional .ini files' | sed 's|Scan this dir for additional .ini files => ||')
-    PHPCONFDIR_FPM=$(echo "$PHPCONFDIR_CLI" | sed 's|/cli/|/fpm/|')
-fi
-
 enable_cc() {
-    if [ "$TRAVIS" = true ]; then
-        phpenv config-add tests/ci/config/codecoverage_xdebug.ini
-
-        pkill php-fpm
-        ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
-    else
-        if [ -L "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"; fi
-        sudo ln -s $(realpath tests/ci/config/codecoverage_xdebug.ini) "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"
-        if [ -L "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"; fi
-        sudo ln -s $(realpath tests/ci/config/codecoverage_xdebug.ini) "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"
-
-        sudo service php-fpm restart
-    fi
+    if [ -L "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"; fi
+    sudo ln -s $(realpath tests/ci/config/codecoverage_xdebug.ini) "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"
+    if [ -L "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"; fi
+    sudo ln -s $(realpath tests/ci/config/codecoverage_xdebug.ini) "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"
+
+    sudo service php-fpm restart
 }
 
 disable_cc() {
-    if [ "$TRAVIS" = true ]; then
-        phpenv config-rm tests/ci/config/codecoverage_xdebug.ini
-
-        pkill php-fpm
-        ~/.phpenv/versions/$(phpenv version-name)/sbin/php-fpm
-    else
-        if [ -L "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"; fi
-        if [ -L "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"; fi
+    if [ -L "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_CLI}/99-codecoverage_xdebug.ini"; fi
+    if [ -L "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini" ]; then sudo rm "${PHPCONFDIR_FPM}/99-codecoverage_xdebug.ini"; fi
 
-        sudo service php-fpm restart
-    fi
+    sudo service php-fpm restart
 }
 
 case "$1" in
index ad16d3d..03bf0be 100755 (executable)
@@ -2,8 +2,7 @@
 
 # Has to be run as admin
 
-# To be kept in sync with setup_php_travis.sh
-
+# @todo make it optional to install xdebug. It is fe. missing in sury's ppa for Xenial
 # @todo make it optional to disable xdebug ?
 
 set -e
@@ -37,6 +36,13 @@ if [ "${PHP_VERSION}" = default ]; then
         php${PHPSUFFIX}-mbstring \
         php${PHPSUFFIX}-xdebug
 else
+    # on GHA runners ubuntu version, php 7.4 and 8.0 seem to be preinstalled. Remove them if found
+    for PHP_CURRENT in $(dpkg -l | grep -E 'php.+-common' | awk '{print $2}'); do
+        if [ "${PHP_CURRENT}" != "php${PHP_VERSION}-common" ]; then
+            apt-get purge -y "${PHP_CURRENT}"
+        fi
+    done
+
     DEBIAN_FRONTEND=noninteractive apt-get install -y language-pack-en-base software-properties-common
     LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
     apt-get update
@@ -57,9 +63,18 @@ PHPVER=$(php -r 'echo implode(".",array_slice(explode(".",PHP_VERSION),0,2));' 2
 
 configure_php_ini /etc/php/${PHPVER}/fpm/php.ini
 
-# use a nice name for the php-fpm service, so that it does not depend on php version running
+# use a nice name for the php-fpm service, so that it does not depend on php version running. Try to make that work
+# both for docker and VMs
 service "php${PHPVER}-fpm" stop
-ln -s "/etc/init.d/php${PHPVER}-fpm" /etc/init.d/php-fpm
+if [ -f "/etc/init.d/php${PHPVER}-fpm" ]; then
+    ln -s "/etc/init.d/php${PHPVER}-fpm" /etc/init.d/php-fpm
+fi
+if [ -f "/lib/systemd/system/php${PHPVER}-fpm.service" ]; then
+    ln -s "/lib/systemd/system/php${PHPVER}-fpm.service" /lib/systemd/system/php-fpm.service
+    if [ ! -f /.dockerenv ]; then
+        systemctl daemon-reload
+    fi
+fi
 
 # @todo shall we configure php-fpm?
 
diff --git a/tests/ci/setup/setup_php_travis.sh b/tests/ci/setup/setup_php_travis.sh
deleted file mode 100755 (executable)
index 4cc194e..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/bin/sh
-
-# To be kept in sync with setup_php.sh
-
-# @todo make it optional to disable xdebug ?
-
-set -e
-
-SCRIPT_DIR="$(dirname -- "$(readlink -f "$0")")"
-
-configure_php_ini() {
-    echo "cgi.fix_pathinfo = 1" >> "${1}"
-    echo "always_populate_raw_post_data = -1" >> "${1}"
-
-    # we disable xdebug for speed for both cli and web mode
-    phpenv config-rm xdebug.ini
-}
-
-PHPVER=$(phpenv version-name)
-
-configure_php_ini ~/.phpenv/versions/${PHPVER}/etc/php.ini
-
-# configure php-fpm
-cp ~/.phpenv/versions/${PHPVER}/etc/php-fpm.conf.default ~/.phpenv/versions/${PHPVER}/etc/php-fpm.conf
-
-# work around travis issue #3385
-if [ -d ~/.phpenv/versions/${PHPVER}/etc/php-fpm.d ]; then
-    # it seems that www.conf does not exist for php 7.0 .. 7.3
-    if [ -f ~/.phpenv/versions/${PHPVER}/etc/php-fpm.d/www.conf.default -a ! -f ~/.phpenv/versions/${PHPVER}/etc/php-fpm.d/www.conf ]; then
-        cp ~/.phpenv/versions/${PHPVER}/etc/php-fpm.d/www.conf.default ~/.phpenv/versions/${PHPVER}/etc/php-fpm.d/www.conf
-    fi
-fi
-
-# Use a unix socket for communication between apache and php-fpm - same as Ubuntu does by default
-if [ -f ~/.phpenv/versions/${PHPVER}/etc/php-fpm.d/www.conf ]; then
-    sed -i -e "s,listen = 127.0.0.1:9000,listen = /run/php/php-fpm.sock,g" ~/.phpenv/versions/${PHPVER}/etc/php-fpm.d/www.conf
-else
-    # php 5.6 has all fpm conf in a single file
-    sed -i -e "s,listen = 127.0.0.1:9000,listen = /run/php/php-fpm.sock,g" ~/.phpenv/versions/${PHPVER}/etc/php-fpm.conf
-    sed -i -e "s,user = nobody,user = travis,g" ~/.phpenv/versions/${PHPVER}/etc/php-fpm.conf
-    sed -i -e "s,group = nobody,group = travis,g" ~/.phpenv/versions/${PHPVER}/etc/php-fpm.conf
-fi
-sudo mkdir /run/php
-sudo chown travis:travis /run/php
-
-# @todo run php-fpm as root, and (always) set up 'travis' as user in www.conf, instead ?
-~/.phpenv/versions/${PHPVER}/sbin/php-fpm
-
-# configure apache for php-fpm via mod_proxy_fcgi
-sudo cp -f "$SCRIPT_DIR/../config/apache_phpfpm_proxyfcgi" "/etc/apache2/conf-available/php${PHPVER}-fpm.conf"
-sudo a2enconf php${PHPVER}-fpm
-sudo sed -i -e "s,www-data,travis,g" /etc/apache2/envvars
-sudo service apache2 restart
index d688514..1cef916 100755 (executable)
@@ -6,11 +6,10 @@ set -e
 
 ACTION="${1}"
 
-# Valid values: 'default', 5.6, 7.0 .. 7.4, 8.0
+# Valid values: 'default', 5.6, 7.0 .. 7.4, 8.0 .. 8.1
 export PHP_VERSION=${PHP_VERSION:-default}
 # Valid values: precise (12), trusty (14), xenial (16), bionic (18), focal (20)
-# We default to the same version we use on Travis
-export UBUNTU_VERSION=${UBUNTU_VERSION:-xenial}
+export UBUNTU_VERSION=${UBUNTU_VERSION:-bionic}
 
 CONTAINER_USER=docker
 CONTAINER_BUILD_DIR="/home/${CONTAINER_USER}/build"
@@ -42,8 +41,8 @@ Options:
     -h                print help
 
 Environment variables: to be set before the 'build' action
-    PHP_VERSION       default value: 'default', ie. the stock php version from the Ubuntu version in use. Other possible values: 7.0 .. 8.0
-    UBUNTU_VERSION    default value: xenial. Other possible values: bionic, focal
+    PHP_VERSION       default value: 'default', ie. the stock php version from the Ubuntu version in use. Other possible values: 5.6, 7.0 .. 8.1
+    UBUNTU_VERSION    default value: bionic. Other possible values: xenial, focal
 "
 }