Preferences: Fix saving preferences when using a database store
Our DbSelect::where() is not (or no longer?) compatible w/ Zend_Db_Select::where(). DbStore::load() now uses Zend_Db_Select but we should definitely think about our DbSelect::where() implementation. fixes #7353
This commit is contained in:
parent
c4554ac692
commit
1b83ec3ce2
|
@ -72,9 +72,11 @@ class DbStore extends PreferencesStore
|
|||
public function load()
|
||||
{
|
||||
try {
|
||||
$select = $this->getStoreConfig()->connection->select();
|
||||
$result = $select->from($this->table, array(self::COLUMN_PREFERENCE, self::COLUMN_VALUE))
|
||||
$select = $this->getStoreConfig()->connection->getDbAdapter()->select();
|
||||
$result = $select
|
||||
->from($this->table, array(self::COLUMN_PREFERENCE, self::COLUMN_VALUE))
|
||||
->where(self::COLUMN_USERNAME . ' = ?', $this->getUser()->getUsername())
|
||||
->query()
|
||||
->fetchAll();
|
||||
} catch (Exception $e) {
|
||||
throw new NotReadableError(
|
||||
|
@ -132,7 +134,7 @@ class DbStore extends PreferencesStore
|
|||
*/
|
||||
protected function insert(array $preferences)
|
||||
{
|
||||
$db = $this->getStoreConfig()->connection->getConnection();
|
||||
$db = $this->getStoreConfig()->connection->getDbAdapter();
|
||||
|
||||
try {
|
||||
foreach ($preferences as $key => $value) {
|
||||
|
@ -163,7 +165,7 @@ class DbStore extends PreferencesStore
|
|||
*/
|
||||
protected function update(array $preferences)
|
||||
{
|
||||
$db = $this->getStoreConfig()->connection->getConnection();
|
||||
$db = $this->getStoreConfig()->connection->getDbAdapter();
|
||||
|
||||
try {
|
||||
foreach ($preferences as $key => $value) {
|
||||
|
@ -194,7 +196,7 @@ class DbStore extends PreferencesStore
|
|||
*/
|
||||
protected function delete(array $preferenceKeys)
|
||||
{
|
||||
$db = $this->getStoreConfig()->connection->getConnection();
|
||||
$db = $this->getStoreConfig()->connection->getDbAdapter();
|
||||
|
||||
try {
|
||||
$db->delete(
|
||||
|
|
|
@ -167,7 +167,7 @@ class DbStoreTest extends BaseTestCase
|
|||
return new DbStoreWithSetPreferences(
|
||||
new Zend_Config(
|
||||
array(
|
||||
'connection' => Mockery::mock(array('getConnection' => $dbMock))
|
||||
'connection' => Mockery::mock(array('getDbAdapter' => $dbMock))
|
||||
)
|
||||
),
|
||||
Mockery::mock('Icinga\User', array('getUsername' => 'unittest'))
|
||||
|
|
Loading…
Reference in New Issue