aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2024-07-19 16:40:49 +0200
committerGitHub <noreply@github.com>2024-07-19 16:40:49 +0200
commit7395211c1a5bf435e3be66d7a021f6cbb99ab1ab (patch)
treec958695ffa44082bf971b2f223f3a81606b1f738 /apps
parent8f975cda34b4b4f181646a54c15f7c511d6e8491 (diff)
parentb656edc47c50376140971e11d1325147cb1e49c9 (diff)
downloadnextcloud-server-7395211c1a5bf435e3be66d7a021f6cbb99ab1ab.tar.gz
nextcloud-server-7395211c1a5bf435e3be66d7a021f6cbb99ab1ab.zip
Merge pull request #46605 from nextcloud/bugfix/noid/test-more-oracle-versions
fix(deps): Deprecate functionality deprecated by doctrine and test on more oracle versions
Diffstat (limited to 'apps')
-rw-r--r--apps/contactsinteraction/lib/Db/CardSearchDao.php20
-rw-r--r--apps/contactsinteraction/lib/Db/RecentContactMapper.php14
-rw-r--r--apps/dav/lib/CalDAV/CalDavBackend.php64
-rw-r--r--apps/dav/lib/CardDAV/CardDavBackend.php12
-rw-r--r--apps/dav/lib/DAV/CustomPropertiesBackend.php2
-rw-r--r--apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php3
-rw-r--r--apps/settings/tests/SetupChecks/SupportedDatabaseTest.php4
-rw-r--r--apps/user_ldap/lib/Mapping/AbstractMapping.php4
8 files changed, 65 insertions, 58 deletions
diff --git a/apps/contactsinteraction/lib/Db/CardSearchDao.php b/apps/contactsinteraction/lib/Db/CardSearchDao.php
index 962f9ff768b..0929cb7efa0 100644
--- a/apps/contactsinteraction/lib/Db/CardSearchDao.php
+++ b/apps/contactsinteraction/lib/Db/CardSearchDao.php
@@ -29,24 +29,24 @@ class CardSearchDao {
$cardQuery = $this->db->getQueryBuilder();
$propQuery = $this->db->getQueryBuilder();
- $propOr = $propQuery->expr()->orX();
+ $additionalWheres = [];
if ($uid !== null) {
- $propOr->add($propQuery->expr()->andX(
+ $additionalWheres[] = $propQuery->expr()->andX(
$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('UID')),
$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($uid))
- ));
+ );
}
if ($email !== null) {
- $propOr->add($propQuery->expr()->andX(
+ $additionalWheres[] = $propQuery->expr()->andX(
$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('EMAIL')),
$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($email))
- ));
+ );
}
if ($cloudId !== null) {
- $propOr->add($propQuery->expr()->andX(
+ $additionalWheres[] = $propQuery->expr()->andX(
$propQuery->expr()->eq('name', $cardQuery->createNamedParameter('CLOUD')),
$propQuery->expr()->eq('value', $cardQuery->createNamedParameter($cloudId))
- ));
+ );
}
$addressbooksQuery->selectDistinct('id')
->from('addressbooks')
@@ -54,8 +54,12 @@ class CardSearchDao {
$propQuery->selectDistinct('cardid')
->from('cards_properties')
->where($propQuery->expr()->in('addressbookid', $propQuery->createFunction($addressbooksQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
- ->andWhere($propOr)
->groupBy('cardid');
+
+ if (!empty($additionalWheres)) {
+ $propQuery->andWhere($propQuery->expr()->orX(...$additionalWheres));
+ }
+
$cardQuery->select('carddata')
->from('cards')
->where($cardQuery->expr()->in('id', $cardQuery->createFunction($propQuery->getSQL()), IQueryBuilder::PARAM_INT_ARRAY))
diff --git a/apps/contactsinteraction/lib/Db/RecentContactMapper.php b/apps/contactsinteraction/lib/Db/RecentContactMapper.php
index e0b2ac723fb..c835b5287c8 100644
--- a/apps/contactsinteraction/lib/Db/RecentContactMapper.php
+++ b/apps/contactsinteraction/lib/Db/RecentContactMapper.php
@@ -61,23 +61,25 @@ class RecentContactMapper extends QBMapper {
?string $cloudId): array {
$qb = $this->db->getQueryBuilder();
- $or = $qb->expr()->orX();
+ $additionalWheres = [];
if ($uid !== null) {
- $or->add($qb->expr()->eq('uid', $qb->createNamedParameter($uid)));
+ $additionalWheres[] = $qb->expr()->eq('uid', $qb->createNamedParameter($uid));
}
if ($email !== null) {
- $or->add($qb->expr()->eq('email', $qb->createNamedParameter($email)));
+ $additionalWheres[] = $qb->expr()->eq('email', $qb->createNamedParameter($email));
}
if ($cloudId !== null) {
- $or->add($qb->expr()->eq('federated_cloud_id', $qb->createNamedParameter($cloudId)));
+ $additionalWheres[] = $qb->expr()->eq('federated_cloud_id', $qb->createNamedParameter($cloudId));
}
$select = $qb
->select('*')
->from($this->getTableName())
- ->where($or)
- ->andWhere($qb->expr()->eq('actor_uid', $qb->createNamedParameter($user->getUID())));
+ ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($user->getUID())));
+ if (!empty($additionalWheres)) {
+ $select->andWhere($select->expr()->orX(...$additionalWheres));
+ }
return $this->findEntities($select);
}
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php
index d25276fe16d..49e99201df1 100644
--- a/apps/dav/lib/CalDAV/CalDavBackend.php
+++ b/apps/dav/lib/CalDAV/CalDavBackend.php
@@ -1875,12 +1875,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
if (!empty($searchProperties)) {
- $or = $innerQuery->expr()->orX();
+ $or = [];
foreach ($searchProperties as $searchProperty) {
- $or->add($innerQuery->expr()->eq('op.name',
- $outerQuery->createNamedParameter($searchProperty)));
+ $or[] = $innerQuery->expr()->eq('op.name',
+ $outerQuery->createNamedParameter($searchProperty));
}
- $innerQuery->andWhere($or);
+ $innerQuery->andWhere($innerQuery->expr()->orX(...$or));
}
if ($pattern !== '') {
@@ -1924,12 +1924,12 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
if (!empty($options['types'])) {
- $or = $outerQuery->expr()->orX();
+ $or = [];
foreach ($options['types'] as $type) {
- $or->add($outerQuery->expr()->eq('componenttype',
- $outerQuery->createNamedParameter($type)));
+ $or[] = $outerQuery->expr()->eq('componenttype',
+ $outerQuery->createNamedParameter($type));
}
- $outerQuery->andWhere($or);
+ $outerQuery->andWhere($outerQuery->expr()->orX(...$or));
}
$outerQuery->andWhere($outerQuery->expr()->in('c.id', $outerQuery->createFunction($innerQuery->getSQL())));
@@ -2150,16 +2150,17 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$escapePattern = !\array_key_exists('escape_like_param', $options) || $options['escape_like_param'] !== false;
$calendarObjectIdQuery = $this->db->getQueryBuilder();
- $calendarOr = $calendarObjectIdQuery->expr()->orX();
- $searchOr = $calendarObjectIdQuery->expr()->orX();
+ $calendarOr = [];
+ $searchOr = [];
// Fetch calendars and subscription
$calendars = $this->getCalendarsForUser($principalUri);
$subscriptions = $this->getSubscriptionsForUser($principalUri);
foreach ($calendars as $calendar) {
- $calendarAnd = $calendarObjectIdQuery->expr()->andX();
- $calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$calendar['id'])));
- $calendarAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)));
+ $calendarAnd = $calendarObjectIdQuery->expr()->andX(
+ $calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$calendar['id'])),
+ $calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_CALENDAR)),
+ );
// If it's shared, limit search to public events
if (isset($calendar['{http://owncloud.org/ns}owner-principal'])
@@ -2167,12 +2168,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$calendarAnd->add($calendarObjectIdQuery->expr()->eq('co.classification', $calendarObjectIdQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC)));
}
- $calendarOr->add($calendarAnd);
+ $calendarOr[] = $calendarAnd;
}
foreach ($subscriptions as $subscription) {
- $subscriptionAnd = $calendarObjectIdQuery->expr()->andX();
- $subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$subscription['id'])));
- $subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)));
+ $subscriptionAnd = $calendarObjectIdQuery->expr()->andX(
+ $calendarObjectIdQuery->expr()->eq('cob.calendarid', $calendarObjectIdQuery->createNamedParameter((int)$subscription['id'])),
+ $calendarObjectIdQuery->expr()->eq('cob.calendartype', $calendarObjectIdQuery->createNamedParameter(self::CALENDAR_TYPE_SUBSCRIPTION)),
+ );
// If it's shared, limit search to public events
if (isset($subscription['{http://owncloud.org/ns}owner-principal'])
@@ -2180,28 +2182,30 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
$subscriptionAnd->add($calendarObjectIdQuery->expr()->eq('co.classification', $calendarObjectIdQuery->createNamedParameter(self::CLASSIFICATION_PUBLIC)));
}
- $calendarOr->add($subscriptionAnd);
+ $calendarOr[] = $subscriptionAnd;
}
foreach ($searchProperties as $property) {
- $propertyAnd = $calendarObjectIdQuery->expr()->andX();
- $propertyAnd->add($calendarObjectIdQuery->expr()->eq('cob.name', $calendarObjectIdQuery->createNamedParameter($property, IQueryBuilder::PARAM_STR)));
- $propertyAnd->add($calendarObjectIdQuery->expr()->isNull('cob.parameter'));
+ $propertyAnd = $calendarObjectIdQuery->expr()->andX(
+ $calendarObjectIdQuery->expr()->eq('cob.name', $calendarObjectIdQuery->createNamedParameter($property, IQueryBuilder::PARAM_STR)),
+ $calendarObjectIdQuery->expr()->isNull('cob.parameter'),
+ );
- $searchOr->add($propertyAnd);
+ $searchOr[] = $propertyAnd;
}
foreach ($searchParameters as $property => $parameter) {
- $parameterAnd = $calendarObjectIdQuery->expr()->andX();
- $parameterAnd->add($calendarObjectIdQuery->expr()->eq('cob.name', $calendarObjectIdQuery->createNamedParameter($property, IQueryBuilder::PARAM_STR)));
- $parameterAnd->add($calendarObjectIdQuery->expr()->eq('cob.parameter', $calendarObjectIdQuery->createNamedParameter($parameter, IQueryBuilder::PARAM_STR_ARRAY)));
+ $parameterAnd = $calendarObjectIdQuery->expr()->andX(
+ $calendarObjectIdQuery->expr()->eq('cob.name', $calendarObjectIdQuery->createNamedParameter($property, IQueryBuilder::PARAM_STR)),
+ $calendarObjectIdQuery->expr()->eq('cob.parameter', $calendarObjectIdQuery->createNamedParameter($parameter, IQueryBuilder::PARAM_STR_ARRAY)),
+ );
- $searchOr->add($parameterAnd);
+ $searchOr[] = $parameterAnd;
}
- if ($calendarOr->count() === 0) {
+ if (empty($calendarOr)) {
return [];
}
- if ($searchOr->count() === 0) {
+ if (empty($searchOr)) {
return [];
}
@@ -2209,8 +2213,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
->from($this->dbObjectPropertiesTable, 'cob')
->leftJoin('cob', 'calendarobjects', 'co', $calendarObjectIdQuery->expr()->eq('co.id', 'cob.objectid'))
->andWhere($calendarObjectIdQuery->expr()->in('co.componenttype', $calendarObjectIdQuery->createNamedParameter($componentTypes, IQueryBuilder::PARAM_STR_ARRAY)))
- ->andWhere($calendarOr)
- ->andWhere($searchOr)
+ ->andWhere($calendarObjectIdQuery->expr()->orX(...$calendarOr))
+ ->andWhere($calendarObjectIdQuery->expr()->orX(...$searchOr))
->andWhere($calendarObjectIdQuery->expr()->isNull('deleted_at'));
if ($pattern !== '') {
diff --git a/apps/dav/lib/CardDAV/CardDavBackend.php b/apps/dav/lib/CardDAV/CardDavBackend.php
index cdbbc228047..9d787c917d3 100644
--- a/apps/dav/lib/CardDAV/CardDavBackend.php
+++ b/apps/dav/lib/CardDAV/CardDavBackend.php
@@ -1148,20 +1148,20 @@ class CardDavBackend implements BackendInterface, SyncSupport {
/**
* FIXME Find a way to match only 4 last digits
* BDAY can be --1018 without year or 20001019 with it
- * $bDayOr = $query2->expr()->orX();
+ * $bDayOr = [];
* if ($options['since'] instanceof DateTimeFilter) {
- * $bDayOr->add(
+ * $bDayOr[] =
* $query2->expr()->gte('SUBSTR(cp_bday.value, -4)',
- * $query2->createNamedParameter($options['since']->get()->format('md')))
+ * $query2->createNamedParameter($options['since']->get()->format('md'))
* );
* }
* if ($options['until'] instanceof DateTimeFilter) {
- * $bDayOr->add(
+ * $bDayOr[] =
* $query2->expr()->lte('SUBSTR(cp_bday.value, -4)',
- * $query2->createNamedParameter($options['until']->get()->format('md')))
+ * $query2->createNamedParameter($options['until']->get()->format('md'))
* );
* }
- * $query2->andWhere($bDayOr);
+ * $query2->andWhere($query2->expr()->orX(...$bDayOr));
*/
}
diff --git a/apps/dav/lib/DAV/CustomPropertiesBackend.php b/apps/dav/lib/DAV/CustomPropertiesBackend.php
index ab62ae36c2c..f4dd9b2d038 100644
--- a/apps/dav/lib/DAV/CustomPropertiesBackend.php
+++ b/apps/dav/lib/DAV/CustomPropertiesBackend.php
@@ -411,7 +411,7 @@ class CustomPropertiesBackend implements BackendInterface {
// request only a subset
$sql .= ' AND `propertyname` in (?)';
$whereValues[] = $requestedProperties;
- $whereTypes[] = \Doctrine\DBAL\Connection::PARAM_STR_ARRAY;
+ $whereTypes[] = IQueryBuilder::PARAM_STR_ARRAY;
}
$result = $this->connection->executeQuery(
diff --git a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
index cbce847a298..c7f57dcb117 100644
--- a/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
+++ b/apps/dav/lib/Migration/CalDAVRemoveEmptyValue.php
@@ -5,7 +5,6 @@
*/
namespace OCA\DAV\Migration;
-use Doctrine\DBAL\Platforms\OraclePlatform;
use OCA\DAV\CalDAV\CalDavBackend;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
@@ -75,7 +74,7 @@ class CalDAVRemoveEmptyValue implements IRepairStep {
}
protected function getInvalidObjects($pattern) {
- if ($this->db->getDatabasePlatform() instanceof OraclePlatform) {
+ if ($this->db->getDatabaseProvider() === IDBConnection::PLATFORM_ORACLE) {
$rows = [];
$chunkSize = 500;
$query = $this->db->getQueryBuilder();
diff --git a/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php b/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
index 2492379b557..0ba1621c5fe 100644
--- a/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
+++ b/apps/settings/tests/SetupChecks/SupportedDatabaseTest.php
@@ -8,7 +8,6 @@ declare(strict_types=1);
*/
namespace OCA\Settings\Tests;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
use OCA\Settings\SetupChecks\SupportedDatabase;
use OCP\IDBConnection;
use OCP\IL10N;
@@ -41,8 +40,7 @@ class SupportedDatabaseTest extends TestCase {
}
public function testPass(): void {
- $platform = $this->connection->getDatabasePlatform();
- if ($platform instanceof SqlitePlatform) {
+ if ($this->connection->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE) {
/** SQlite always gets a warning */
$this->assertEquals(SetupResult::WARNING, $this->check->run()->getSeverity());
} else {
diff --git a/apps/user_ldap/lib/Mapping/AbstractMapping.php b/apps/user_ldap/lib/Mapping/AbstractMapping.php
index c243731eaf7..79d23b8d618 100644
--- a/apps/user_ldap/lib/Mapping/AbstractMapping.php
+++ b/apps/user_ldap/lib/Mapping/AbstractMapping.php
@@ -8,9 +8,9 @@
namespace OCA\User_LDAP\Mapping;
use Doctrine\DBAL\Exception;
-use Doctrine\DBAL\Platforms\SqlitePlatform;
use OCP\DB\IPreparedStatement;
use OCP\DB\QueryBuilder\IQueryBuilder;
+use OCP\IDBConnection;
use Psr\Log\LoggerInterface;
/**
@@ -216,7 +216,7 @@ abstract class AbstractMapping {
public function getListOfIdsByDn(array $fdns): array {
$totalDBParamLimit = 65000;
$sliceSize = 1000;
- $maxSlices = $this->dbc->getDatabasePlatform() instanceof SqlitePlatform ? 9 : $totalDBParamLimit / $sliceSize;
+ $maxSlices = $this->dbc->getDatabaseProvider() === IDBConnection::PLATFORM_SQLITE ? 9 : $totalDBParamLimit / $sliceSize;
$results = [];
$slice = 1;