From ca8c370c4b21f9fc00b2599d278b4c6db304fa8e Mon Sep 17 00:00:00 2001 From: Thorry84 Date: Mon, 8 Aug 2016 07:36:38 +0200 Subject: [PATCH 1/3] Change way how to detect if "Node::preFormat" has been invoked Using the SPL object hash to uniquely identify objects isn't safe, PHP reuses SPL object hashes. --- lib/PHPPdf/Core/Node/Manager.php | 5 +---- lib/PHPPdf/Core/Node/Node.php | 11 ++++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/PHPPdf/Core/Node/Manager.php b/lib/PHPPdf/Core/Node/Manager.php index 61e377dc..11d43d00 100644 --- a/lib/PHPPdf/Core/Node/Manager.php +++ b/lib/PHPPdf/Core/Node/Manager.php @@ -27,8 +27,6 @@ class Manager implements DocumentParserListener private $managedNodes = array(); private $behavioursTasks; - - private $preFormatInvoked = array(); public function __construct() { @@ -187,13 +185,12 @@ private function invokePreFormatIfItHasntInvokedYet(Document $document, Node $no { if(!$this->preFormatHasBeenInvoked($node)) { - $this->preFormatInvoked[spl_object_hash($node)] = true; $node->preFormat($document); } } private function preFormatHasBeenInvoked(Node $node) { - return isset($this->preFormatInvoked[spl_object_hash($node)]); + return $node->hasPreFormatBeenInvoked(); } } \ No newline at end of file diff --git a/lib/PHPPdf/Core/Node/Node.php b/lib/PHPPdf/Core/Node/Node.php index c23398a4..7673e320 100644 --- a/lib/PHPPdf/Core/Node/Node.php +++ b/lib/PHPPdf/Core/Node/Node.php @@ -84,6 +84,8 @@ abstract class Node implements Drawable, NodeAware, \ArrayAccess, \Serializable private $closestAncestorWithPosition = null; private $positionTranslation = null; + private $preFormatInvoked = false; + public function __construct(array $attributes = array(), UnitConverter $converter = null) { static::initializeTypeIfNecessary(); @@ -1305,6 +1307,7 @@ public function copy() $copy->ancestorWithFontSize = null; $copy->ancestorWithRotation = null; $copy->closestAncestorWithPosition = null; + $copy->preFormatInvoked = false; return $copy; } @@ -1584,8 +1587,9 @@ public function format(Document $document) public function preFormat(Document $document) { $this->beforeFormat($document); - + $this->doFormat('pre', $document); + $this->preFormatInvoked = true; } public function doFormat($type, Document $document) @@ -1867,4 +1871,9 @@ public function getShape() { return self::SHAPE_RECTANGLE; } + + public function hasPreFormatBeenInvoked() + { + return $this->preFormatInvoked; + } } \ No newline at end of file From 7055c857a34003b8bf2af6200d5fad18360a67a6 Mon Sep 17 00:00:00 2001 From: "piotr.sliwa" Date: Mon, 15 Aug 2016 00:50:47 +0200 Subject: [PATCH 2/3] 1.2.10 release --- CHANGELOG.markdown | 6 +++++- lib/PHPPdf/Version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown index 2871584c..114864be 100644 --- a/CHANGELOG.markdown +++ b/CHANGELOG.markdown @@ -1,10 +1,14 @@ CHANGELOG ========= -* 1.2.10 (???) +* 1.2.11 (???) * (nothing) +* 1.2.10 (2016-08-15) + + * [#114] Fix failures on nodes initialization in big documents + * 1.2.9 (2016-03-06) * [#95] relaxed ZF components versions diff --git a/lib/PHPPdf/Version.php b/lib/PHPPdf/Version.php index 3f08bdee..3f61fe43 100644 --- a/lib/PHPPdf/Version.php +++ b/lib/PHPPdf/Version.php @@ -17,7 +17,7 @@ */ final class Version { - const VERSION = '1.2.10-DEV'; + const VERSION = '1.2.10'; private function __construct() { From 84390da3b55a39bf08dfa660c18a0a7c1a4efe99 Mon Sep 17 00:00:00 2001 From: "piotr.sliwa" Date: Mon, 15 Aug 2016 00:51:17 +0200 Subject: [PATCH 3/3] update version to 1.2.11-DEV --- lib/PHPPdf/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PHPPdf/Version.php b/lib/PHPPdf/Version.php index 3f61fe43..6194289a 100644 --- a/lib/PHPPdf/Version.php +++ b/lib/PHPPdf/Version.php @@ -17,7 +17,7 @@ */ final class Version { - const VERSION = '1.2.10'; + const VERSION = '1.2.11-DEV'; private function __construct() {