Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
feat: add PHP 8 compatibility (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMage authored May 31, 2021
1 parent 007b35d commit 0cfda50
Show file tree
Hide file tree
Showing 47 changed files with 399 additions and 256 deletions.
152 changes: 126 additions & 26 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ unit-config: &unit-config

- run:
name: PHP unit tests
command: vendor/bin/phpunit
command: XDEBUG_MODE=coverage vendor/bin/phpunit

- run:
name: PHP unit tests with extension
command: |
if [ $RUN_EXTENSION_TESTS -eq "1" ]; then
php -d extension=opencensus.so vendor/bin/phpunit
XDEBUG_MODE=coverage php -d extension=opencensus.so vendor/bin/phpunit
else
echo "Skipping units tests with extension"
fi
Expand Down Expand Up @@ -107,29 +107,30 @@ jobs:
docker:
- image: circleci/php:7.3-zts-node

php71-32bit:
php74:
<<: *unit-config
docker:
- image: gcr.io/php-stackdriver/php71-32bit
environment:
TEST_PHP_ARGS: -q
REPORT_EXIT_STATUS: 1
RUN_EXTENSION_TESTS: 1
SUDO_CMD: ""
- image: circleci/php:7.4-node

php71-debug:
php74-zts:
<<: *unit-config
docker:
- image: gcr.io/php-stackdriver/php71-debug
environment:
TEST_PHP_ARGS: -q
REPORT_EXIT_STATUS: 1
RUN_EXTENSION_TESTS: 1
SUDO_CMD: ""
- image: circleci/php:7.4-zts-node

integration:
php80:
<<: *unit-config
docker:
- image: circleci/php:7.2-node
- image: circleci/php:8.0-node

php80-zts:
<<: *unit-config
docker:
- image: circleci/php:8.0-zts-node

# Integration tests running on PHP 7.4. When updating these, please also update `integration-8.0` further down.
integration-7.4:
docker:
- image: circleci/php:7.4-node
- image: memcached
- image: mysql:5.7
environment:
Expand Down Expand Up @@ -202,11 +203,13 @@ jobs:
- run:
name: Pgsql test
command: tests/integration/pgsql/test.sh
- run:
name: Symfony 4 test
command: tests/integration/symfony4/test.sh
environment:
DATABASE_URL: mysql://mysql:mysql@127.0.0.1:3306/mysqldb
# Skipped due to a dependency incompatibility between "cache/adapter-common" and "psr/cache".
# TODO(mrmage): Re-enable this step once "cache/adapter-common" supports "psr/cache" v2.0/v3.0.
# - run:
# name: Symfony 4 test
# command: tests/integration/symfony4/test.sh
# environment:
# DATABASE_URL: mysql://mysql:mysql@127.0.0.1:3306/mysqldb
- run:
name: Wordpress test
command: tests/integration/wordpress/test.sh
Expand All @@ -216,6 +219,100 @@ jobs:
DB_PASSWORD: mysql
DB_DATABASE: mysqldb

# Integration tests running on PHP 8.0. When updating these, please also update `integration-7.4` further down.
integration-8.0:
docker:
- image: circleci/php:8.0-node
- image: memcached
- image: mysql:5.7
environment:
MYSQL_USER: mysql
MYSQL_PASSWORD: mysql
MYSQL_DATABASE: mysqldb
MYSQL_RANDOM_ROOT_PASSWORD: yes
- image: postgres:9.6
environment:
POSTGRES_PASSWORD: pgsql
POSTGRES_USER: postgres
steps:
- checkout
- run:
name: Install build tools
command: |
sudo apt-get update -y
sudo apt-get install -y -q --no-install-recommends \
build-essential \
g++ \
gcc \
libc-dev \
libpqxx-dev \
make \
autoconf \
git \
unzip
- run:
name: Install opencensus extension
command: |
cd ext
phpize
./configure --enable-opencensus
sudo make install
sudo docker-php-ext-enable opencensus
- run:
name: Install memcached extension
command: |
sudo apt-get install -y -q --no-install-recommends \
libmemcached11 libmemcached-dev zlib1g-dev zlib1g
sudo pecl install memcached <<<''
sudo docker-php-ext-enable memcached
- run:
name: Install pdo_mysql extension
command: sudo docker-php-ext-install pdo_mysql
- run:
name: Install mysqli extension
command: sudo docker-php-ext-install mysqli
- run:
name: Install pgsql extension
command: sudo docker-php-ext-install pgsql
- run:
name: Install pcntl extension
command: sudo docker-php-ext-install pcntl
- run:
name: Curl test
command: tests/integration/curl/test.sh
- run:
name: Guzzle 5 test
command: tests/integration/guzzle5/test.sh
- run:
name: Guzzle 6 test
command: tests/integration/guzzle6/test.sh
- run:
name: Laravel test
command: tests/integration/laravel/test.sh
- run:
name: Memcached test
command: tests/integration/memcached/test.sh
- run:
name: Pgsql test
command: tests/integration/pgsql/test.sh
# Skipped due to a dependency incompatibility between "cache/adapter-common" and "psr/cache".
# TODO(mrmage): Re-enable this step once "cache/adapter-common" supports "psr/cache" v2.0/v3.0.
# - run:
# name: Symfony 4 test
# command: tests/integration/symfony4/test.sh
# environment:
# DATABASE_URL: mysql://mysql:mysql@127.0.0.1:3306/mysqldb
# Skipped because "wp-cli" is currently not compatible with PHP 8 (see https://github.com/wp-cli/wp-cli/issues/5452).
# TODO(mrmage): Re-enable this step once "wp-cli" supports PHP 8.
# - run:
# name: Wordpress test
# command: tests/integration/wordpress/test.sh
environment:
DB_HOST: 127.0.0.1
DB_USERNAME: mysql
DB_PASSWORD: mysql
DB_DATABASE: mysqldb

workflows:
version: 2
units:
Expand All @@ -226,6 +323,9 @@ workflows:
- php72-zts
- php73
- php73-zts
- php71-32bit
- php71-debug
- integration
- php74
- php74-zts
- php80
- php80-zts
- integration-7.4
- integration-8.0
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"minimum-stability": "stable",
"require": {
"php": ">=7.1",
"ramsey/uuid": "~3",
"ramsey/uuid": "^3.0 || ^4.0",
"psr/log": "^1.0",
"psr/cache": "^1.0",
"psr/cache": "^1.0 || ^2.0 || ^3.0",
"cache/adapter-common": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0",
"squizlabs/php_codesniffer": "2.*",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"squizlabs/php_codesniffer": "^3.0",
"twig/twig": "~2.0 || ~1.35",
"symfony/yaml": "~3.3",
"guzzlehttp/guzzle": "~5.3",
Expand Down
6 changes: 0 additions & 6 deletions examples/symfony/web/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,8 @@
use Symfony\Component\HttpFoundation\Request;

require __DIR__.'/../vendor/autoload.php';
if (PHP_VERSION_ID < 70000) {
include_once __DIR__.'/../var/bootstrap.php.cache';
}

$kernel = new AppKernel('prod', false);
if (PHP_VERSION_ID < 70000) {
$kernel->loadClassCache();
}
//$kernel = new AppCache($kernel);

// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
Expand Down
3 changes: 0 additions & 3 deletions examples/symfony/web/app_dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
Debug::enable();

$kernel = new AppKernel('dev', true);
if (PHP_VERSION_ID < 70000) {
$kernel->loadClassCache();
}
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
Expand Down
23 changes: 9 additions & 14 deletions ext/opencensus.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_opencensus_trace_add_message_event, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0)
ZEND_ARG_ARRAY_INFO(0, options, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_void, 0, 0, 0)
ZEND_END_ARG_INFO();

/* }}} */

static PHP_MINFO_FUNCTION(opencensus);
Expand All @@ -85,16 +89,16 @@ PHP_FUNCTION(opencensus_version);
/* {{{ opencensus_functions[]
*/
static zend_function_entry opencensus_functions[] = {
PHP_FE(opencensus_version, NULL)
PHP_FE(opencensus_version, arginfo_void)
PHP_FE(opencensus_core_send_to_daemonclient, arginfo_opencensus_core_send_to_daemon)
PHP_FE(opencensus_trace_function, arginfo_opencensus_trace_function)
PHP_FE(opencensus_trace_method, arginfo_opencensus_trace_method)
PHP_FE(opencensus_trace_list, NULL)
PHP_FE(opencensus_trace_list, arginfo_void)
PHP_FE(opencensus_trace_begin, arginfo_opencensus_trace_begin)
PHP_FE(opencensus_trace_finish, NULL)
PHP_FE(opencensus_trace_clear, NULL)
PHP_FE(opencensus_trace_finish, arginfo_void)
PHP_FE(opencensus_trace_clear, arginfo_void)
PHP_FE(opencensus_trace_set_context, arginfo_opencensus_trace_set_context)
PHP_FE(opencensus_trace_context, NULL)
PHP_FE(opencensus_trace_context, arginfo_void)
PHP_FE(opencensus_trace_add_attribute, arginfo_opencensus_trace_add_attribute)
PHP_FE(opencensus_trace_add_annotation, arginfo_opencensus_trace_add_annotation)
PHP_FE(opencensus_trace_add_link, arginfo_opencensus_trace_add_link)
Expand Down Expand Up @@ -122,9 +126,6 @@ zend_module_entry opencensus_module_entry = {
};

#ifdef COMPILE_DL_OPENCENSUS
#ifdef ZTS
ZEND_TSRMLS_CACHE_DEFINE()
#endif
ZEND_GET_MODULE(opencensus)
#endif

Expand All @@ -149,9 +150,6 @@ PHP_MINFO_FUNCTION(opencensus)
*/
PHP_GINIT_FUNCTION(opencensus)
{
#if defined(COMPILE_DL_OPENCENSUS) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE()
#endif
opencensus_trace_ginit();
}
/* }}} */
Expand All @@ -168,9 +166,6 @@ PHP_GSHUTDOWN_FUNCTION(opencensus)
*/
PHP_MINIT_FUNCTION(opencensus)
{
#if defined(COMPILE_DL_OPENCENSUS) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE()
#endif
REGISTER_INI_ENTRIES();

#ifndef PHP_WIN32
Expand Down
Loading

0 comments on commit 0cfda50

Please sign in to comment.