Skip to content

Commit 9138441

Browse files
lacatoirelacatoire
andauthored
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 <[email protected]>
1 parent 43855fa commit 9138441

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

phpdotnet/phd/Package/PHP/Web.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,14 @@ public function header($id) {
204204
"alternatives" => $this->cchunk["alternatives"],
205205
"source" => $this->sourceInfo($id),
206206
);
207-
$setup["history"] = $this->history[$setup["source"]["path"]] ?? [];
207+
$history = $this->history ?? [];
208+
209+
$sourcePath = $setup["source"]["path"] ?? null;
210+
211+
$setup["history"] = $sourcePath !== null
212+
? ($history[$sourcePath] ?? [])
213+
: [];
214+
208215
if ($this->getChildren($id)) {
209216
$lang = $this->config->language;
210217
$setup["extra_header_links"] = array(

0 commit comments

Comments
 (0)