Fix bug in Image() when writing to disk should use tempnam()
PHP class for PDF
Brought to you by:
nicolaasuni
Piwik, open source web analytics, is a very happy TCPDF user.
We have found a bug. In tcpdf.php the code to write to files is not refactored, and it seems there are a few differences between the uses of fopen etc.
In particular in Image() the filename used to record on disk does not use tempnam (as opposed to the sendToDisk() at line 8234)
Please apply the following patch to Tcpdf!
http://dev.piwik.org/trac/changeset/5540#file0
Thanks & keep up the great work
one line fix
The original code is perfectly valid and the patch is wrong.
The image filename cannot be random, it is created in this way to easily retrieve already processed images.
If the path is not writable, the image creation will fail and throw fopen/fwrite/fclose warning on screens. When using tempnam, the directory is first checked to see if it's writable, if not, will write in /tmp/ which is enough for us to generate the image for hard-inclusion in PDF.
Maybe my patch is not fixing the bug in the best way, but it certainly fixes a bug in tcpdf for us, thanks!