Issue #1969846 by rootatwc: Convert session_write_interval() to settings.
parent
d2e5e7b77a
commit
bb1817e515
|
@ -169,7 +169,7 @@ function _drupal_session_write($sid, $value) {
|
||||||
|
|
||||||
// For performance reasons, do not update the sessions table, unless
|
// For performance reasons, do not update the sessions table, unless
|
||||||
// $_SESSION has changed or more than 180 has passed since the last update.
|
// $_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.
|
// Either ssid or sid or both will be added from $key below.
|
||||||
$fields = array(
|
$fields = array(
|
||||||
'uid' => $user->uid,
|
'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.
|
// 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')
|
db_update('users')
|
||||||
->fields(array(
|
->fields(array(
|
||||||
'access' => REQUEST_TIME
|
'access' => REQUEST_TIME
|
||||||
|
|
|
@ -228,7 +228,13 @@ class SessionTest extends WebTestBase {
|
||||||
$this->assertEqual($times4->timestamp, $times3->timestamp, 'Sessions table was not updated.');
|
$this->assertEqual($times4->timestamp, $times3->timestamp, 'Sessions table was not updated.');
|
||||||
|
|
||||||
// Force updating of users and sessions table once per second.
|
// 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('');
|
$this->drupalGet('');
|
||||||
$times5 = db_query($sql, array(':uid' => $user->uid))->fetchObject();
|
$times5 = db_query($sql, array(':uid' => $user->uid))->fetchObject();
|
||||||
$this->assertNotEqual($times5->access, $times4->access, 'Users table was updated.');
|
$this->assertNotEqual($times5->access, $times4->access, 'Users table was updated.');
|
||||||
|
|
|
@ -451,6 +451,14 @@ $settings['update_free_access'] = FALSE;
|
||||||
*/
|
*/
|
||||||
# $settings['mixed_mode_sessions'] = TRUE;
|
# $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).
|
* Base URL (optional).
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue