Fix base class
Some checks failed
DokuWiki Default Tasks / all (push) Has been cancelled

This commit is contained in:
2026-01-06 09:35:23 +01:00
parent 68f678c2df
commit 30bb9e3bbd

View File

@@ -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];
}
}
}