From c47cad2bddd82cca7c58bc5564edfaf48a2031f5 Mon Sep 17 00:00:00 2001 From: Nicola Asuni Date: Fri, 31 Aug 2012 21:13:21 +0100 Subject: [PATCH] 5.9.181 (2012-08-31) - composer.json file was added. - Bug item #3563369 "Cached images are not unlinked some time" was fixed. --- CHANGELOG.TXT | 4 ++++ README.TXT | 4 ++-- composer.json | 38 ++++++++++++++++++++++++++++++++++++++ tcpdf.php | 39 +++++++++++++++++++++++++-------------- 4 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 composer.json diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index d3c29f9..3b87c8c 100755 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,7 @@ +5.9.181 (2012-08-31) + - composer.json file was added. + - Bug item #3563369 "Cached images are not unlinked some time" was fixed. + 5.9.180 (2012-08-22) - Bug item #3560493 "Problems with nested cells in HTML" was fixed. diff --git a/README.TXT b/README.TXT index ff86c9d..1d0fc01 100755 --- a/README.TXT +++ b/README.TXT @@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 5.9.180 -Release date: 2012-08-22 +Version: 5.9.181 +Release date: 2012-08-31 Author: Nicola Asuni Copyright (c) 2002-2012: diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..4cbb538 --- /dev/null +++ b/composer.json @@ -0,0 +1,38 @@ +{ + "name": "tcpdf/tcpdf", + "version": "5.9.181", + "homepage": "http://www.tcpdf.org/", + "type": "library", + "description": "TCPDF is a PHP class for generating PDF files on-the-fly without requiring external extensions.", + "keywords": ["pdf"], + "license": "LGPLv3", + "authors": [ + { + "name": "Nicola Asuni", + "email": "info@tecnick.com", + "homepage": "http://nicolaasuni.tecnick.com" + } + ], + "require": { + "php": ">5.2" + }, + "autoload": { + "classmap": [ + "fonts", + "config/lang", + "config", + "2dbarcodes.php", + "barcodes.php", + "datamatrix.php", + "encodings_maps.php", + "htmlcolors.php", + "pdf417.php", + "qrcode.php", + "spotcolors.php", + "tcpdf.php", + "tcpdf_filters.php", + "tcpdf_parser.php", + "unicode_data.php" + ] + } +} diff --git a/tcpdf.php b/tcpdf.php index 21da160..c5109bf 100755 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,9 +1,9 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 5.9.180 + * @version 5.9.181 */ // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file. @@ -150,7 +150,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.php'); * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 5.9.180 + * @version 5.9.181 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -161,7 +161,7 @@ class TCPDF { * Current TCPDF version. * @private */ - private $tcpdf_version = '5.9.180'; + private $tcpdf_version = '5.9.181'; // Protected properties @@ -359,6 +359,12 @@ class TCPDF { */ protected $images = array(); + /** + * Array of cached files. + * @protected + */ + protected $cached_files = array(); + /** * Array of Annotations in pages. * @protected @@ -7849,7 +7855,6 @@ class TCPDF { } // check page for no-write regions and adapt page margins if necessary list($x, $y) = $this->checkPageRegions($h, $x, $y); - $cached_file = false; // true when the file is cached $exurl = ''; // external streams // check if we are passing an image as file or string if ($file[0] === '@') { @@ -7860,11 +7865,11 @@ class TCPDF { fwrite($fp, $imgdata); fclose($fp); unset($imgdata); - $cached_file = true; $imsize = @getimagesize($file); if ($imsize === FALSE) { unlink($file); - $cached_file = false; + } else { + $this->cached_files[] = $file; } } else { // image file if ($file{0} === '*') { @@ -7908,11 +7913,11 @@ class TCPDF { fwrite($fp, $imgdata); fclose($fp); unset($imgdata); - $cached_file = true; $imsize = @getimagesize($file); if ($imsize === FALSE) { unlink($file); - $cached_file = false; + } else { + $this->cached_files[] = $file; } } } elseif (($w > 0) AND ($h > 0)) { @@ -8172,10 +8177,6 @@ class TCPDF { // add image to document $this->setImageBuffer($file, $info); } - if ($cached_file) { - // remove cached file - unlink($file); - } // set alignment $this->img_rb_y = $y + $h; // set alignment @@ -9075,6 +9076,7 @@ class TCPDF { AND ($val != 'bufferlen') AND ($val != 'buffer') AND ($val != 'diskcache') + AND ($val != 'cached_files') AND ($val != 'sign') AND ($val != 'signature_data') AND ($val != 'signature_max_length') @@ -9085,6 +9087,15 @@ class TCPDF { } } } + if (isset($this->cached_files) AND !empty($this->cached_files)) { + // remove cached files + foreach ($this->cached_files as $cachefile) { + if (is_file($cachefile)) { + unlink($cachefile); + } + } + unset($this->cached_files); + } } /**