core: Three reads of an undefined variable or property become errors (PHP 9.0)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
Read system/core/communication.php around flushDigest(), system/core/database.php around Xml::requireLock(), and hypha.php around data(). The issue gives reproduction steps and proposed fixes for all three undefined reads. Verify the digest message, lock exception message, and unpacked-file lookup no longer trigger undefined-read errors on PHP 9.0; pull request #601 is already open against this issue.
索引モデルが issue の本文から書いたものです。
説明
Problem. PHP 9.0 turns a read of an undefined variable or property into an Error; PHP 8.x only logs a warning. This was accepted in the RFCs Undefined variable error promotion and Undefined property error promotion (both target PHP 9.0). Three places on main (d97ab7b) read a variable or property that is not set:
| Place | What happens | Message today (PHP 8.2, 8.5 and 8.6.0RC4) |
|---|---|---|
system/core/communication.php:182-186, flushDigest() |
$s is only set when the last digest is more than 60 seconds ago. With a digest interval of one minute or zero (settings: 0 days, 0 hours, 0 or 1 minute), the digest is sent sooner and $s is unset: the mail says "summary of the last" without a period. On PHP 9.0 the request that sends the digest stops with an Error, after hypha_getAndClearDigest() has already emptied the digest, so that digest is lost. |
Warning: Undefined variable $s in system/core/communication.php on line 186 |
system/core/database.php:242, Xml::requireLock() |
The exception message reads $this->filename, a property that Xml does not have (the name is in its HyphaFile, $this->file). The message names no file today; on PHP 9.0 the LogicException is replaced by an Error about the property. |
Warning: Undefined property: Xml::$filename |
hypha.php:424, data() |
if ($zip) runs when no case has set $zip. In a built hypha.php every packed file has a case, so this is only reached for a name that is not packed; on 9.0 that is an Error instead of null. |
Warning: Undefined variable $zip in hypha.php on line 424 |
Found with PHPStan (level 1) on main and confirmed at run time on PHP 8.2, 8.5 and 8.6.0RC4 (the php:8.6-rc image) with a fictional test site. The other "might not be defined" findings of PHPStan (index.php:126, communication.php:277-279, database.php:767, datatypes/index.php:70, peer_reviewed_article.php:1566, settings.php:672) are set on every path that reaches them. Related: #338 (automated code checks such as PHPStan would catch these).
Steps to reproduce (fictional test site). Set digestInterval="0" in data/hypha.xml, put a line in data/digest and open any page: the log shows the warning and the digest mail has no period. For the other two: php -r "require 'system/core/database.php'; \$x = new Xml('textpage', true, true); \$x->loadFromFile('data/pages/<id>'); \$x->requireLock();", and data('x') from hypha.php.
Proposed fix (a suggestion and a starting point):
flushDigest(): replace the lastelseif ($t > 60)byelse $s = max(1, floor($t / 60)).' '.__('minutes');.requireLock():'File ' . $this->file->getFilename() . ' should be locked'.data(): start with$zip = false;(above//START_OF_DATA, sobuildzip()keeps it).
All three work unchanged on PHP 8.2 up to 8.5.
🤖 Generated with Claude Code
- 主要言語
- JavaScript
- スター
- 5
- フォーク
- 9
- 平均マージ
- 18時間 7分
- マージ済み PR(30日)
- 11
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
PlanBCode/hypha のほかの issue
-
Component: User interface Impact: Low Level: Easy Pagetype: Peer reviewed article Type: Bug Value: Visitors
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
Impact: Medium Level: Easy Type: Bug Value: Users
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Impact: Low Level: Easy Pagetype: Festival Type: Bug Value: Coders
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
Impact: Medium Level: Easy Pagetype: Mailinglist Type: Bug Value: Users
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 1 日以内に返信
-
Impact: Low Level: Easy Type: Bug Value: Coders
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
PlanBCode/hypha#586 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
PlanBCode/hypha の issue をすべて見る
似ている issue
-
step.duration reflects only the last retry attempt (HelperStep.run() overwrites startTime)対応中かも @mirao が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
codeceptjs/CodeceptJS#5774 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
Status: Unconfirmed
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
AllTheMods/ATM10-Aeronautics#151 ·
メンテナーはふだん 4 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
feimacode/open-design-agent-kit#66 ·
メンテナーはふだん 1 日以内に返信