From 30bb9e3bbd8d732a45dc4ce2b8b8cc618309b759 Mon Sep 17 00:00:00 2001 From: luxick Date: Tue, 6 Jan 2026 09:35:23 +0100 Subject: [PATCH] Fix base class --- syntax/AbstractSyntax.php | 41 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/syntax/AbstractSyntax.php b/syntax/AbstractSyntax.php index bd1a747..b8fcfca 100644 --- a/syntax/AbstractSyntax.php +++ b/syntax/AbstractSyntax.php @@ -10,6 +10,7 @@ use dokuwiki\plugin\luxtools\Path; * * Provides shared functionality for directory, files, and images syntax. */ +if (!class_exists('syntax_plugin_luxtools_abstract', false)) { abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin { /** @@ -103,15 +104,47 @@ abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin return false; } + // DokuWiki caches the $data returned by handle(). When the shape changes + // between plugin versions, old cached instructions can feed unexpected + // structures (or even null) into render(). Be defensive to avoid fatals. + if (!is_array($data)) { + return false; + } + if ($format !== 'xhtml' && $format !== 'odt') { return false; } - $pathData = $data['pathData']; - $params = $data['params']; + // New format: ['pathData' => array, 'params' => array] + // Back-compat: numeric list or older associative keys. + $pathData = $data['pathData'] ?? ($data[0] ?? null); + $params = $data['params'] ?? ($data[1] ?? null); + + // Some older cached instructions may pass the raw path as string. + if (is_string($pathData)) { + $pathData = $this->processPath($pathData); + } + + // If params are missing (older cache), fall back to defaults. + if (!is_array($params)) { + $params = $this->parseFlags(''); + } + + // If pathData was inlined (e.g. ['base'=>..,'pattern'=>..,'params'=>..]), extract it. + if (!is_array($pathData)) { + $candidate = $data; + unset($candidate['params']); + if (isset($candidate['base']) || isset($candidate['pattern']) || isset($candidate['path'])) { + $pathData = $candidate; + } + } + + if (!is_array($pathData)) { + return false; + } // Disable caching if requested - if ($params['cache'] === 0) { + if (($params['cache'] ?? 0) == 0) { $renderer->nocache(); } @@ -218,3 +251,5 @@ abstract class syntax_plugin_luxtools_abstract extends SyntaxPlugin return [$base, $pattern]; } } + +}