Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache files are being deleted when PDF is generated #371

Open
mixasgr opened this issue Feb 1, 2021 · 3 comments
Open

Cache files are being deleted when PDF is generated #371

mixasgr opened this issue Feb 1, 2021 · 3 comments

Comments

@mixasgr
Copy link

mixasgr commented Feb 1, 2021

After upgrading to the latest version "1.4.8.0" from "1.4.19", i am having a very strange issue with automatic deletion of cache files.
This seems to happen when someone chooses to generate a PDF file which results in deleting all the files located at "cache" folder used to the selected area, eg specific images of the module used.

This strange behaviour is happening both at admin backend, eg from "modules" -> "list" -> select a module and then click at "PDF" bottom at the bottom of the page, or the frontend eg when a user exports the results of a test as "PDF".

Thank you for Tcexam and for any help if possible

@mormegilbelwas
Copy link

I am having a similar issue but it is only deleting the files that are used in the specific test. The images associated with the test will be deleted.

Your software is great, appreciate any help.

@bilias
Copy link
Contributor

bilias commented Jan 23, 2022

This happens in shared/tcpdf/tcpdf.php around line: 7826
in function _destroy()
I've commented the code bellow and I have no deletes of the generated .png files.

if (isset($this->imagekeys)) {

foreach($this->imagekeys as $file) {
    if (strpos($file, K_PATH_CACHE) === 0 && TCPDF_STATIC::file_exists($file)) {
         @unlink($file);
     }
}

}

Although I don't like this option that much, cause it also does not delete on Error

I think best solution is to change
register_shutdown_function(array($this, '_destroy'), true);
to
register_shutdown_function(array($this, '_destroy'), true, true);

@nicolaasuni
Copy link
Member

tcpdf was changes while ago.
Is this still a problem with the latest version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants