Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#599 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@guidol-ive đang làm issue này rồi.

Từ ngày 28/10/2026.

  • #601 của @guidol-ive — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
JavaScript
Star
5
Fork
9
Merge trung bình
18 giờ 7 phút
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của PlanBCode/hypha

Tất cả issue của PlanBCode/hypha

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.