[Pkg-owncloud-commits] [php-sabredav] 04/16: Fixed order of triggering events.
David Prévot
taffit at moszumanska.debian.org
Sat Sep 5 15:23:56 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch 2.1
in repository php-sabredav.
commit 67632c4557bb17dceb27d9619c14e75807b68a8f
Author: Evert Pot <me at evertpot.com>
Date: Wed Sep 2 17:27:40 2015 +0200
Fixed order of triggering events.
oops. thnx @staabm
---
lib/DAV/CorePlugin.php | 9 +++++++--
tests/Sabre/DAV/HttpMoveTest.php | 11 ++++++-----
tests/Sabre/DAV/Mock/Collection.php | 2 +-
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/lib/DAV/CorePlugin.php b/lib/DAV/CorePlugin.php
index a4469e1..bc23310 100644
--- a/lib/DAV/CorePlugin.php
+++ b/lib/DAV/CorePlugin.php
@@ -633,13 +633,18 @@ class CorePlugin extends ServerPlugin {
if ($moveInfo['destinationExists']) {
if (!$this->server->emit('beforeUnbind',[$moveInfo['destination']])) return false;
+
+ }
+ if (!$this->server->emit('beforeUnbind',[$path])) return false;
+ if (!$this->server->emit('beforeBind',[$moveInfo['destination']])) return false;
+
+ if ($moveInfo['destinationExists']) {
+
$this->server->tree->delete($moveInfo['destination']);
$this->server->emit('afterUnbind',[$moveInfo['destination']]);
}
- if (!$this->server->emit('beforeUnbind',[$path])) return false;
- if (!$this->server->emit('beforeBind',[$moveInfo['destination']])) return false;
$this->server->tree->move($path, $moveInfo['destination']);
$this->server->emit('afterUnbind',[$path]);
$this->server->emit('afterBind',[$moveInfo['destination']]);
diff --git a/tests/Sabre/DAV/HttpMoveTest.php b/tests/Sabre/DAV/HttpMoveTest.php
index 03ad150..b6c0d3c 100644
--- a/tests/Sabre/DAV/HttpMoveTest.php
+++ b/tests/Sabre/DAV/HttpMoveTest.php
@@ -101,8 +101,7 @@ class HttpMoveTest extends DAVServerTest {
$this->server->on('beforeUnbind', function($path) {
if ($path==='file1') {
- // Block file1 from being deleted.
- return false;
+ throw new \Sabre\DAV\Exception\Forbidden('uh oh');
}
});
@@ -110,9 +109,11 @@ class HttpMoveTest extends DAVServerTest {
'Destination' => '/file2'
]);
$response = $this->request($request);
- $this->assertEquals(204, $response->getStatus(), print_r($response,true));
- $this->assertEquals('content1', $this->tree->getChild('file2')->get());
- $this->assertFalse($this->tree->childExists('file1'));
+ $this->assertEquals(403, $response->getStatus(), print_r($response,true));
+ $this->assertEquals('content1', $this->tree->getChild('file1')->get());
+ $this->assertEquals('content2', $this->tree->getChild('file2')->get());
+ $this->assertTrue($this->tree->childExists('file1'));
+ $this->assertTrue($this->tree->childExists('file2'));
}
}
diff --git a/tests/Sabre/DAV/Mock/Collection.php b/tests/Sabre/DAV/Mock/Collection.php
index 461e538..a119521 100644
--- a/tests/Sabre/DAV/Mock/Collection.php
+++ b/tests/Sabre/DAV/Mock/Collection.php
@@ -105,7 +105,7 @@ class Collection extends DAV\Collection {
*/
public function createDirectory($name) {
- $this->children = new Collection($name);
+ $this->children[] = new Collection($name);
}
--
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