I am using Moodle 2.1.10 on a Windows Server 2003 server with IIS and a SQL Server 2008 R2 database.
$CFG->dbtype is 'sqlsrv';
Please forgive me, but that old hardware won't run the latest version of Moodle...
Anyway, a student reported that she had completed and passed a quiz, but did not get the expected credit in the gradebook for that course. I can see that the quiz attempt was successfully submitted and graded, but for some reason no grade was written to the gradebook. To fix that I normally regrade the quiz attempt and that solves the problem.
But in this case the quiz attempt regrade abended with a timeout error:
PHP Fatal error: Maximum execution time of 30 seconds exceeded in \lib\dml\sqlsrv_native_moodle_database.php on line 362
The max_execution_time in my php.ini file is set to 1800, so that's not the problem.
So I fired up my PHP editor and had a look at the private function do_query(...) in the \lib\dml\sqlsrv_native_moodle_database.php page. I added a QueryTimeout parameter to sqlsrv_query() like this:
$sql = $this->emulate_bound_params($sql, $params);
$this->query_start($sql, $params, $sql_query_type);
if (!$scrollable) { // Only supporting next row
$result = sqlsrv_query($this->sqlsrv, $sql);
} else { // Supporting absolute/relative rows
-- $result = sqlsrv_query($this->sqlsrv, $sql, array(), array('Scrollable' => SQLSRV_CURSOR_STATIC));
++ $result = sqlsrv_query($this->sqlsrv, $sql, array(), array('Scrollable' => SQLSRV_CURSOR_STATIC, 'QueryTimeout' => 900));
}
That doesn't seem to have broken anything, but is there any reason for me not to do this? Will it cause any regressions elsewhere in Moodle? (I'll probably revert the change after I've managed to regrade the bad quiz attempt on production.)
This quiz regrade timeout was never a problem in Moodle 2.0.4+ which we were running up until a few weeks ago.