Merge pull request #371 from butonic/sql_and_error_log_fixes

add missing sql backticks, check sharing for error and add log
This commit is contained in:
blizzz 2012-11-12 03:37:43 -08:00
commit e0fdb8272b
1 changed files with 5 additions and 2 deletions

View File

@ -548,7 +548,7 @@ class Share {
$itemTypes = $collectionTypes; $itemTypes = $collectionTypes;
} }
$placeholders = join(',', array_fill(0, count($itemTypes), '?')); $placeholders = join(',', array_fill(0, count($itemTypes), '?'));
$where .= ' WHERE item_type IN ('.$placeholders.'))'; $where .= ' WHERE `item_type` IN ('.$placeholders.'))';
$queryArgs = $itemTypes; $queryArgs = $itemTypes;
} else { } else {
$where = ' WHERE `item_type` = ?'; $where = ' WHERE `item_type` = ?';
@ -625,7 +625,7 @@ class Share {
$queryArgs[] = $item; $queryArgs[] = $item;
if ($includeCollections && $collectionTypes) { if ($includeCollections && $collectionTypes) {
$placeholders = join(',', array_fill(0, count($collectionTypes), '?')); $placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
$where .= ' OR item_type IN ('.$placeholders.'))'; $where .= ' OR `item_type` IN ('.$placeholders.'))';
$queryArgs = array_merge($queryArgs, $collectionTypes); $queryArgs = array_merge($queryArgs, $collectionTypes);
} }
} }
@ -673,6 +673,9 @@ class Share {
$root = strlen($root); $root = strlen($root);
$query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$where, $queryLimit); $query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$where, $queryLimit);
$result = $query->execute($queryArgs); $result = $query->execute($queryArgs);
if (\OC_DB::isError($result)) {
\OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where, \OC_Log::ERROR);
}
$items = array(); $items = array();
$targets = array(); $targets = array();
while ($row = $result->fetchRow()) { while ($row = $result->fetchRow()) {