Skip to content

Commit f5ad0cb

Browse files
authored
fix: make frankenphp-worker.php template idempotent on watcher restart (#10191)
1 parent 6a1543a commit f5ad0cb

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

system/Commands/Worker/Views/frankenphp-worker.php.tpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ if (version_compare(PHP_VERSION, $minPhpVersion, '<')) {
3636
*---------------------------------------------------------------
3737
*/
3838

39-
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
39+
if (! defined('FCPATH')) {
40+
define('FCPATH', __DIR__ . DIRECTORY_SEPARATOR);
41+
}
4042

4143
if (getcwd() . DIRECTORY_SEPARATOR !== FCPATH) {
4244
chdir(FCPATH);
@@ -49,11 +51,11 @@ if (getcwd() . DIRECTORY_SEPARATOR !== FCPATH) {
4951
*/
5052

5153
// This is the line that might need to be changed, depending on your folder structure.
52-
require FCPATH . '../app/Config/Paths.php';
54+
require_once FCPATH . '../app/Config/Paths.php';
5355
// ^^^ Change this line if you move your application folder
5456
$paths = new Paths();
5557

56-
require $paths->systemDirectory . '/Boot.php';
58+
require_once $paths->systemDirectory . '/Boot.php';
5759

5860
// One-time boot - loads autoloader, environment, helpers, etc.
5961
$app = Boot::bootWorker($paths);

user_guide_src/source/changelogs/v4.7.3.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Bugs Fixed
5050
- **Toolbar:** Fixed a bug where the Logs collector raised an undefined property error when using a third-party PSR-3 logger.
5151
- **Time:** Fixed a bug where ``Time::createFromTimestamp()`` could fail for microsecond timestamps when ``LC_NUMERIC`` used a comma decimal separator.
5252
- **Validation:** Fixed a bug where ``Validation::getValidated()`` dropped fields whose validated value was explicitly ``null``.
53+
- **Worker Mode:** Fixed a bug where the ``frankenphp-worker.php`` template caused a ``Cannot redeclare class Config\Paths`` fatal error when FrankenPHP's watcher re-executed the worker script after a watched file changed.
5354

5455
See the repo's
5556
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

user_guide_src/source/installation/upgrade_473.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ Please refer to the upgrade instructions corresponding to your installation meth
1616
Mandatory File Changes
1717
**********************
1818

19+
Worker Mode
20+
===========
21+
22+
If you are using Worker Mode, you must update **public/frankenphp-worker.php** after
23+
upgrading. The easiest way is to re-run the install command:
24+
25+
.. code-block:: console
26+
27+
php spark worker:install --force
28+
1929
****************
2030
Breaking Changes
2131
****************

0 commit comments

Comments
 (0)