My upload (files) directory exceeded 2GB recently, and when this occurred, anyone attempting to post an image with an attachment received this error:
Code: Select all
SQL ERROR [ mssqlnative ]
SQLSTATE: 22003 code: 8115 message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Arithmetic overflow error converting expression to data type int. SQLSTATE: 01000 code: 3621 message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]The statement has been terminated. [3621]
SQL
UPDATE phpbb_config SET config_value = config_value + 157133 WHERE config_name = 'upload_dir_size'
The problem is that the config value is supposed to be converted to a bigint before being written to the database, but there was never a "conversion to bigint" implementation written in the MSSQL driver. So MSSQL defaults to using int, and the largest number you can store in an int is 2,147,483,647. Once your upload directory exceeds this value (in bytes), this crash will occur when attempting to upload any more attachments.
To fix the bug, open \phpbb\db\driver\mssql_base.php. Add the following missing function override to it:
Code: Select all
/**
* {@inheritDoc}
*/
function cast_expr_to_bigint($expression)
{
return 'CONVERT(BIGINT, ' . $expression . ')';
}