Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
9fe34ef9
Commit
9fe34ef9
authored
Nov 08, 2016
by
Jörn Friedrich Dreyer
Committed by
Thomas Müller
Nov 08, 2016
Browse files
use query builder (#26425)
* use query builder * test no longer needs to mock the dbtype * close cursor early
parent
00968e55
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/private/AllConfig.php
View file @
9fe34ef9
...
...
@@ -28,6 +28,7 @@
*/
namespace
OC
;
use
Doctrine\DBAL\Platforms\OraclePlatform
;
use
OC\Cache\CappedMemoryCache
;
use
OCP\IDBConnection
;
use
OCP\PreConditionNotMetException
;
...
...
@@ -410,23 +411,38 @@ class AllConfig implements \OCP\IConfig {
// TODO - FIXME
$this
->
fixDIInit
();
$sql
=
'SELECT `userid` FROM `*PREFIX*preferences` '
.
'WHERE `appid` = ? AND `configkey` = ? '
;
if
(
$this
->
getSystemValue
(
'dbtype'
,
'sqlite'
)
===
'oci'
)
{
//oracle hack: need to explicitly cast CLOB to CHAR for comparison
$sql
.
=
'AND to_char(`configvalue`) = ?'
;
$queryBuilder
=
$this
->
connection
->
getQueryBuilder
();
$queryBuilder
->
select
(
'userid'
)
->
from
(
'preferences'
)
->
where
(
$queryBuilder
->
expr
()
->
eq
(
'appid'
,
$queryBuilder
->
createNamedParameter
(
$appName
))
)
->
andWhere
(
$queryBuilder
->
expr
()
->
eq
(
'configkey'
,
$queryBuilder
->
createNamedParameter
(
$key
))
)
->
andWhere
(
$queryBuilder
->
expr
()
->
isNotNull
(
'configvalue'
));
if
(
$this
->
connection
->
getDatabasePlatform
()
instanceof
OraclePlatform
)
{
//oracle can only compare the first 4000 bytes of a CLOB column
$queryBuilder
->
andWhere
(
$queryBuilder
->
expr
()
->
eq
(
$queryBuilder
->
createFunction
(
'dbms_lob.substr(`configvalue`, 4000, 1)'
),
$queryBuilder
->
createNamedParameter
(
$value
))
);
}
else
{
$sql
.
=
'AND `configvalue` = ?'
;
$queryBuilder
->
andWhere
(
$queryBuilder
->
expr
()
->
eq
(
'configvalue'
,
$queryBuilder
->
createNamedParameter
(
$value
))
);
}
$result
=
$this
->
connection
->
executeQuery
(
$sql
,
[
$appName
,
$key
,
$value
]);
$query
=
$queryBuilder
->
execute
();
$userIDs
=
[];
while
(
$row
=
$
result
->
fetch
())
{
while
(
$row
=
$
query
->
fetch
())
{
$userIDs
[]
=
$row
[
'userid'
];
}
$query
->
closeCursor
();
return
$userIDs
;
}
}
tests/lib/AllConfigTest.php
View file @
9fe34ef9
...
...
@@ -404,11 +404,6 @@ class AllConfigTest extends \Test\TestCase {
$systemConfig
=
$this
->
getMockBuilder
(
'\OC\SystemConfig'
)
->
disableOriginalConstructor
()
->
getMock
();
$systemConfig
->
expects
(
$this
->
once
())
->
method
(
'getValue'
)
->
with
(
$this
->
equalTo
(
'dbtype'
),
$this
->
equalTo
(
'sqlite'
))
->
will
(
$this
->
returnValue
(
\
OC
::
$server
->
getConfig
()
->
getSystemValue
(
'dbtype'
,
'sqlite'
)));
$config
=
$this
->
getConfig
(
$systemConfig
);
// preparation - add something to the database
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment