From 43f9360cc0e4dc9204104b3f155d323651a91292 Mon Sep 17 00:00:00 2001 From: randy Date: Wed, 30 Jul 2025 22:13:24 -0700 Subject: [PATCH] Fix PHP 8.3 TypeError on non-existent pages - Add page existence checks to prevent processing missing pages - Fixes 'Cannot access offset of type string on string' error - Prevents unnecessary TOC processing on pages that don't exist - Maintains existing functionality for valid pages Affected functions: - handlePostProcess() - handleTocRender() - handleContentDisplay() Tested on PHP 8.3 - missing pages now show normal DokuWiki message --- action/rendertoc.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/action/rendertoc.php b/action/rendertoc.php index e39ee97..0e19b99 100644 --- a/action/rendertoc.php +++ b/action/rendertoc.php @@ -120,6 +120,11 @@ function handlePostProcess(Doku_Event $event, $param) { return; } + // Skip processing for non-existent pages to prevent PHP 8.3 TypeError + if (!page_exists($INFO['id'])) { + return; + } + // TOC Position check $tocPosition = @$meta['position'] ?: $this->getConf('tocPosition'); if ($ACT == 'preview') { @@ -175,6 +180,11 @@ function handleTocRender(Doku_Event $event, $param) { return; } + // Skip processing for non-existent pages to prevent PHP 8.3 TypeError + if (!page_exists($INFO['id'])) { + return; + } + // retrieve toc config parameters from metadata $topLv = @$meta['toptoclevel'] ?: $this->getConf('toptoclevel'); $maxLv = @$meta['maxtoclevel'] ?: $this->getConf('maxtoclevel'); @@ -204,6 +214,11 @@ function handleContentDisplay(Doku_Event $event, $param) { return; } + // Skip processing for non-existent pages to prevent PHP 8.3 TypeError + if (!page_exists($INFO['id'])) { + return; + } + // TOC Position check $tocPosition = @$meta['position'] ?: $this->getConf('tocPosition'); if (!in_array($tocPosition, [0,1,2,6])) {