Skip to content

Commit 2b7973b

Browse files
apply code suggestions
Co-authored-by: John Paul E. Balandan, CPA <paulbalandan@gmail.com>
1 parent 1728900 commit 2b7973b

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

system/Boot.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public static function bootWorker(Paths $paths): CodeIgniter
102102
static::setExceptionHandler();
103103
static::initializeKint();
104104

105-
// Note: We skip config caching in worker mode
106-
// as it may cause issues with state between requests
105+
static::checkOptimizationsForWorker();
106+
107107
static::autoloadHelpers();
108108

109109
return Boot::initializeCodeIgniter();
@@ -366,6 +366,20 @@ protected static function checkMissingExtensions(): void
366366
exit(EXIT_ERROR);
367367
}
368368

369+
protected static function checkOptimizationsForWorker(): void
370+
{
371+
if (class_exists(Optimize::class)) {
372+
$optimize = new Optimize();
373+
374+
if ($optimize->configCacheEnabled || $optimize->locatorCacheEnabled) {
375+
echo 'Optimization settings (configCacheEnabled, locatorCacheEnabled) '
376+
. 'must be disabled in Config\Optimize when running in Worker Mode.';
377+
378+
exit(EXIT_ERROR);
379+
}
380+
}
381+
}
382+
369383
protected static function initializeKint(): void
370384
{
371385
service('autoloader')->initializeKint(CI_DEBUG);

system/Database/BaseConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ abstract protected function _close();
512512
*/
513513
public function ping(): bool
514514
{
515-
if (! $this->connID) {
515+
if ($this->connID === false) {
516516
return false;
517517
}
518518

system/Database/Config.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,6 @@ protected static function ensureFactory()
161161
*/
162162
public static function reconnectForWorkerMode(): void
163163
{
164-
if (static::$instances === []) {
165-
return;
166-
}
167-
168164
foreach (static::$instances as $connection) {
169165
$connection->reconnect();
170166
}

system/Session/Handlers/RedisHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public function close(): bool
305305
try {
306306
$pingReply = $this->redis->ping();
307307

308-
if (in_array($pingReply, [true, '+PONG'], true) && (isset($this->lockKey) && ! $this->releaseLock())) {
308+
if (in_array($pingReply, [true, '+PONG'], true) && isset($this->lockKey) && ! $this->releaseLock()) {
309309
return false;
310310
}
311311
} catch (RedisException $e) {

user_guide_src/source/installation/running.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ Worker Mode with FrankenPHP
164164

165165
.. versionadded:: 4.7.0
166166

167+
.. important:: Worker Mode is currently **experimental**. The only officially supported
168+
worker implementation is **FrankenPHP**, which is backed by the PHP Foundation.
169+
167170
FrankenPHP is a modern PHP application server that supports Worker Mode, allowing
168171
your application to handle multiple requests within the same PHP process for
169172
improved performance.

0 commit comments

Comments
 (0)