Skip to content

Commit 4060877

Browse files
authored
Merge pull request phpbb#6789 from rxu/ticket/17475
[ticket/17475] Fix MSSQL arithmetic overflow error on counting attachments size
2 parents 84a835a + 14a6322 commit 4060877

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

phpBB/includes/acp/acp_attachments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ function main($id, $mode)
10771077
$attachments_per_page = (int) $config['topics_per_page'];
10781078

10791079
// Get total number or orphans older than 3 hours
1080-
$sql = 'SELECT COUNT(attach_id) as num_files, SUM(filesize) as total_size
1080+
$sql = 'SELECT COUNT(attach_id) as num_files, SUM(' . $this->db->cast_expr_to_bigint('filesize') . ') as total_size
10811081
FROM ' . ATTACHMENTS_TABLE . '
10821082
WHERE is_orphan = 1
10831083
AND filetime < ' . (time() - 3*60*60);

phpBB/includes/acp/acp_forums.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,7 @@ function delete_forum_content($forum_id)
20712071

20722072
$config->set('num_files', (int) $row['stat'], false);
20732073

2074-
$sql = 'SELECT SUM(filesize) as stat
2074+
$sql = 'SELECT SUM(' . $db->cast_expr_to_bigint('filesize') . ') as stat
20752075
FROM ' . ATTACHMENTS_TABLE;
20762076
$result = $db->sql_query($sql);
20772077
$row = $db->sql_fetchrow($result);

phpBB/includes/acp/acp_main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function main($id, $mode)
182182
$config->set('num_files', (int) $db->sql_fetchfield('stat'), false);
183183
$db->sql_freeresult($result);
184184

185-
$sql = 'SELECT SUM(filesize) as stat
185+
$sql = 'SELECT SUM(' . $db->cast_expr_to_bigint('filesize') . ') as stat
186186
FROM ' . ATTACHMENTS_TABLE . '
187187
WHERE is_orphan = 0';
188188
$result = $db->sql_query($sql);

phpBB/includes/functions_convert.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ function update_dynamic_config()
19981998
$config->set('num_files', (int) $db->sql_fetchfield('stat'), false);
19991999
$db->sql_freeresult($result);
20002000

2001-
$sql = 'SELECT SUM(filesize) as stat
2001+
$sql = 'SELECT SUM(' . $db->cast_expr_to_bigint('filesize') . ') as stat
20022002
FROM ' . ATTACHMENTS_TABLE . '
20032003
WHERE is_orphan = 0';
20042004
$result = $db->sql_query($sql);

0 commit comments

Comments
 (0)