Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#599 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@guidol-ive ci sta già lavorando.

Dal 28/10/2026.

  • #601 di @guidol-ive — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
php
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
JavaScript
Stelle
5
Fork
9
Merge medio
18h 7m
PR unite (30g)
11

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PlanBCode/hypha

Tutte le issue di PlanBCode/hypha

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.