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

8.0.x
Alex Pott 2013-04-18 09:30:42 +01:00
parent d2e5e7b77a
commit bb1817e515
3 changed files with 17 additions and 3 deletions

View File

@ -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

View File

@ -228,7 +228,13 @@ class SessionTest extends WebTestBase {
$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.');

View File

@ -451,6 +451,14 @@ $settings['update_free_access'] = FALSE;
*/
# $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).
*