Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[Bug]: herd restart skips PHP versions used only by isolated sites ("Restarting PHP $_sock_...")

未关闭
#1,770 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
php
领域
cli

调研方向

Start by locating PhpFpm::utilizedPhpVersions() and isolatedDirectories(), which the issue identifies as the current version-discovery paths; inspect how stopIfUnused() uses the same version list. Reproduce with a global PHP version and a site isolated to another version, then run herd restart and check whether both PHP-FPM processes get new PIDs. Done when every version used by a site is restarted without the invalid $_sock_ name.

由索引模型根据 Issue 内容生成。

描述

fixed-in-next-release macOS
Platform

macOS

Operating system version

macOS 27.0.1 (26A434)

System architecture

ARM64 (M1, M2, etc)

Herd Version

2.0.2 (Build: 71)

PHP Version

Not version-specific: any version that only isolated sites use. Here: global PHP 8.5.10, a site isolated to PHP 8.4.25.

Bug description

herd restart (and herd restart php) does not restart PHP-FPM for a version that only isolated sites use. Here the global PHP is 8.5 and a site is isolated to 8.4: herd restart prints Restarting PHP $_sock_... and Restarting PHP 8.5..., and afterwards only 8.5 has a new PHP-FPM process; 8.4 keeps its pid and start time (log below). Sites isolated to the global version are not affected, because the global version is always restarted.

Expected: every PHP version that a site uses is restarted.

Impact: low, but silent. Code changes are not affected (with Herd's default OPcache settings PHP picks them up by itself). But for a version that only isolated sites use, a php.ini change (for example memory_limit, upload_max_filesize or an extension) is not applied, and stuck PHP-FPM workers are not cleared, although the CLI says "Herd services have been restarted."

Cause, in herd.phar 2.0.2: in PhpFpm::utilizedPhpVersions(), the first entry of Herd::SUPPORTED_PHP_VERSIONS is 'php', which nginxSockName() turns into $herd_sock_. That is the start of every isolated site's socket name ($herd_sock_84), so the strpos() check matches it first, and str_replace(['herd', '.sock'], ...) turns it into $_sock_. Herd rejects that name ("Invalid PHP version provided", log below), but runAppleScript() discards stderr, so no error shows. stopIfUnused() uses the same list.

Suggestion: read each site's version from its # ISOLATED_PHP_VERSION= line, as isolatedDirectories() already does. Fixing only the prefix match wouldn't be enough: the str_replace() expects herd84.sock-style names and would give $_sock_8.4.

Workaround: quit and reopen Herd.

The same Restarting PHP $_sock_... line shows in output pasted in #402 (Herd 1.4.1) and #1597 (Herd 1.24.2), so this is probably not new.

Steps to reproduce
  1. Herd 2.0.2 with global PHP 8.5.
  2. Isolate a site to 8.4: herd isolate 8.4 --site=example (Herd installs 8.4 if needed).
  3. Note the PHP-FPM main processes: ps -o pid,lstart,command -p $(pgrep -d, -P $(pgrep -x Herd)) | grep fpm
  4. Run herd restart.
  5. Run the ps command again: 8.5 has a new pid and start time, 8.4 still has the old ones.
Relevant log output
PHP-FPM main processes before herd restart (from ps):
PHP 8.4 started Oct 19 22:35:05 2026 (pid 61676)
PHP 8.5 started Oct 19 22:03:47 2026 (pid 57366)

$ herd restart
Restarting DNSMasq...
Restarting PHP $_sock_...
Restarting PHP 8.5...
Restarting Nginx...
Herd services have been restarted.

PHP-FPM main processes after:
PHP 8.4 started Oct 19 22:35:05 2026 (pid 61676)
PHP 8.5 started Oct 19 22:35:35 2026 (pid 61898)

$ osascript -e 'tell application "Herd" to restart php service "$_sock_"'
27:56: execution error: Herd got an error: Invalid PHP version provided. Available versions are: 8.6, 8.5, 8.4, 8.3, 8.2, 8.1, 8.0, 7.4 (10)
主要语言
没有语言数据
星标
124
派生
1
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

beyondcode/herd-community 的其他 Issue

查看 beyondcode/herd-community 的全部 Issue

相似的 Issue

更多 CLI Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。