aboutsummaryrefslogtreecommitdiffstats
path: root/lib/connector
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2012-11-14 10:53:00 -0800
committerLukas Reschke <lukas@statuscode.ch>2012-11-14 10:53:00 -0800
commit8b03b683dfc3d612fcc72f404f2dac19d06e203f (patch)
tree0ae87f4820670e6f783f685a5b5aea1ae0a8d03f /lib/connector
parent49f05dfadefc5ec38ff413adeeccae7fe5317dd8 (diff)
parent07ffa0de39f410b1c6d70608b7cdeb39275ae670 (diff)
downloadnextcloud-server-8b03b683dfc3d612fcc72f404f2dac19d06e203f.tar.gz
nextcloud-server-8b03b683dfc3d612fcc72f404f2dac19d06e203f.zip
Merge pull request #271 from owncloud/239_webdav_999_files
fixes #239 - query the database in chunks of 200
Diffstat (limited to 'lib/connector')
-rw-r--r--lib/connector/sabre/directory.php26
1 files changed, 16 insertions, 10 deletions
diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php
index b6e02569d2a..6076aed6fcd 100644
--- a/lib/connector/sabre/directory.php
+++ b/lib/connector/sabre/directory.php
@@ -116,7 +116,6 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
* @return Sabre_DAV_INode[]
*/
public function getChildren() {
-
$folder_content = OC_Files::getDirectoryContent($this->path);
$paths = array();
foreach($folder_content as $info) {
@@ -124,15 +123,22 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
}
$properties = array_fill_keys($paths, array());
if(count($paths)>0) {
- $placeholders = join(',', array_fill(0, count($paths), '?'));
- $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ?' . ' AND `propertypath` IN ('.$placeholders.')' );
- array_unshift($paths, OC_User::getUser()); // prepend userid
- $result = $query->execute( $paths );
- while($row = $result->fetchRow()) {
- $propertypath = $row['propertypath'];
- $propertyname = $row['propertyname'];
- $propertyvalue = $row['propertyvalue'];
- $properties[$propertypath][$propertyname] = $propertyvalue;
+ //
+ // the number of arguments within IN conditions are limited in most databases
+ // we chunk $paths into arrays of 200 items each to meet this criteria
+ //
+ $chunks = array_chunk($paths, 200, false);
+ foreach ($chunks as $pack) {
+ $placeholders = join(',', array_fill(0, count($pack), '?'));
+ $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ?' . ' AND `propertypath` IN ('.$placeholders.')' );
+ array_unshift($pack, OC_User::getUser()); // prepend userid
+ $result = $query->execute( $pack );
+ while($row = $result->fetchRow()) {
+ $propertypath = $row['propertypath'];
+ $propertyname = $row['propertyname'];
+ $propertyvalue = $row['propertyvalue'];
+ $properties[$propertypath][$propertyname] = $propertyvalue;
+ }
}
}