Skip to content
Snippets Groups Projects
Commit 8b03b683 authored by Lukas Reschke's avatar Lukas Reschke
Browse files

Merge pull request #271 from owncloud/239_webdav_999_files

fixes #239 - query the database in chunks of 200
parents 49f05dfa 07ffa0de
No related branches found
No related tags found
No related merge requests found
......@@ -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,10 +123,16 @@ 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), '?'));
//
// 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($paths, OC_User::getUser()); // prepend userid
$result = $query->execute( $paths );
array_unshift($pack, OC_User::getUser()); // prepend userid
$result = $query->execute( $pack );
while($row = $result->fetchRow()) {
$propertypath = $row['propertypath'];
$propertyname = $row['propertyname'];
......@@ -135,6 +140,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
$properties[$propertypath][$propertyname] = $propertyvalue;
}
}
}
$nodes = array();
foreach($folder_content as $info) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment