-
Bug
-
Resolution: Fixed
-
Blocker
-
3.0.9
-
None
-
PHP 5.3.6, MSSQL 2005
I am running two boards on 3.0.9, and recently upgraded my server to PHP 5.3.6. I am running my PHPBB against MSSQL 2005, and as a result of moving to the newer version of PHP, I had to switch from the MSSQL to the MSSQLNative database driver.
A few days later, I noticed that both boards had stopped sending email out, and the "Last On" date was not being updated. Looking into the problem, I realized that cron.php was not running correctly. After some debugging, I discovered the problem was with the new SQL driver - specifically, the sql_affectedrows function in /includes/db/mssqlnative.php.
The problem was that when cron.php attempted to update the cron-lock config value, it would look at the sql_affectedrows value afterward, to ensure that it had actually updated the lock (to ensure no other process had jumped in). However, the sql_affectedrows function in mssqlnative.php is incorrect, and would always return nothing - so the cron job would abort, and no processing would be done, even though the cron-lock config had been updated successfully.
Investigating mssqlnative.php, I found the following on line 399:
return ($this->db_connect_id) ? @sqlsrv_rows_affected($this->db_connect_id) : false;
The problem is that sqlsrv_rows_affected is not expecting db_connect_id as a parameter, it's expecting query_result. Changing the line thus fixes the problem:
return ($this->query_result) ? @sqlsrv_rows_affected($this->query_result) : false;