core: Three reads of an undefined variable or property become errors (PHP 9.0)
Maintainer thường phản hồi trong vòng 1 ngày
Đá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
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ả
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
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PlanBCode/hypha
-
Component: User interface Impact: Low Level: Easy Pagetype: Peer reviewed article Type: Bug Value: Visitors
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Impact: Medium Level: Easy Type: Bug Value: Users
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Impact: Low Level: Easy Pagetype: Festival Type: Bug Value: Coders
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Impact: Medium Level: Easy Pagetype: Mailinglist Type: Bug Value: Users
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Impact: Low Level: Easy Type: Bug Value: Coders
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 85/100
PlanBCode/hypha#586 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của PlanBCode/hypha
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
microsoft/monaco-editor#5563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Package downloads never retry: getUrlWithResuming's retry catch cannot see a rejected requestĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
account: profile bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 5 ngày
-
ai-driven-fuzzing bug claude Minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
linagora/cozy-client#1777 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày