From b60ae11db8b49aa2a06116625de07fa03349a8e3 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Wed, 23 Oct 2013 16:03:57 +0200 Subject: introducing new dav property {xmlns:oc="http://owncloud.org/ns}id --- lib/private/connector/sabre/node.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/private/connector/sabre/node.php') diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php index 3c2ad60f1dd..5c0fd2dcadc 100644 --- a/lib/private/connector/sabre/node.php +++ b/lib/private/connector/sabre/node.php @@ -45,6 +45,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * @var string */ protected $path; + /** * node fileinfo cache * @var array @@ -211,6 +212,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr * properties should be returned */ public function getProperties($properties) { + if (is_null($this->property_cache)) { $sql = 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ?'; $result = OC_DB::executeAudited( $sql, array( OC_User::getUser(), $this->path ) ); @@ -236,8 +238,11 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $props = array(); foreach($properties as $property) { - if (isset($this->property_cache[$property])) $props[$property] = $this->property_cache[$property]; + if (isset($this->property_cache[$property])) { + $props[$property] = $this->property_cache[$property]; + } } + return $props; } @@ -260,4 +265,15 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr } return $this->fileView; } + + /** + * @return mixed + */ + public function getFileId() + { + $this->getFileinfoCache(); + $instanceId = OC_Util::getInstanceId(); + $id = sprintf('%08d', $this->fileinfo_cache['fileid']); + return $instanceId . $id; + } } -- cgit v1.2.3 From b02a4857126337688e8ad40d5f74929d005037ac Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Wed, 23 Oct 2013 16:40:29 +0200 Subject: handle case where fileid is not set --- lib/private/connector/sabre/filesplugin.php | 5 ++++- lib/private/connector/sabre/node.php | 11 ++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/private/connector/sabre/node.php') diff --git a/lib/private/connector/sabre/filesplugin.php b/lib/private/connector/sabre/filesplugin.php index c9d43a038db..46ca14fadcd 100644 --- a/lib/private/connector/sabre/filesplugin.php +++ b/lib/private/connector/sabre/filesplugin.php @@ -59,7 +59,10 @@ class OC_Connector_Sabre_FilesPlugin extends Sabre_DAV_ServerPlugin unset($requestedProperties[array_search($fileid_propertyname, $requestedProperties)]); /** @var $node OC_Connector_Sabre_Node */ - $returnedProperties[200][$fileid_propertyname] = $node->getFileId(); + $fileId = $node->getFileId(); + if (!is_null($fileId)) { + $returnedProperties[200][$fileid_propertyname] = $fileId; + } } diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php index 5c0fd2dcadc..76fbc251100 100644 --- a/lib/private/connector/sabre/node.php +++ b/lib/private/connector/sabre/node.php @@ -272,8 +272,13 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr public function getFileId() { $this->getFileinfoCache(); - $instanceId = OC_Util::getInstanceId(); - $id = sprintf('%08d', $this->fileinfo_cache['fileid']); - return $instanceId . $id; + + if (isset($this->fileinfo_cache['fileid'])) { + $instanceId = OC_Util::getInstanceId(); + $id = sprintf('%08d', $this->fileinfo_cache['fileid']); + return $instanceId . $id; + } + + return null; } } -- cgit v1.2.3