[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] pdflib: Ensure temp/pdfimg files are deleted even with permission issues

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <696fe5f580531_2c181bb82271e@gitlab-sidekiq-low-urgency-cpu-bound-v2-b9f9c5d67-pp57l.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
bcc4b215 by Domeshow Emmanuel at 2026-01-20T20:22:05+00:00
[FIX] pdflib: Ensure temp/pdfimg files are deleted even with permission issues
---
* [FIX] pdflib: Ensure temp/pdfimg files are deleted even with permission issues

See merge request tikiwiki/tiki!9374

- - - - -


2 changed files:

- lib/pdflib.php
- path_constants.php


Changes:

=====================================
lib/pdflib.php
=====================================
@@ -446,6 +446,7 @@ class PdfGenerator
             if (empty($isPermissionToViewPage)) {
                 $title = tr('PDF Cover Page Error');
                 $mes = tr('PDF generation failed because you do not have permission to view the specified cover page: %0', $coverWikiPage);
+                $this->clearTempImg($tempImgArr);
                 Feedback::error(['mes' => $mes, 'title' => $title]);
                 TikiLib::lib('access')->redirect($params['page'] ?? '');
                 die();
@@ -1162,9 +1163,9 @@ class PdfGenerator
         if (! $internalImg) {
             $url = $base_url . $url;
         }
-        if (! file_exists('temp/pdfimg')) {
-            mkdir('temp/pdfimg');
-            chmod('temp/pdfimg', 0755);
+        if (! file_exists(TEMP_PDFIMG_PATH)) {
+            mkdir(TEMP_PDFIMG_PATH);
+            chmod(TEMP_PDFIMG_PATH, 0755);
         }
         $cookie = $_SERVER['HTTP_COOKIE'] ?? '';
         $opts = [];
@@ -1180,7 +1181,7 @@ class PdfGenerator
         if (gettype($data) == 'boolean' && ! $data) {
             return '';
         }
-        $newFile = 'temp/pdfimg/pdfimg' . mt_rand(9999, 999999) . '.png';
+        $newFile = TEMP_PDFIMG_PATH . '/pdfimg' . mt_rand(9999, 999999) . '.png';
         file_put_contents($newFile, $data);
         chmod($newFile, 0755);
         return $newFile;


=====================================
path_constants.php
=====================================
@@ -99,6 +99,7 @@ const TEMP_CACHE_PATH = 'temp/cache';
 const TEMP_PUBLIC_PATH = 'temp/public';
 const TEMP_MAIL_DEBUG = 'temp/mail_debug';
 const HTMLPURIFIERCACHE_CACHE_PATH = 'temp/cache/HTMLPurifierCache';
+const TEMP_PDFIMG_PATH = 'temp/pdfimg';
 
 const WIKIPLUGINS_SRC_PATH = 'lib/wiki-plugins';
 //Question: where is the string or constant that generates these files?



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/bcc4b2157eff2be53ab3aeb01bbf4f4958cf3b6c

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/bcc4b2157eff2be53ab3aeb01bbf4f4958cf3b6c
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.