Skip to content

Commit 2b202b0

Browse files
committed
Document: # fix total document tool size usage calculation to avoid documents that have many registries in c_item_property - refs BT#22562
1 parent d005bcd commit 2b202b0

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

main/inc/lib/document.lib.php

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,23 +3293,27 @@ public static function documents_total_space($course_id = null, $group_id = null
32933293
}
32943294

32953295
$sql = "SELECT SUM(size)
3296-
FROM $TABLE_ITEMPROPERTY AS props
3297-
INNER JOIN $TABLE_DOCUMENT AS docs
3298-
ON (docs.id = props.ref AND props.c_id = docs.c_id)
3299-
WHERE
3300-
props.c_id = $course_id AND
3301-
docs.c_id = $course_id AND
3302-
props.tool = '".TOOL_DOCUMENT."' AND
3303-
props.ref not in (
3304-
SELECT ref
3305-
FROM $TABLE_ITEMPROPERTY as cip
3306-
WHERE
3307-
cip.c_id = $course_id AND
3308-
cip.tool = '".TOOL_DOCUMENT."' AND
3309-
cip.visibility = 2
3310-
)
3311-
$group_condition
3312-
$session_condition
3296+
FROM (
3297+
SELECT ref, size
3298+
FROM $TABLE_ITEMPROPERTY AS props
3299+
INNER JOIN $TABLE_DOCUMENT AS docs
3300+
ON (docs.id = props.ref AND props.c_id = docs.c_id)
3301+
WHERE
3302+
props.c_id = $course_id AND
3303+
docs.c_id = $course_id AND
3304+
props.tool = '".TOOL_DOCUMENT."' AND
3305+
props.ref not in (
3306+
SELECT ref
3307+
FROM $TABLE_ITEMPROPERTY as cip
3308+
WHERE
3309+
cip.c_id = $course_id AND
3310+
cip.tool = '".TOOL_DOCUMENT."' AND
3311+
cip.visibility = 2
3312+
)
3313+
$group_condition
3314+
$session_condition
3315+
GROUP BY props.ref
3316+
) AS table1
33133317
";
33143318
$result = Database::query($sql);
33153319

0 commit comments

Comments
 (0)