[Pkg-owncloud-commits] [php-sabredav] 105/275: Issue 482: PropFind::set() hard adds properties during ALLPROPS

David Prévot taffit at moszumanska.debian.org
Thu Sep 25 14:55:57 UTC 2014


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

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

commit da4f5b97208d1c859e85687d90fe22547a4c5551
Author: Alfred Klomp <git at alfredklomp.com>
Date:   Sat Jul 26 19:34:39 2014 +0200

    Issue 482: PropFind::set() hard adds properties during ALLPROPS
    
    See Issue 482. Properties handled on propFind with PropFind::set() were
    not being added to an ALLPROPS response, even though that would be
    expected. Ensure that any properties being added through set() are added
    to an ALLPROPS response.
---
 lib/DAV/PropFind.php             | 24 +++++++++++++++---------
 tests/Sabre/DAV/PropFindTest.php | 11 +++++++++++
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/lib/DAV/PropFind.php b/lib/DAV/PropFind.php
index 810a7db..247a0af 100644
--- a/lib/DAV/PropFind.php
+++ b/lib/DAV/PropFind.php
@@ -120,17 +120,23 @@ class PropFind {
      */
     public function set($propertyName, $value, $status = null) {
 
-        if (isset($this->result[$propertyName])) {
-            if (is_null($status)) {
-                $status = is_null($value) ? 404 : 200;
-            }
-            if ($status!==404 && $this->result[$propertyName][0]===404) {
-                $this->itemsLeft--;
-            } elseif ($status === 404 && $this->result[$propertyName][0] !== 404) {
-                $this->itemsLeft++;
+        if (is_null($status)) {
+            $status = is_null($value) ? 404 : 200;
+        }
+        // If this is an ALLPROPS request and the property is
+        // unknown, add it to the result; else ignore it:
+        if (!isset($this->result[$propertyName])) {
+            if ($this->requestType === self::ALLPROPS) {
+                $this->result[$propertyName] = [$status, $value];
             }
-            $this->result[$propertyName] = [$status, $value];
+            return;
+        }
+        if ($status!==404 && $this->result[$propertyName][0]===404) {
+            $this->itemsLeft--;
+        } elseif ($status === 404 && $this->result[$propertyName][0] !== 404) {
+            $this->itemsLeft++;
         }
+        $this->result[$propertyName] = [$status, $value];
 
     }
 
diff --git a/tests/Sabre/DAV/PropFindTest.php b/tests/Sabre/DAV/PropFindTest.php
index 51fd71c..ec1d616 100644
--- a/tests/Sabre/DAV/PropFindTest.php
+++ b/tests/Sabre/DAV/PropFindTest.php
@@ -50,6 +50,17 @@ class PropFindTest extends \PHPUnit_Framework_TestCase {
 
     }
 
+    function testSetAllpropCustom() {
+
+        $propFind = new PropFind('foo', ['{DAV:}displayname'], 0, PropFind::ALLPROPS);
+        $propFind->set('{DAV:}customproperty', 'bar');
+
+        $this->assertEquals([
+            200 => ['{DAV:}customproperty' => 'bar'],
+        ], $propFind->getResultForMultiStatus());
+
+    }
+
     function testSetUnset() {
 
         $propFind = new PropFind('foo', ['{DAV:}displayname']);

-- 
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