Skip to content

Commit 051e9b8

Browse files
authored
Merge pull request #988 from nextcloud/carl/port-away-execute
chore(migration): Port away from deprecated IQueryBuilder::execute
2 parents 3afe763 + e8b8fab commit 051e9b8

File tree

7 files changed

+1197
-15
lines changed

7 files changed

+1197
-15
lines changed

REUSE.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,9 @@ path = "tests/integration/vendor/symfony/**"
106106
precedence = "aggregate"
107107
SPDX-FileCopyrightText = "Fabien Potencier"
108108
SPDX-License-Identifier = "MIT"
109+
110+
[[annotations]]
111+
path = ["tests/stubs/doctrine_dbal_**"]
112+
precedence = "aggregate"
113+
SPDX-FileCopyrightText = "none"
114+
SPDX-License-Identifier = "MIT"

lib/Migration/Version5000Date20211025124248.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ protected function deleteOldConfiguration(array $keys): bool {
151151

152152
$deletedRows = $this->deleteQuery
153153
->setParameter('cfgKeys', $keys, IQueryBuilder::PARAM_STR_ARRAY)
154-
->execute();
154+
->executeStatement();
155155

156156
return $deletedRows > 0;
157157
}
@@ -174,7 +174,7 @@ protected function insertConfiguration(int $id, array $configData): bool {
174174
->setParameter('configId', $id)
175175
->setParameter('displayName', $configData['general-idp0_display_name'] ?? '')
176176
->setParameter('configuration', \json_encode($configData, JSON_THROW_ON_ERROR))
177-
->execute();
177+
->executeStatement();
178178

179179
return $insertedRows > 0;
180180
}
@@ -190,7 +190,7 @@ protected function readConfiguration(array $configKeys): \Generator {
190190
}
191191

192192
$r = $this->readQuery->setParameter('cfgKeys', $configKeys, IQueryBuilder::PARAM_STR_ARRAY)
193-
->execute();
193+
->executeQuery();
194194

195195
while ($row = $r->fetch()) {
196196
yield $row;
@@ -216,7 +216,7 @@ protected function fetchPrefixes(): array {
216216
->where($q->expr()->eq('appid', $q->createNamedParameter('user_saml')))
217217
->andWhere($q->expr()->eq('configkey', $q->createNamedParameter('providerIds')));
218218

219-
$r = $q->execute();
219+
$r = $q->executeQuery();
220220
$prefixes = $r->fetchOne();
221221
if ($prefixes === false) {
222222
return [1]; // 1 is the default value for providerIds
@@ -229,6 +229,6 @@ protected function deletePrefixes(): void {
229229
$q->delete('appconfig')
230230
->where($q->expr()->eq('appid', $q->createNamedParameter('user_saml')))
231231
->andWhere($q->expr()->eq('configkey', $q->createNamedParameter('providerIds')))
232-
->execute();
232+
->executeStatement();
233233
}
234234
}

psalm.xml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
>
1616
<stubs>
1717
<file name="tests/stub.phpstub" preloadClasses="true"/>
18+
<file name="tests/stubs/doctrine_dbal_schema_abstractasset.php" />
19+
<file name="tests/stubs/doctrine_dbal_schema_column.php" />
20+
<file name="tests/stubs/doctrine_dbal_schema_schema.php" />
21+
<file name="tests/stubs/doctrine_dbal_schema_table.php" />
1822
</stubs>
1923
<projectFiles>
2024
<directory name="lib" />
@@ -31,18 +35,8 @@
3135
<DeprecatedConstant errorLevel="info" />
3236
<UndefinedClass>
3337
<errorLevel type="suppress">
34-
<referencedClass name="Doctrine\DBAL\Types\Types"/>
3538
<referencedClass name="Symfony\Component\Console\Command\Command"/>
3639
</errorLevel>
3740
</UndefinedClass>
38-
<UndefinedDocblockClass>
39-
<errorLevel type="suppress">
40-
<referencedClass name="Doctrine\DBAL\Driver\Statement" />
41-
<referencedClass name="Doctrine\DBAL\Schema\Schema" />
42-
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
43-
<referencedClass name="Doctrine\DBAL\Schema\Table" />
44-
<referencedClass name="Doctrine\DBAL\Statement" />
45-
</errorLevel>
46-
</UndefinedDocblockClass>
4741
</issueHandlers>
4842
</psalm>
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<?php
2+
3+
namespace Doctrine\DBAL\Schema;
4+
5+
use Doctrine\DBAL\Platforms\AbstractPlatform;
6+
7+
/**
8+
* The abstract asset allows to reset the name of all assets without publishing this to the public userland.
9+
*
10+
* This encapsulation hack is necessary to keep a consistent state of the database schema. Say we have a list of tables
11+
* array($tableName => Table($tableName)); if you want to rename the table, you have to make sure this does not get
12+
* recreated during schema migration.
13+
*/
14+
abstract class AbstractAsset {
15+
/** @var string */
16+
protected $_name = '';
17+
18+
/**
19+
* Namespace of the asset. If none isset the default namespace is assumed.
20+
*
21+
* @var string|null
22+
*/
23+
protected $_namespace;
24+
25+
/** @var bool */
26+
protected $_quoted = false;
27+
28+
/**
29+
* Sets the name of this asset.
30+
*
31+
* @param string $name
32+
*
33+
* @return void
34+
*/
35+
protected function _setName($name) {
36+
}
37+
38+
/**
39+
* Is this asset in the default namespace?
40+
*
41+
* @param string $defaultNamespaceName
42+
*
43+
* @return bool
44+
*/
45+
public function isInDefaultNamespace($defaultNamespaceName) {
46+
}
47+
48+
/**
49+
* Gets the namespace name of this asset.
50+
*
51+
* If NULL is returned this means the default namespace is used.
52+
*
53+
* @return string|null
54+
*/
55+
public function getNamespaceName() {
56+
}
57+
58+
/**
59+
* The shortest name is stripped of the default namespace. All other
60+
* namespaced elements are returned as full-qualified names.
61+
*
62+
* @param string|null $defaultNamespaceName
63+
*
64+
* @return string
65+
*/
66+
public function getShortestName($defaultNamespaceName) {
67+
}
68+
69+
/**
70+
* The normalized name is full-qualified and lower-cased. Lower-casing is
71+
* actually wrong, but we have to do it to keep our sanity. If you are
72+
* using database objects that only differentiate in the casing (FOO vs
73+
* Foo) then you will NOT be able to use Doctrine Schema abstraction.
74+
*
75+
* Every non-namespaced element is prefixed with the default namespace
76+
* name which is passed as argument to this method.
77+
*
78+
* @deprecated Use {@see getNamespaceName()} and {@see getName()} instead.
79+
*
80+
* @param string $defaultNamespaceName
81+
*
82+
* @return string
83+
*/
84+
public function getFullQualifiedName($defaultNamespaceName) {
85+
}
86+
87+
/**
88+
* Checks if this asset's name is quoted.
89+
*
90+
* @return bool
91+
*/
92+
public function isQuoted() {
93+
}
94+
95+
/**
96+
* Checks if this identifier is quoted.
97+
*
98+
* @param string $identifier
99+
*
100+
* @return bool
101+
*/
102+
protected function isIdentifierQuoted($identifier) {
103+
}
104+
105+
/**
106+
* Trim quotes from the identifier.
107+
*
108+
* @param string $identifier
109+
*
110+
* @return string
111+
*/
112+
protected function trimQuotes($identifier) {
113+
}
114+
115+
/**
116+
* Returns the name of this schema asset.
117+
*
118+
* @return string
119+
*/
120+
public function getName() {
121+
}
122+
123+
/**
124+
* Gets the quoted representation of this asset but only if it was defined with one. Otherwise
125+
* return the plain unquoted value as inserted.
126+
*
127+
* @return string
128+
*/
129+
public function getQuotedName(AbstractPlatform $platform) {
130+
}
131+
132+
/**
133+
* Generates an identifier from a list of column names obeying a certain string length.
134+
*
135+
* This is especially important for Oracle, since it does not allow identifiers larger than 30 chars,
136+
* however building idents automatically for foreign keys, composite keys or such can easily create
137+
* very long names.
138+
*
139+
* @param string[] $columnNames
140+
* @param string $prefix
141+
* @param int $maxSize
142+
*
143+
* @return string
144+
*/
145+
protected function _generateIdentifierName($columnNames, $prefix = '', $maxSize = 30) {
146+
}
147+
}

0 commit comments

Comments
 (0)