From 303f61733d97a8c16c48e4bccb228a07d22d3aad Mon Sep 17 00:00:00 2001 From: Steven Lewis Date: Mon, 14 Oct 2024 10:30:41 +0100 Subject: [PATCH 1/2] Test Git Actions with php 8.4 --- .github/workflows/php.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 82871f0..9a21710 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -17,7 +17,7 @@ jobs: strategy: matrix: operating-system: [ubuntu-latest] - php-versions: ['8.0', '8.1', '8.2', '8.3'] + php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4'] ext-versions: ['couchbase-4.1.6', 'couchbase'] name: PHP ${{ matrix.php-versions }} using ${{ matrix.ext-versions }} quality/tests on ${{ matrix.operating-system }} env: From 1508f9a025fc4ac5c9fd532daa37f60a156fa8b6 Mon Sep 17 00:00:00 2001 From: "steven.lewis" Date: Wed, 27 Nov 2024 17:33:46 +0000 Subject: [PATCH 2/2] Notify parent and child process at the same time --- CHANGELOG.md | 7 +++++++ README.md | 5 ++++- lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php | 6 +++++- tests/Couchbasev4.test.php | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ffc38f..9b05351 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 9.2.3 +#### 27 November 2024 +- __Driver Core__ + - `Couchbasev4` Allow call to `handleNotifyFork()` after process has been forked, this is due + - to a change in the couchbase SDK that needs parent and child to be notified at the same time. + + ## 9.2.2 #### 29 July 2024 - __Driver Core__ diff --git a/README.md b/README.md index 66f0a69..d498d61 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,16 @@ composer install phpfastcache/couchbasev4-extension To fork a php process correctly you will need to tell the Couchbase diver to prepare for the fork. -⚠️ __WARNING__ You **must** call the drivers `Phpfastcache\Drivers\Couchbasev4\Driver::prepareToFork()` just before the `pcntl_fork()` call or the child process will lock up. +⚠️ __WARNING__ You **must** call the drivers `Phpfastcache\Drivers\Couchbasev4\Driver::prepareToFork()` +just before the `pcntl_fork()` call or the child process will lock up and then call `handleNotifyFork()` to avoid further +errors. #### Example ```php try { \Phpfastcache\Drivers\Couchbasev4\Driver::prepareToFork(); $pid = pcntl_fork(); + \Phpfastcache\Drivers\Couchbasev4\Driver::handleNotifyFork(); if ($pid == -1) { // There was a problem with forking the process } else if ($pid) { diff --git a/lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php b/lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php index 332f016..80228e7 100644 --- a/lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php +++ b/lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php @@ -199,8 +199,12 @@ protected function handleForkedProcess(): void } } - protected static function handleNotifyFork(): void + public static function handleNotifyFork(): void { + if (!isset(static::$posixLoaded) && !isset(static::$extVersion)) { + return; + } + if (static::$prepareToForkPPID && \version_compare(static::$extVersion, '4.2.1', '>=')) { if (static::$prepareToForkPPID === \posix_getpid()) { Cluster::notifyFork(ForkEvent::PARENT); diff --git a/tests/Couchbasev4.test.php b/tests/Couchbasev4.test.php index 82f9471..f6fdd4d 100644 --- a/tests/Couchbasev4.test.php +++ b/tests/Couchbasev4.test.php @@ -82,6 +82,7 @@ try { \Phpfastcache\Extensions\Drivers\Couchbasev4\Driver::prepareToFork(); $pid = \pcntl_fork(); + \Phpfastcache\Extensions\Drivers\Couchbasev4\Driver::handleNotifyFork(); if ($pid == -1) { $testHelper->assertFail('Unable to fork'); } else if ($pid) {