Tests: Fix database locking bug

pull/7203/head
Aleksander Machniak 5 years ago
parent 84aa5d93f1
commit 8080eb2c71

@ -146,18 +146,18 @@ class GeneralTest extends \Tests\Browser\TestCase
$browser->assertCheckboxState('_pretty_date', $this->settings['pretty_date']); $browser->assertCheckboxState('_pretty_date', $this->settings['pretty_date']);
$browser->assertCheckboxState('_display_next', $this->settings['display_next']); $browser->assertCheckboxState('_display_next', $this->settings['display_next']);
$browser->assertCheckboxState('_standard_windows', $this->settings['standard_windows']); $browser->assertCheckboxState('_standard_windows', $this->settings['standard_windows']);
});
});
// Assert the options have been saved in database properly // Assert the options have been saved in database properly
$prefs = \bootstrap::get_prefs(); $prefs = \bootstrap::get_prefs();
$options = array_diff(array_keys($this->settings), ['refresh_interval', 'pretty_date']); $options = array_diff(array_keys($this->settings), ['refresh_interval', 'pretty_date']);
foreach ($options as $option) { foreach ($options as $option) {
$this->assertEquals($this->settings[$option], $prefs[$option]); $this->assertEquals($this->settings[$option], $prefs[$option]);
} }
$this->assertEquals($this->settings['pretty_date'], $prefs['prettydate']); $this->assertEquals($this->settings['pretty_date'], $prefs['prettydate']);
$this->assertEquals($this->settings['refresh_interval'], $prefs['refresh_interval']/60); $this->assertEquals($this->settings['refresh_interval'], $prefs['refresh_interval']/60);
});
});
} }
} }

@ -243,7 +243,13 @@ class bootstrap
*/ */
public static function get_prefs() public static function get_prefs()
{ {
$db = rcmail::get_instance()->get_dbh(); $rcmail = rcmail::get_instance();
// Create a separate connection to the DB, otherwise
// we hit some strange and hard to investigate locking issues
$db = rcube_db::factory($rcmail->config->get('db_dsnw'), $rcmail->config->get('db_dsnr'), false);
$db->set_debug((bool)$rcmail->config->get('sql_debug'));
$query = $db->query("SELECT preferences FROM users WHERE username = ?", TESTS_USER); $query = $db->query("SELECT preferences FROM users WHERE username = ?", TESTS_USER);
$record = $db->fetch_assoc($query); $record = $db->fetch_assoc($query);

Loading…
Cancel
Save