[Pkg-owncloud-commits] [php-sabre-vobject] 302/341: Merge branch 'master' into optimize-children-access
David Prévot
taffit at moszumanska.debian.org
Tue Aug 11 13:35:59 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 32a43b401bbd107dbcd4685c80fb7e1aeff3498a
Merge: 1134e49 7dded29
Author: Evert Pot <me at evertpot.com>
Date: Sat Jul 4 01:40:49 2015 -0400
Merge branch 'master' into optimize-children-access
.gitignore | 1 +
CHANGELOG.md | 2 ++
bin/bench_manipulatevcard.php | 69 ++++++++++++++++++++++++++++++++++++++++++
lib/Component.php | 26 +++++++++++++---
lib/Node.php | 15 +++++++++
lib/Property.php | 18 +++++++++++
tests/VObject/DocumentTest.php | 21 +++++++++++++
7 files changed, 148 insertions(+), 4 deletions(-)
diff --cc lib/Component.php
index a315f77,197371f..7370bb2
--- a/lib/Component.php
+++ b/lib/Component.php
@@@ -151,33 -149,23 +151,31 @@@ class Component extends Node
function remove($item) {
if (is_string($item)) {
-
- $children = $this->select($item);
- foreach ($children as $k => $child) {
- $child->destroy();
- unset($this->children[$k]);
- }
- return;
- }
- foreach ($this->children as $k => $child) {
- if ($child === $item) {
- $child->destroy();
- unset($this->children[$k]);
+ // If there's no dot in the name, it's an exact property name and
+ // we can just wipe out all those properties.
+ //
+ if (strpos($item, '.') === false) {
+ unset($this->children[strtoupper($item)]);
return;
}
+ // If there was a dot, we need to ask select() to help us out and
+ // then we just call remove recursively.
+ foreach ($this->select($item) as $child) {
+
+ $this->remove($child);
+
+ }
+ } else {
+ foreach ($this->select($item->name) as $k => $child) {
+ if ($child === $item) {
+ unset($this->children[$item->name][$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');
+
}
/**
--
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