Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

core: Three reads of an undefined variable or property become errors (PHP 9.0)

オープン
#599 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@guidol-ive がすでに取り組んでいます。

2026年10月28日 から。

  • #601 @guidol-ive による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
php
領域
backend

調査の方向性

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 の本文から書いたものです。

説明

Impact: Low Level: Easy Type: Bug Value: Coders

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 last elseif ($t > 60) by else $s = max(1, floor($t / 60)).' '.__('minutes');.
  • requireLock(): 'File ' . $this->file->getFilename() . ' should be locked'.
  • data(): start with $zip = false; (above //START_OF_DATA, so buildzip() 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

PlanBCode/hypha のほかの issue

PlanBCode/hypha の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。