[Pkg-owncloud-commits] [php-sabre-vobject] 298/341: Fixed a few bugs, updated changelog.

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 13:35:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit 2cd4e5c6c4e3661b8b9cb8d7d4231171eed565af
Author: Evert Pot <me at evertpot.com>
Date:   Sat Jul 4 01:25:48 2015 -0400

    Fixed a few bugs, updated changelog.
---
 CHANGELOG.md                   |  2 ++
 lib/Component.php              | 19 +++++++++----------
 tests/VObject/DocumentTest.php | 21 +++++++++++++++++++++
 3 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20c8410..3b324f0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,8 @@ ChangeLog
 * Removed `RecurrenceIterator` (use Recur\EventIterator instead).
 * Now using php-cs-fixer to automatically enforce and correct CS.
 * #233: The `+00:00` timezone is now recognized as UTC. (@c960657)
+* #237: Added a `destroy()` method to all documents. This method breaks any
+  circular references, allowing PHP to free up memory.
 
 
 3.4.5 (2015-06-02)
diff --git a/lib/Component.php b/lib/Component.php
index cdadd41..87653b8 100644
--- a/lib/Component.php
+++ b/lib/Component.php
@@ -154,19 +154,18 @@ class Component extends Node {
                 $child->destroy();
                 unset($this->children[$k]);
             }
-            return $child;
-        } else {
-            foreach ($this->children as $k => $child) {
-                if ($child === $item) {
-                    $child->destroy();
-                    unset($this->children[$k]);
-                }
+            return;
+        }
+        foreach ($this->children as $k => $child) {
+            if ($child === $item) {
+                $child->destroy();
+                unset($this->children[$k]);
+                return;
             }
-
-            throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component');
-
         }
 
+        throw new \InvalidArgumentException('The item you passed to remove() was not a child of this component');
+
     }
 
     /**
diff --git a/tests/VObject/DocumentTest.php b/tests/VObject/DocumentTest.php
index 5d66ce4..d657192 100644
--- a/tests/VObject/DocumentTest.php
+++ b/tests/VObject/DocumentTest.php
@@ -62,6 +62,27 @@ class DocumentTest extends \PHPUnit_Framework_TestCase {
 
     }
 
+    function testDestroy() {
+
+        $vcal = new Component\VCalendar([], false);
+        $event = $vcal->createComponent('VEVENT');
+
+        $this->assertInstanceOf('Sabre\VObject\Component\VEvent', $event);
+        $vcal->add($event);
+
+        $prop = $vcal->createProperty('X-PROP', '1234256', ['X-PARAM' => '3']);
+
+        $event->add($prop);
+
+        $this->assertEquals($event, $prop->parent);
+
+        $vcal->destroy();
+
+        $this->assertNull($event, $prop->parent);
+
+
+    }
+
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list