Fix problem with non share collection item types being treated as collections
This commit is contained in:
parent
ff6141b1e9
commit
37f0b85d3f
|
@ -458,8 +458,11 @@ class Share {
|
||||||
$collectionTypes[] = $type;
|
$collectionTypes[] = $type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!self::getBackend($itemType) instanceof Share_Backend_Collection) {
|
||||||
|
unset($collectionTypes[0]);
|
||||||
|
}
|
||||||
// Return array if collections were found or the item type is a collection itself - collections can be inside collections
|
// Return array if collections were found or the item type is a collection itself - collections can be inside collections
|
||||||
if (count($collectionTypes) > 1 || self::getBackend($itemType) instanceof Share_Backend_Collection) {
|
if (count($collectionTypes) > 0) {
|
||||||
return $collectionTypes;
|
return $collectionTypes;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -504,9 +507,14 @@ class Share {
|
||||||
$root = '';
|
$root = '';
|
||||||
if ($includeCollections && !isset($item) && ($collectionTypes = self::getCollectionItemTypes($itemType))) {
|
if ($includeCollections && !isset($item) && ($collectionTypes = self::getCollectionItemTypes($itemType))) {
|
||||||
// If includeCollections is true, find collections of this item type, e.g. a music album contains songs
|
// If includeCollections is true, find collections of this item type, e.g. a music album contains songs
|
||||||
$placeholders = join(',', array_fill(0, count($collectionTypes), '?'));
|
if (!in_array($itemType, $collectionTypes)) {
|
||||||
$where .= ' OR item_type IN ('.$placeholders.'))';
|
$itemTypes = array_merge(array($itemType), $collectionTypes);
|
||||||
$queryArgs = $collectionTypes;
|
} else {
|
||||||
|
$itemTypes = $collectionTypes;
|
||||||
|
}
|
||||||
|
$placeholders = join(',', array_fill(0, count($itemTypes), '?'));
|
||||||
|
$where .= ' WHERE item_type IN ('.$placeholders.'))';
|
||||||
|
$queryArgs = $itemTypes;
|
||||||
} else {
|
} else {
|
||||||
$where = ' WHERE `item_type` = ?';
|
$where = ' WHERE `item_type` = ?';
|
||||||
$queryArgs = array($itemType);
|
$queryArgs = array($itemType);
|
||||||
|
@ -580,7 +588,7 @@ class Share {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$queryArgs[] = $item;
|
$queryArgs[] = $item;
|
||||||
if ($includeCollections && $collectionTypes = self::getCollectionItemTypes($itemType)) {
|
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);
|
||||||
|
@ -689,7 +697,7 @@ class Share {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if this is a collection of the requested item type
|
// Check if this is a collection of the requested item type
|
||||||
if ($includeCollections && in_array($row['item_type'], $collectionTypes)) {
|
if ($includeCollections && $collectionTypes && in_array($row['item_type'], $collectionTypes)) {
|
||||||
if (($collectionBackend = self::getBackend($row['item_type'])) && $collectionBackend instanceof Share_Backend_Collection) {
|
if (($collectionBackend = self::getBackend($row['item_type'])) && $collectionBackend instanceof Share_Backend_Collection) {
|
||||||
// Collections can be inside collections, check if the item is a collection
|
// Collections can be inside collections, check if the item is a collection
|
||||||
if (isset($item) && $row['item_type'] == $itemType && $row[$column] == $item) {
|
if (isset($item) && $row['item_type'] == $itemType && $row[$column] == $item) {
|
||||||
|
|
Loading…
Reference in New Issue