From dc7ee5e76a5fed077ca7650216cc27a8a0e05b3f Mon Sep 17 00:00:00 2001 From: Frieder Schrempf Date: Sat, 8 May 2021 19:07:13 +0200 Subject: [PATCH] Fix multi page rendering by setting global $INFO In case of rendering multiple pages into a single document, the context of the current page does not match the one of the pages to be rendered. In some cases (e.g. with the struct plugin), the global $INFO is evluated and as this is not set to match the page to be rendered, the struct plugin does not produce the expected output in the PDF. Fix this by setting $INFO to match the current page to be rendered and restoring it afterwards. Signed-off-by: Frieder Schrempf --- action.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/action.php b/action.php index 8b5a69c0..a558ba83 100644 --- a/action.php +++ b/action.php @@ -348,10 +348,17 @@ protected function p_wiki_dw2pdf($id, $rev = '', $date_at = '') { if(!file_exists($file)) return ''; - //ensure $id is in global $ID (needed for parsing) + /* + * Ensure that global $ID and $INFO are set to match the page + * to be rendered in order for the rendering and other plugins + * to work properly. + */ global $ID; - $keep = $ID; - $ID = $id; + global $INFO; + $keepid = $ID; + $keepinfo = $INFO; + $ID = $id; + $INFO = pageinfo(); if($rev || $date_at) { $ret = p_render('dw2pdf', p_get_instructions(io_readWikiPage($file, $id, $rev)), $info, $date_at); //no caching on old revisions @@ -359,8 +366,9 @@ protected function p_wiki_dw2pdf($id, $rev = '', $date_at = '') { $ret = p_cached_output($file, 'dw2pdf', $id); } - //restore ID (just in case) - $ID = $keep; + // Restore ID and INFO (just in case) + $ID = $keepid; + $INFO = $keepinfo; return $ret; }