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

Fix compatibility with PHP 8 #270

Merged
merged 42 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1e7a25a
Fix compatibility with PHP 8.
MrMage Apr 26, 2021
7bf5d60
Add CI for PHP 8.
MrMage Apr 26, 2021
407a6cd
Also add CI for PHP 7.4.
MrMage Apr 26, 2021
ca2efdc
Try fixing another compiler error.
MrMage Apr 26, 2021
c6f2280
Fix two more flags that have been removed.
MrMage Apr 26, 2021
f747721
Try making an extension test compatible with PHP 7.4.
MrMage Apr 26, 2021
f860754
Solve the PHP 7.4 test compatibility issues the proper way.
MrMage Apr 26, 2021
6083f84
Enable Xdebug coverage in more places.
MrMage Apr 26, 2021
1f8829b
Add support for UUID v4 to fix our integration tests.
MrMage Apr 26, 2021
05fcc64
Add a bunch of arginfo annotations.
MrMage Apr 26, 2021
d38d8b4
More arginfo fixes.
MrMage Apr 26, 2021
3c72422
Remove `call_user_function_ex`.
MrMage Apr 26, 2021
4fb4005
Update a bunch of `zend_read_property` calls.
MrMage Apr 26, 2021
e7f7a52
More Z_OBJ_P fixes.
MrMage Apr 26, 2021
e5e471a
Yet more Z_OBJ_P.
MrMage Apr 26, 2021
2747006
Also update our _php_math_longtobase calls.
MrMage Apr 26, 2021
2b64d6d
Update PHP CodeSniffer.
MrMage Apr 26, 2021
2f55e72
Update PHPUnit.
MrMage Apr 26, 2021
9b16d04
Remove PHP 7 CI; make tests compatible with PHPUnit 9.
MrMage Apr 26, 2021
7f6fb82
Fix a few exceptions; require PHP 8.
MrMage Apr 26, 2021
a2f1c32
More PHPUnit fixes.
MrMage Apr 26, 2021
e66aa54
More compatibility fixes.
MrMage Apr 26, 2021
6d830fc
Fix another PHPUnit method signature.
MrMage Apr 26, 2021
4e90929
More integration test fixes.
MrMage Apr 26, 2021
a814fce
Yet more integration test fixes...
MrMage Apr 26, 2021
99d996b
Remove a reference to phpunit.xml.dist.
MrMage Apr 26, 2021
87f5105
Deja vu...
MrMage Apr 26, 2021
a715b05
Add support for PSR cache 2.0 and 3.0.
MrMage Apr 26, 2021
0c1f50c
Skip the Symfony 4 tests for now.
MrMage Apr 26, 2021
2eaf0e6
Also skip the WordPress integration test.
MrMage Apr 26, 2021
3a2dcf2
Fix a compiler error on macOS.
MrMage Apr 27, 2021
c528164
Try fixing compilation pre-PHP 8.
MrMage May 4, 2021
bfea684
Re-add CI for PHP 7.
MrMage May 4, 2021
8d2ea0d
Update a few composer files.
MrMage May 4, 2021
40dab4c
Two more fixes.
MrMage May 4, 2021
020c210
Also allow PHPUnit 7.
MrMage May 4, 2021
467d646
Use `PHP_MAJOR_VERSION` instead of `PHP_VERSION_ID`.
MrMage May 5, 2021
01914df
Minor macro tweak.
MrMage May 18, 2021
544ce56
Try running integration tests on PHP 7.4 instead.
MrMage May 18, 2021
f1f8b2a
Fix a typo and add integration tests on both 7.4 and 8.0.
MrMage May 18, 2021
28c1a3e
Another WordPress test fix.
MrMage May 18, 2021
024aac7
Remove unnecessary parent setup calls.
MrMage May 26, 2021
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
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:[email protected]: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:[email protected]: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:[email protected]: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
MrMage marked this conversation as resolved.
Show resolved Hide resolved
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