[phd] master: Fix: Prevent using null as array offset in Package/PHP/Web (#228)
| From: | Louis-Arnaud via GitHub | Date: | Sun, 11 Jan 2026 20:32:47 +0000 |
| Subject: | [phd] master: Fix: Prevent using null as array offset in Package/PHP/Web (#228) | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-22942@lists.php.net to get a copy of this message | ||
Author: Louis-Arnaud (lacatoire)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2026-01-11T20:32:45Z
Commit: https://github.com/php/phd/commit/91384413a2d76e53ac338bb86703ea19b08041ad
Raw diff: https://github.com/php/phd/commit/91384413a2d76e53ac338bb86703ea19b08041ad.diff
Fix: Prevent using null as array offset in Package/PHP/Web (#228)
* Fix: Stop using null as array offset (Resolves #227)
* This also avoids accessing "path" on a null source when sourceInfo() returns null.
---------
Co-authored-by: lacatoire <louis-arnaud.catoire@external.drivalia.com>
Changed paths:
M phpdotnet/phd/Package/PHP/Web.php
Diff:
diff --git a/phpdotnet/phd/Package/PHP/Web.php b/phpdotnet/phd/Package/PHP/Web.php
index 2ba54010..475f3870 100644
--- a/phpdotnet/phd/Package/PHP/Web.php
+++ b/phpdotnet/phd/Package/PHP/Web.php
@@ -204,7 +204,14 @@ public function header($id) {
"alternatives" => $this->cchunk["alternatives"],
"source" => $this->sourceInfo($id),
);
- $setup["history"] =
$this->history[$setup["source"]["path"]] ?? [];
+ $history = $this->history ?? [];
+
+ $sourcePath = $setup["source"]["path"] ?? null;
+
+ $setup["history"] = $sourcePath !== null
+ ? ($history[$sourcePath] ?? [])
+ : [];
+
if ($this->getChildren($id)) {
$lang = $this->config->language;
$setup["extra_header_links"] = array(