refactor: Port away from more IQueryBuilder::execute

Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
Carl Schwan 2025-10-02 14:39:14 +02:00
parent c267036030
commit 9e848551be
8 changed files with 19 additions and 49 deletions

View file

@ -9,7 +9,9 @@ namespace OCA\Testing\Locking;
use OC\Lock\DBLockingProvider;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use Override;
class FakeDBLockingProvider extends DBLockingProvider {
// Lock for 10 hours just to be sure
@ -28,14 +30,16 @@ class FakeDBLockingProvider extends DBLockingProvider {
$this->db = $connection;
}
/** @inheritDoc */
#[Override]
public function releaseLock(string $path, int $type): void {
// we DONT keep shared locks till the end of the request
// we DON'T keep shared locks till the end of the request
if ($type === self::LOCK_SHARED) {
$this->db->executeUpdate(
'UPDATE `*PREFIX*file_locks` SET `lock` = 0 WHERE `key` = ? AND `lock` = 1',
[$path]
);
$qb = $this->db->getQueryBuilder();
$qb->update('file_locks')
->set('lock', $qb->createNamedParameter(0, IQueryBuilder::PARAM_INT))
->where($qb->expr()->eq('key', $qb->createNamedParameter($path, IQueryBuilder::PARAM_STR)))
->andWhere($qb->expr()->eq('lock', $qb->createNamedParameter(1, IQueryBuilder::PARAM_INT)))
->executeStatement();
}
parent::releaseLock($path, $type);

View file

@ -2132,11 +2132,6 @@
<code><![CDATA[setAppValue]]></code>
</DeprecatedMethod>
</file>
<file src="apps/testing/lib/Locking/FakeDBLockingProvider.php">
<DeprecatedMethod>
<code><![CDATA[executeUpdate]]></code>
</DeprecatedMethod>
</file>
<file src="apps/testing/lib/Provider/FakeText2ImageProvider.php">
<DeprecatedInterface>
<code><![CDATA[FakeText2ImageProvider]]></code>
@ -2674,7 +2669,6 @@
</file>
<file src="core/Command/Db/ConvertType.php">
<DeprecatedMethod>
<code><![CDATA[execute]]></code>
<code><![CDATA[getName]]></code>
<code><![CDATA[getPrimaryKeyColumns]]></code>
</DeprecatedMethod>
@ -3021,34 +3015,6 @@
<code><![CDATA[$this->request->server]]></code>
</NoInterfaceProperties>
</file>
<file src="core/Migrations/Version13000Date20170718121200.php">
<DeprecatedMethod>
<code><![CDATA[execute]]></code>
<code><![CDATA[execute]]></code>
<code><![CDATA[execute]]></code>
</DeprecatedMethod>
</file>
<file src="core/Migrations/Version14000Date20180404140050.php">
<DeprecatedMethod>
<code><![CDATA[execute]]></code>
</DeprecatedMethod>
</file>
<file src="core/Migrations/Version16000Date20190427105638.php">
<DeprecatedMethod>
<code><![CDATA[execute]]></code>
</DeprecatedMethod>
</file>
<file src="core/Migrations/Version18000Date20190920085628.php">
<DeprecatedMethod>
<code><![CDATA[execute]]></code>
</DeprecatedMethod>
</file>
<file src="core/Migrations/Version20000Date20201109081918.php">
<DeprecatedMethod>
<code><![CDATA[execute]]></code>
<code><![CDATA[execute]]></code>
</DeprecatedMethod>
</file>
<file src="core/Service/LoginFlowV2Service.php">
<DeprecatedClass>
<code><![CDATA[IToken::DO_NOT_REMEMBER]]></code>

View file

@ -358,7 +358,7 @@ class ConvertType extends Command implements CompletionAwareInterface {
$insertQuery->setParameter($key, $value);
}
}
$insertQuery->execute();
$insertQuery->executeStatement();
}
$result->closeCursor();

View file

@ -31,7 +31,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
if ($table->hasColumn('fileid')) {
$qb = $this->connection->getQueryBuilder();
$qb->delete('properties');
$qb->execute();
$qb->executeStatement();
}
}
@ -1008,6 +1008,7 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
$query = $this->connection->getQueryBuilder();
$query->select('*')
->from('dav_properties');
$result = $query->executeQuery();
$insert = $this->connection->getQueryBuilder();
$insert->insert('properties')
@ -1016,14 +1017,13 @@ class Version13000Date20170718121200 extends SimpleMigrationStep {
->setValue('propertyvalue', $insert->createParameter('propertyvalue'))
->setValue('userid', $insert->createParameter('userid'));
$result = $query->execute();
while ($row = $result->fetch()) {
preg_match('/(calendar)\/([A-z0-9-@_]+)\//', $row['propertypath'], $match);
$insert->setParameter('propertypath', (string)$row['propertypath'])
->setParameter('propertyname', (string)$row['propertyname'])
->setParameter('propertyvalue', (string)$row['propertyvalue'])
->setParameter('userid', ($match[2] ?? ''));
$insert->execute();
$insert->executeStatement();
}
}
}

View file

@ -62,6 +62,6 @@ class Version14000Date20180404140050 extends SimpleMigrationStep {
$qb->update('users')
->set('uid_lower', $qb->func()->lower('uid'));
$qb->execute();
$qb->executeStatement();
}
}

View file

@ -29,7 +29,7 @@ class Version16000Date20190427105638 extends SimpleMigrationStep {
$this->connection
->getQueryBuilder()
->delete('collres_accesscache')
->execute();
->executeStatement();
}
/**

View file

@ -55,6 +55,6 @@ class Version18000Date20190920085628 extends SimpleMigrationStep {
$query = $this->connection->getQueryBuilder();
$query->update('groups')
->set('displayname', 'gid');
$query->execute();
$query->executeStatement();
}
}

View file

@ -77,12 +77,12 @@ class Version20000Date20201109081918 extends SimpleMigrationStep {
->setValue('identifier', $insert->createParameter('identifier'))
->setValue('credentials', $insert->createParameter('credentials'));
$result = $query->execute();
$result = $query->executeQuery();
while ($row = $result->fetch()) {
$insert->setParameter('user', (string)$row['user'])
->setParameter('identifier', (string)$row['identifier'])
->setParameter('credentials', (string)$row['credentials']);
$insert->execute();
$insert->executeStatement();
}
$result->closeCursor();
}