[Pkg-owncloud-commits] [php-sabredav] 41/148: Moved carddav reports to new xml system.

David Prévot taffit at moszumanska.debian.org
Wed Apr 15 01:37:10 UTC 2015


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

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

commit 0bdc01cdecd512232e58555a16720db7c1ba3809
Author: Evert Pot <me at evertpot.com>
Date:   Wed Feb 11 23:25:12 2015 -0500

    Moved carddav reports to new xml system.
---
 lib/CalDAV/Xml/Filter/CalendarData.php             |   4 +-
 lib/CardDAV/AddressBookQueryParser.php             | 221 ---------------------
 lib/CardDAV/Plugin.php                             |  55 ++---
 lib/CardDAV/Xml/Filter/AddressData.php             |  63 ++++++
 lib/CardDAV/Xml/Filter/PropFilter.php              |   6 +-
 .../Xml/Request/AddressBookMultiGetReport.php      |  44 +++-
 lib/CardDAV/Xml/Request/AddressBookQueryReport.php |  66 ++++--
 tests/Sabre/CardDAV/PluginTest.php                 |   1 -
 8 files changed, 164 insertions(+), 296 deletions(-)

diff --git a/lib/CalDAV/Xml/Filter/CalendarData.php b/lib/CalDAV/Xml/Filter/CalendarData.php
index 5ab8e85..4ff2b14 100644
--- a/lib/CalDAV/Xml/Filter/CalendarData.php
+++ b/lib/CalDAV/Xml/Filter/CalendarData.php
@@ -37,8 +37,8 @@ class CalendarData implements XmlDeserializable {
      * Often you want to return an instance of the current class, but you are
      * free to return other data as well.
      *
-     * Important note 2: You are responsible for advancing the reader to the
-     * next element. Not doing anything will result in a never-ending loop.
+     * You are responsible for advancing the reader to the next element. Not
+     * doing anything will result in a never-ending loop.
      *
      * If you just want to skip parsing for this element altogether, you can
      * just call $reader->next();
diff --git a/lib/CardDAV/AddressBookQueryParser.php b/lib/CardDAV/AddressBookQueryParser.php
deleted file mode 100644
index 8d5c25b..0000000
--- a/lib/CardDAV/AddressBookQueryParser.php
+++ /dev/null
@@ -1,221 +0,0 @@
-<?php
-
-namespace Sabre\CardDAV;
-
-use Sabre\DAV;
-
-/**
- * Parses the addressbook-query report request body.
- *
- * Whoever designed this format, and the CalDAV equivalent even more so,
- * has no feel for design.
- *
- * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class AddressBookQueryParser {
-
-    const TEST_ANYOF = 'anyof';
-    const TEST_ALLOF = 'allof';
-
-    /**
-     * List of requested properties the client wanted
-     *
-     * @var array
-     */
-    public $requestedProperties;
-
-    /**
-     * The number of results the client wants
-     *
-     * null means it wasn't specified, which in most cases means 'all results'.
-     *
-     * @var int|null
-     */
-    public $limit;
-
-    /**
-     * List of property filters.
-     *
-     * @var array
-     */
-    public $filters;
-
-    /**
-     * Either TEST_ANYOF or TEST_ALLOF
-     *
-     * @var string
-     */
-    public $test;
-
-    /**
-     * DOM Document
-     *
-     * @var DOMDocument
-     */
-    protected $dom;
-
-    /**
-     * DOM XPath object
-     *
-     * @var DOMXPath
-     */
-    protected $xpath;
-
-    /**
-     * Creates the parser
-     *
-     * @param \DOMDocument $dom
-     */
-    function __construct(\DOMDocument $dom) {
-
-        $this->dom = $dom;
-
-        $this->xpath = new \DOMXPath($dom);
-        $this->xpath->registerNameSpace('card',Plugin::NS_CARDDAV);
-
-    }
-
-    /**
-     * Parses the request.
-     *
-     * @return void
-     */
-    function parse() {
-
-        $limit = $this->xpath->evaluate('number(/card:addressbook-query/card:limit/card:nresults)');
-        if (is_nan($limit)) $limit = null;
-
-        $filter = $this->xpath->query('/card:addressbook-query/card:filter');
-
-        // According to the CardDAV spec there needs to be exactly 1 filter
-        // element. However, KDE 4.8.2 contains a bug that will encode 0 filter
-        // elements, so this is a workaround for that.
-        //
-        // See: https://bugs.kde.org/show_bug.cgi?id=300047
-        if ($filter->length === 0) {
-            $test = null;
-            $filter = null;
-        } elseif ($filter->length === 1) {
-            $filter = $filter->item(0);
-            $test = $this->xpath->evaluate('string(@test)', $filter);
-        } else {
-            throw new DAV\Exception\BadRequest('Only one filter element is allowed');
-        }
-
-        if (!$test) $test = self::TEST_ANYOF;
-        if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) {
-            throw new DAV\Exception\BadRequest('The test attribute must either hold "anyof" or "allof"');
-        }
-
-        $propFilters = [];
-
-        if (!is_null($filter)) {
-            $propFilterNodes = $this->xpath->query('card:prop-filter', $filter);
-            for($ii=0; $ii < $propFilterNodes->length; $ii++) {
-
-                $propFilters[] = $this->parsePropFilterNode($propFilterNodes->item($ii));
-
-
-            }
-        }
-
-        $this->filters = $propFilters;
-        $this->limit = $limit;
-        $this->requestedProperties = array_keys(DAV\XMLUtil::parseProperties($this->dom->firstChild));
-        $this->test = $test;
-
-    }
-
-    /**
-     * Parses the prop-filter xml element
-     *
-     * @param \DOMElement $propFilterNode
-     * @return array
-     */
-    protected function parsePropFilterNode(\DOMElement $propFilterNode) {
-
-        $propFilter = [];
-        $propFilter['name'] = $propFilterNode->getAttribute('name');
-        $propFilter['test'] = $propFilterNode->getAttribute('test');
-        if (!$propFilter['test']) $propFilter['test'] = 'anyof';
-
-        $propFilter['is-not-defined'] = $this->xpath->query('card:is-not-defined', $propFilterNode)->length>0;
-
-        $paramFilterNodes = $this->xpath->query('card:param-filter', $propFilterNode);
-
-        $propFilter['param-filters'] = [];
-
-
-        for($ii=0;$ii<$paramFilterNodes->length;$ii++) {
-
-            $propFilter['param-filters'][] = $this->parseParamFilterNode($paramFilterNodes->item($ii));
-
-        }
-        $propFilter['text-matches'] = [];
-        $textMatchNodes = $this->xpath->query('card:text-match', $propFilterNode);
-
-        for($ii=0;$ii<$textMatchNodes->length;$ii++) {
-
-            $propFilter['text-matches'][] = $this->parseTextMatchNode($textMatchNodes->item($ii));
-
-        }
-
-        return $propFilter;
-
-    }
-
-    /**
-     * Parses the param-filter element
-     *
-     * @param \DOMElement $paramFilterNode
-     * @return array
-     */
-    function parseParamFilterNode(\DOMElement $paramFilterNode) {
-
-        $paramFilter = [];
-        $paramFilter['name'] = $paramFilterNode->getAttribute('name');
-        $paramFilter['is-not-defined'] = $this->xpath->query('card:is-not-defined', $paramFilterNode)->length>0;
-        $paramFilter['text-match'] = null;
-
-        $textMatch = $this->xpath->query('card:text-match', $paramFilterNode);
-        if ($textMatch->length>0) {
-            $paramFilter['text-match'] = $this->parseTextMatchNode($textMatch->item(0));
-        }
-
-        return $paramFilter;
-
-    }
-
-    /**
-     * Text match
-     *
-     * @param \DOMElement $textMatchNode
-     * @return array
-     */
-    function parseTextMatchNode(\DOMElement $textMatchNode) {
-
-        $matchType = $textMatchNode->getAttribute('match-type');
-        if (!$matchType) $matchType = 'contains';
-
-        if (!in_array($matchType, ['contains', 'equals', 'starts-with', 'ends-with'])) {
-            throw new DAV\Exception\BadRequest('Unknown match-type: ' . $matchType);
-        }
-
-        $negateCondition = $textMatchNode->getAttribute('negate-condition');
-        $negateCondition = $negateCondition==='yes';
-        $collation = $textMatchNode->getAttribute('collation');
-        if (!$collation) $collation = 'i;unicode-casemap';
-
-        return [
-            'negate-condition' => $negateCondition,
-            'collation' => $collation,
-            'match-type' => $matchType,
-            'value' => $textMatchNode->nodeValue
-        ];
-
-
-    }
-
-}
diff --git a/lib/CardDAV/Plugin.php b/lib/CardDAV/Plugin.php
index 2f956a1..a0b8217 100644
--- a/lib/CardDAV/Plugin.php
+++ b/lib/CardDAV/Plugin.php
@@ -76,8 +76,8 @@ class Plugin extends DAV\ServerPlugin {
         $server->on('beforeCreateFile',    [$this, 'beforeCreateFile']);
         $server->on('afterMethod:GET',     [$this, 'httpAfterGet']);
 
-        /* Namespaces */
-        $server->xmlNamespaces[self::NS_CARDDAV] = 'card';
+        $server->xml->elementMap['{' . self::NS_CARDDAV . '}addressbook-query'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookQueryReport';
+        $server->xml->elementMap['{' . self::NS_CARDDAV . '}addressbook-multiget'] = 'Sabre\\CardDAV\\Xml\\Request\\AddressBookMultiGetReport';
 
         /* Mapping Interfaces to {DAV:}resourcetype values */
         $server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook'] = '{' . self::NS_CARDDAV . '}addressbook';
@@ -287,29 +287,13 @@ class Plugin extends DAV\ServerPlugin {
      * This report is used by the client to fetch the content of a series
      * of urls. Effectively avoiding a lot of redundant requests.
      *
-     * @param \DOMNode $dom
+     * @param Xml\Request\AddressBookMultiGetReport $report
      * @return void
      */
-    function addressbookMultiGetReport($dom) {
-
-        $properties = array_keys(DAV\XMLUtil::parseProperties($dom->firstChild));
-
-        $hrefElems = $dom->getElementsByTagNameNS('urn:DAV','href');
-        $propertyList = [];
-
-        $uris = [];
-        foreach($hrefElems as $elem) {
-
-            $uris[] = $this->server->calculateUri($elem->nodeValue);
-
-        }
+    function addressbookMultiGetReport($report) {
 
-        $xpath = new \DOMXPath($dom);
-        $xpath->registerNameSpace('card',Plugin::NS_CARDDAV);
-        $xpath->registerNameSpace('dav','urn:DAV');
-
-        $contentType = $xpath->evaluate("string(/card:addressbook-multiget/dav:prop/card:address-data/@content-type)");
-        $version = $xpath->evaluate("string(/card:addressbook-multiget/dav:prop/card:address-data/@version)");
+        $contentType = $report->contentType;
+        $version = $report->version;
         if ($version) {
             $contentType.='; version=' . $version;
         }
@@ -319,7 +303,7 @@ class Plugin extends DAV\ServerPlugin {
         );
 
         $propertyList = [];
-        foreach($this->server->getPropertiesForMultiplePaths($uris, $properties) as $props) {
+        foreach($this->server->getPropertiesForMultiplePaths($report->hrefs, $report->properties) as $props) {
 
             if (isset($props['200']['{' . self::NS_CARDDAV . '}address-data'])) {
 
@@ -451,13 +435,10 @@ class Plugin extends DAV\ServerPlugin {
      * This report is used by the client to filter an addressbook based on a
      * complex query.
      *
-     * @param \DOMNode $dom
+     * @param Xml\Request\AddressBookQueryReport $report
      * @return void
      */
-    protected function addressbookQueryReport($dom) {
-
-        $query = new AddressBookQueryParser($dom);
-        $query->parse();
+    protected function addressbookQueryReport($report) {
 
         $depth = $this->server->getHTTPDepth(0);
 
@@ -472,21 +453,15 @@ class Plugin extends DAV\ServerPlugin {
             $candidateNodes = $this->server->tree->getChildren($this->server->getRequestUri());
         }
 
-        $xpath = new \DOMXPath($dom);
-        $xpath->registerNameSpace('card',Plugin::NS_CARDDAV);
-        $xpath->registerNameSpace('dav','urn:DAV');
-
-        $contentType = $xpath->evaluate("string(/card:addressbook-query/dav:prop/card:address-data/@content-type)");
-        $version = $xpath->evaluate("string(/card:addressbook-query/dav:prop/card:address-data/@version)");
-        if ($version) {
-            $contentType.='; version=' . $version;
+        $contentType = $report->contentType;
+        if ($report->version) {
+            $contentType.='; version=' . $report->version;
         }
 
         $vcardType = $this->negotiateVCard(
             $contentType
         );
 
-
         $validNodes = [];
         foreach($candidateNodes as $node) {
 
@@ -498,13 +473,13 @@ class Plugin extends DAV\ServerPlugin {
                 $blob = stream_get_contents($blob);
             }
 
-            if (!$this->validateFilters($blob, $query->filters, $query->test)) {
+            if (!$this->validateFilters($blob, $report->filters, $report->test)) {
                 continue;
             }
 
             $validNodes[] = $node;
 
-            if ($query->limit && $query->limit <= count($validNodes)) {
+            if ($report->limit && $report->limit <= count($validNodes)) {
                 // We hit the maximum number of items, we can stop now.
                 break;
             }
@@ -520,7 +495,7 @@ class Plugin extends DAV\ServerPlugin {
                 $href = $this->server->getRequestUri() . '/' . $validNode->getName();
             }
 
-            list($props) = $this->server->getPropertiesForPath($href, $query->requestedProperties, 0);
+            list($props) = $this->server->getPropertiesForPath($href, $report->properties, 0);
 
             if (isset($props[200]['{' . self::NS_CARDDAV . '}address-data'])) {
 
diff --git a/lib/CardDAV/Xml/Filter/AddressData.php b/lib/CardDAV/Xml/Filter/AddressData.php
new file mode 100644
index 0000000..6a0d67f
--- /dev/null
+++ b/lib/CardDAV/Xml/Filter/AddressData.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Sabre\CardDAV\Xml\Filter;
+
+use Sabre\Xml\Reader;
+use Sabre\Xml\XmlDeserializable;
+use Sabre\DAV\Exception\BadRequest;
+use Sabre\CardDAV\Plugin;
+use Sabre\VObject\DateTimeParser;
+
+
+/**
+ * AddressData parser.
+ *
+ * This class parses the {urn:ietf:params:xml:ns:carddav}address-data XML
+ * element, as defined in:
+ *
+ * http://tools.ietf.org/html/rfc6352#section-10.4
+ *
+ * This element is used in two distinct places, but this one specifically
+ * encodes the address-data element as it appears in the addressbook-query
+ * adressbook-multiget REPORT requests.
+ *
+ * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+class AddressData implements XmlDeserializable {
+
+    /**
+     * The deserialize method is called during xml parsing.
+     *
+     * This method is called statictly, this is because in theory this method
+     * may be used as a type of constructor, or factory method.
+     *
+     * Often you want to return an instance of the current class, but you are
+     * free to return other data as well.
+     *
+     * You are responsible for advancing the reader to the next element. Not
+     * doing anything will result in a never-ending loop.
+     *
+     * If you just want to skip parsing for this element altogether, you can
+     * just call $reader->next();
+     *
+     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
+     * the next element.
+     *
+     * @param Reader $reader
+     * @return mixed
+     */
+    static function xmlDeserialize(Reader $reader) {
+
+        $result = [
+            'contentType' => $reader->getAttribute('content-type')?:'text/vcard',
+            'version'     => $reader->getAttribute('version')?:'3.0',
+        ];
+
+        $reader->next();
+        return $result;
+
+    }
+
+}
diff --git a/lib/CardDAV/Xml/Filter/PropFilter.php b/lib/CardDAV/Xml/Filter/PropFilter.php
index c94884d..1c7e7b2 100644
--- a/lib/CardDAV/Xml/Filter/PropFilter.php
+++ b/lib/CardDAV/Xml/Filter/PropFilter.php
@@ -2,8 +2,8 @@
 
 namespace Sabre\CardDAV\Xml\Filter;
 
-use Sabre\Xml\Element;
 use Sabre\Xml\Reader;
+use Sabre\Xml\XmlDeserializable;
 use Sabre\DAV\Exception\BadRequest;
 use Sabre\CardDAV\Plugin;
 
@@ -22,7 +22,7 @@ use Sabre\CardDAV\Plugin;
  * @author Evert Pot (http://evertpot.com/) 
  * @license http://sabre.io/license/ Modified BSD License
  */
-abstract class PropFilter implements Element {
+class PropFilter implements XmlDeserializable {
 
     /**
      * The deserialize method is called during xml parsing.
@@ -45,7 +45,7 @@ abstract class PropFilter implements Element {
      * @param Reader $reader
      * @return mixed
      */
-    static function deserializeXml(Reader $reader) {
+    static function xmlDeserialize(Reader $reader) {
 
         $result = [
             'name' => null,
diff --git a/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php b/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
index 3e45fad..17ae6f0 100644
--- a/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
+++ b/lib/CardDAV/Xml/Request/AddressBookMultiGetReport.php
@@ -2,6 +2,8 @@
 
 namespace Sabre\CardDAV\Xml\Request;
 
+use Sabre\CardDAV\Plugin;
+use Sabre\Uri;
 use Sabre\Xml\Reader;
 use Sabre\Xml\XmlDeserializable;
 
@@ -34,6 +36,22 @@ class AddressBookMultiGetReport implements XmlDeserializable {
     public $hrefs;
 
     /**
+     * The mimetype of the content that should be returend. Usually
+     * text/vcard.
+     *
+     * @var string
+     */
+    public $contentType = null;
+
+    /**
+     * The version of vcard data that should be returned. Usually 3.0,
+     * referring to vCard 3.0.
+     *
+     * @var string
+     */
+    public $version = null;
+
+    /**
      * The deserialize method is called during xml parsing.
      *
      * This method is called statictly, this is because in theory this method
@@ -54,22 +72,30 @@ class AddressBookMultiGetReport implements XmlDeserializable {
      * @param Reader $reader
      * @return mixed
      */
-    static function deserializeXml(Reader $reader) {
+    static function xmlDeserialize(Reader $reader) {
 
-        $elems = $reader->parseInnerTree();
-        $hrefs = [];
+        $elems = $reader->parseInnerTree([
+            '{urn:ietf:params:xml:ns:carddav}address-data' => 'Sabre\\CardDAV\\Xml\\Filter\\AddressData',
+            '{DAV:}prop'                                   => 'Sabre\\Xml\\Element\\KeyValue',
+        ]);
 
-        $properties = null;
+        $newProps = [
+            'hrefs' => [],
+            'properties' => []
+        ];
 
         foreach($elems as $elem) {
 
             switch($elem['name']) {
 
                 case '{DAV:}prop' :
-                    $properties = array_keys($elem['value']);
+                    $newProps['properties'] = array_keys($elem['value']);
+                    if (isset($elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'])) {
+                        $newProps+=$elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'];
+                    }
                     break;
                 case '{DAV:}href' :
-                    $hrefs[] = $elem['value'];
+                    $newProps['hrefs'][] = Uri\resolve($reader->baseUri, $elem['value']);
                     break;
 
             }
@@ -77,9 +103,9 @@ class AddressBookMultiGetReport implements XmlDeserializable {
         }
 
         $obj = new self();
-        $obj->properties = $properties;
-        $obj->hrefs = $hrefs;
-
+        foreach($newProps as $key=>$value) {
+            $obj->$key = $value;
+        }
         return $obj;
 
     }
diff --git a/lib/CardDAV/Xml/Request/AddressBookQueryReport.php b/lib/CardDAV/Xml/Request/AddressBookQueryReport.php
index 3ff45f8..1e03794 100644
--- a/lib/CardDAV/Xml/Request/AddressBookQueryReport.php
+++ b/lib/CardDAV/Xml/Request/AddressBookQueryReport.php
@@ -33,7 +33,7 @@ class AddressBookQueryReport implements XmlDeserializable {
      *
      * @var array
      */
-    public $filter;
+    public $filters;
 
     /**
      * The number of results the client wants
@@ -52,6 +52,23 @@ class AddressBookQueryReport implements XmlDeserializable {
     public $test;
 
     /**
+     * The mimetype of the content that should be returend. Usually
+     * text/vcard.
+     *
+     * @var string
+     */
+    public $contentType = null;
+
+    /**
+     * The version of vcard data that should be returned. Usually 3.0,
+     * referring to vCard 3.0.
+     *
+     * @var string
+     */
+    public $version = null;
+
+
+    /**
      * The deserialize method is called during xml parsing.
      *
      * This method is called statictly, this is because in theory this method
@@ -74,12 +91,19 @@ class AddressBookQueryReport implements XmlDeserializable {
      */
     static function xmlDeserialize(Reader $reader) {
 
-        $elems = $reader->parseInnerTree();
+        $elems = $reader->parseInnerTree([
+            '{urn:ietf:params:xml:ns:carddav}prop-filter'  => 'Sabre\\CardDAV\\Xml\\Filter\\PropFilter',
+            '{urn:ietf:params:xml:ns:carddav}param-filter' => 'Sabre\\CardDAV\\Xml\\Filter\\ParamFilter',
+            '{urn:ietf:params:xml:ns:carddav}address-data' => 'Sabre\\CardDAV\\Xml\\Filter\\AddressData',
+            '{DAV:}prop'                                   => 'Sabre\\Xml\\Element\\KeyValue',
+        ]);
 
-        $properties = null;
-        $filter = null;
-        $test = 'anyof';
-        $limit = null;
+        $newProps = [
+            'filters' => null,
+            'properties' => [],
+            'test' => 'anyof',
+            'limit' => null,
+        ];
 
         if (!is_array($elems)) $elems = [];
 
@@ -88,33 +112,36 @@ class AddressBookQueryReport implements XmlDeserializable {
             switch($elem['name']) {
 
                 case '{DAV:}prop' :
-                    $properties = array_keys($elem['value']);
+                    $newProps['properties'] = array_keys($elem['value']);
+                    if (isset($elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'])) {
+                        $newProps+=$elem['value']['{' . Plugin::NS_CARDDAV . '}address-data'];
+                    }
                     break;
                 case '{'.Plugin::NS_CARDDAV.'}filter' :
 
-                    if (!is_null($filter)) {
+                    if (!is_null($newProps['filters'])) {
                         throw new BadRequest('You can only include 1 {' . Plugin::NS_CARDDAV . '}filter element');
                     }
                     if (isset($elem['attributes']['test'])) {
-                        $test = $elem['attributes']['test'];
-                        if ($test!=='allof' && $test!=='anyof') {
+                        $newProps['test'] = $elem['attributes']['test'];
+                        if ($newProps['test']!=='allof' && $newProps['test']!=='anyof') {
                             throw new BadRequest('The "test" attribute must be one of "allof" or "anyof"');
                         }
                     }
 
                     foreach($elem['value'] as $subElem) {
                         if ($subElem['name'] === '{' . Plugin::NS_CARDDAV . '}prop-filter') {
-                            if (is_null($filter)) {
-                                $filter = [];
+                            if (is_null($newProps['filters'])) {
+                                $newProps['filters'] = [];
                             }
-                            $filter[] = $subElem['value'];
+                            $newProps['filters'][] = $subElem['value'];
                         }
                     }
                     break;
                 case '{'.Plugin::NS_CARDDAV.'}limit' :
                     foreach($elem['value'] as $child) {
                         if ($child['name'] === '{'. Plugin::NS_CARDDAV .'}nresults') {
-                            $limit = (int)$child['value'];
+                            $newProps['limit'] = (int)$child['value'];
                         }
                     }
                     break;
@@ -123,22 +150,21 @@ class AddressBookQueryReport implements XmlDeserializable {
 
         }
 
-        if (is_null($filter)) {
+        if (is_null($newProps['filters'])) {
             /**
              * We are supposed to throw this error, but KDE sometimes does not
              * include the filter element, and we need to treat it as if no
              * filters are supplied
              */
             //throw new BadRequest('The {' . Plugin::NS_CARDDAV . '}filter element is required for this request');
-            $filter = [];
+            $newProps['filters'] = [];
 
         }
 
         $obj = new self();
-        $obj->properties = $properties;
-        $obj->filter = $filter;
-        $obj->test = $test;
-        $obj->limit = $limit;
+        foreach($newProps as $key=>$value) {
+            $obj->$key = $value;
+        }
 
         return $obj;
 
diff --git a/tests/Sabre/CardDAV/PluginTest.php b/tests/Sabre/CardDAV/PluginTest.php
index 0ef5a3a..8c0b53e 100644
--- a/tests/Sabre/CardDAV/PluginTest.php
+++ b/tests/Sabre/CardDAV/PluginTest.php
@@ -9,7 +9,6 @@ class PluginTest extends AbstractPluginTest {
 
     function testConstruct() {
 
-        $this->assertEquals('card', $this->server->xmlNamespaces[Plugin::NS_CARDDAV]);
         $this->assertEquals('{' . Plugin::NS_CARDDAV . '}addressbook', $this->server->resourceTypeMapping['Sabre\\CardDAV\\IAddressBook']);
 
         $this->assertTrue(in_array('addressbook', $this->plugin->getFeatures()));

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



More information about the Pkg-owncloud-commits mailing list