Commit bb1817e5 authored by alexpott's avatar alexpott

Issue #1969846 by rootatwc: Convert session_write_interval() to settings.

parent d2e5e7b7
......@@ -169,7 +169,7 @@ function _drupal_session_write($sid, $value) {
// For performance reasons, do not update the sessions table, unless
// $_SESSION has changed or more than 180 has passed since the last update.
if ($is_changed || !isset($user->timestamp) || REQUEST_TIME - $user->timestamp > variable_get('session_write_interval', 180)) {
if ($is_changed || !isset($user->timestamp) || REQUEST_TIME - $user->timestamp > settings()->get('session_write_interval', 180)) {
// Either ssid or sid or both will be added from $key below.
$fields = array(
'uid' => $user->uid,
......@@ -206,7 +206,7 @@ function _drupal_session_write($sid, $value) {
}
// Likewise, do not update access time more than once per 180 seconds.
if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) {
if ($user->uid && REQUEST_TIME - $user->access > settings()->get('session_write_interval', 180)) {
db_update('users')
->fields(array(
'access' => REQUEST_TIME
......
......@@ -228,7 +228,13 @@ function testSessionWrite() {
$this->assertEqual($times4->timestamp, $times3->timestamp, 'Sessions table was not updated.');
// Force updating of users and sessions table once per second.
variable_set('session_write_interval', 0);
$this->settingsSet('session_write_interval', 0);
// Write that value also into the test settings.php file.
$settings['settings']['session_write_interval'] = (object) array(
'value' => 0,
'required' => TRUE,
);
$this->writeSettings($settings);
$this->drupalGet('');
$times5 = db_query($sql, array(':uid' => $user->uid))->fetchObject();
$this->assertNotEqual($times5->access, $times4->access, 'Users table was updated.');
......
......@@ -451,6 +451,14 @@
*/
# $settings['mixed_mode_sessions'] = TRUE;
/**
* Session write interval:
*
* Set the minimum interval between each session write to database.
* For performance reasons it defaults to 180.
*/
# $settings['session_write_interval'] = 180;
/**
* Base URL (optional).
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment