PluginProbe ʕ •ᴥ•ʔ
MailPoet – Newsletters, Email Marketing, and Automation / 5.36.0
MailPoet – Newsletters, Email Marketing, and Automation v5.36.0
5.36.0 5.35.1 5.35.0 5.34.3 5.34.2 5.34.1 5.34.0 5.33.1 5.33.0 5.32.0 5.31.0 5.30.0 5.29.0 5.28.1 5.28.0 5.27.0 5.26.0 5.26.1 5.25.0 5.24.0 4.43.0 4.43.1 4.44.0 4.44.1 4.45.0 4.46.0 4.47.0 4.48.0 4.48.1 4.48.2 4.49.0 4.49.1 4.5.0 4.5.1 4.5.2 4.50.0 4.50.1 4.51.0 4.51.1 4.51.2 4.52.0 4.53.0 4.54.0 4.55.0 4.56.0 4.57.0 4.58.0 4.58.1 4.58.2 4.6.0 4.6.1 4.6.2 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 5.0.0 5.0.1 5.0.2 5.1.0 5.1.1 5.10.0 5.10.1 5.11.0 5.12.0 5.12.1 5.12.10 5.12.11 5.12.12 5.12.13 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.12.7 5.12.8 5.12.9 5.13.0 5.13.1 5.13.2 5.14.0 5.14.1 5.14.2 5.14.3 5.15.0 5.15.1 5.16.0 5.16.1 5.16.2 5.16.3 5.16.4 5.17.0 5.17.1 5.17.2 5.17.3 5.17.4 5.17.5 5.17.6 5.18.0 5.19.0 5.2.0 5.2.1 5.2.2 5.2.3 5.20.0 5.21.0 5.21.1 5.21.2 5.21.3 5.22.0 5.22.1 5.22.2 5.22.3 5.22.4 5.23.0 5.23.1 5.23.2 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 5.5.2 5.6.0 5.6.1 5.6.2 5.6.3 5.6.4 5.7.0 5.7.1 5.8.0 5.8.1 5.9.0 3.0.0-beta.15 3.7.1 3.0.0-beta.16 3.7.2 3.0.0-beta.17 3.7.3 3.0.0-beta.18 3.7.4 3.0.0-beta.19 3.7.5 3.0.0-beta.2 3.7.6 3.0.0-beta.20 3.7.8 3.0.0-beta.21 3.70.0 3.0.0-beta.22 3.71.0 3.0.0-beta.23 3.71.1 3.0.0-beta.23.1 3.71.2 3.0.0-beta.23.2 3.71.3 3.0.0-beta.24 3.72.0 3.0.0-beta.25 3.73.0 3.0.0-beta.26 3.73.1 3.0.0-beta.27 3.73.2 3.0.0-beta.28 3.74.0 3.0.0-beta.29 3.74.1 3.0.0-beta.3 3.74.2 3.0.0-beta.30 3.74.3 3.0.0-beta.31 3.75.0 3.0.0-beta.32 3.75.1 3.0.0-beta.33 3.76.0 3.0.0-beta.33.1 3.77.0 3.0.0-beta.34.0.0 3.77.1 3.0.0-beta.36.0.0 3.78.0 3.0.0-beta.36.0.1 3.79.0 3.0.0-beta.36.2.0 3.8 3.0.0-beta.36.3.0 3.8.1 3.0.0-beta.36.3.1 3.8.2 3.0.0-beta.37.0.0 3.8.3 3.0.0-beta.4 3.8.4 3.0.0-beta.5 3.8.5 3.0.0-beta.6 3.8.6 3.0.0-beta.7 3.80.0 3.0.0-beta.7.1 3.81.0 3.0.0-beta.8 3.82.0 3.0.0-beta.9 3.83.0 3.0.0-rc.1.0.0 3.84.0 3.0.0-rc.1.0.1 3.84.1 3.0.0-rc.1.0.2 3.85.0 3.0.0-rc.1.0.3 3.85.1 3.0.0-rc.1.0.4 3.86.0 3.0.0-rc.2.0.0 3.87.0 3.0.0-rc.2.0.1 3.87.1 3.0.0-rc.2.0.2 3.87.2 3.0.0-rc.2.0.3 3.88.0 3.0.1 3.88.1 3.0.2 3.88.2 3.0.3 3.89.0 3.0.4 3.89.1 3.0.5 3.89.2 3.0.6 3.89.3 3.0.7 3.89.4 3.0.8 3.9.0 3.0.9 3.9.1 3.1.0 3.90.0 3.10 3.90.1 3.10.1 3.90.2 3.100.0 3.91.0 3.100.1 3.91.1 3.100.2 3.92.0 3.101.0 3.92.1 3.101.1 3.93.0 3.102.0 3.93.1 3.102.1 3.94.0 3.103.0 3.95.0 3.103.1 3.95.1 3.11.0 3.96.0 3.11.1 3.96.1 3.11.2 3.97.0 3.11.3 3.98.0 3.11.4 3.98.1 3.11.5 3.99.0 3.12.0 3.99.1 3.12.1 4.0.0 3.13.0 4.0.1 3.14.0 4.1.0 3.14.1 4.1.1 3.15.0 4.10.0 3.16.0 4.11.0 3.16.1 4.11.1 3.16.2 4.12.0 3.16.3 4.12.1 3.17.0 4.12.2 3.17.1 4.13.0 3.17.2 4.14.0 3.18.0 4.15.0 3.18.1 4.16.0 3.18.2 4.17.0 3.19.0 4.17.1 3.19.1 4.18.0 3.19.2 4.18.1 3.19.3 4.19.0 3.2.0 4.2.0 3.2.1 4.20.0 3.2.2 4.20.1 3.2.3 4.20.2 3.2.4 4.21.0 3.2.5 4.22.0 3.20.0 4.22.1 3.21.0 4.22.2 3.21.1 4.23.0 3.22.0 4.24.0 3.23.0 4.25.0 3.23.1 4.26.0 3.23.2 4.26.1 3.24.0 4.27.0 3.25.0 4.28.0 3.25.1 4.29.0 3.26.0 4.3.0 3.26.1 4.3.1 3.27.0 4.30.0 3.28.0 4.31.0 3.29.0 4.31.1 3.3.0 4.32.0 3.3.1 4.33.0 3.3.2 4.34.0 3.3.3 4.35.0 3.3.4 4.35.1 3.3.5 4.36.0 3.3.6 4.37.0 3.30.0 4.38.0 3.31.0 4.39.0 3.31.1 4.4.0 3.32.0 4.40.0 3.32.1 4.41.0 3.32.2 4.41.1 3.33.0 4.41.2 3.34.0 4.41.3 3.34.1 4.42.0 3.34.2 4.42.1 3.34.3 3.34.4 3.35.0 3.35.1 3.35.3 3.35.4 3.36.0 3.37.0 3.37.1 3.37.2 3.37.3 3.38.0 3.38.1 3.39.0 3.39.1 3.39.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.40.0 3.40.1 3.41.0 3.41.1 3.41.2 3.42.0 3.42.1 3.42.2 3.42.3 3.43.0 3.43.1 3.44.0 3.45.0 3.45.1 3.46.0 3.46.1 3.46.10 3.46.11 3.46.12 3.46.13 3.46.14 3.46.2 3.46.3 3.46.4 3.46.5 3.46.6 3.46.7 3.46.8 3.46.9 3.47.0 3.47.1 3.47.10 3.47.11 3.47.2 3.47.3 3.47.5 3.47.6 3.47.7 3.47.9 3.48.0 3.48.1 3.49.0 3.49.1 3.5.0 3.5.1 3.50.0 3.51.0 3.51.1 3.51.2 3.52.0 3.53.0 3.54.0 3.54.1 3.54.2 3.54.3 3.55.0 3.55.1 3.56.0 3.56.1 3.56.2 3.57.0 3.57.1 3.58.0 3.59.0 3.59.1 3.59.2 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.60.0 3.60.1 3.60.10 3.60.11 3.60.12 3.60.2 3.60.3 3.60.4 3.60.6 3.60.7 3.60.8 3.60.9 3.61.0 3.62.0 3.62.1 3.63.0 3.64.0 3.64.1 3.64.2 3.64.3 3.65.0 trunk 3.65.1 3.0.0 3.66.0 3.0.0-beta.1 3.67.0 3.0.0-beta.10 3.67.1 3.0.0-beta.11 3.68.0 3.0.0-beta.12 3.69.0 3.0.0-beta.13 3.69.1 3.0.0-beta.14 3.7.0
mailpoet / vendor-prefixed / doctrine / dbal / src / Schema / AbstractSchemaManager.php
mailpoet / vendor-prefixed / doctrine / dbal / src / Schema Last commit date
Exception 2 years ago Visitor 9 months ago AbstractAsset.php 2 years ago AbstractSchemaManager.php 9 months ago Column.php 2 years ago ColumnDiff.php 2 years ago Comparator.php 2 years ago Constraint.php 2 years ago DB2SchemaManager.php 2 years ago DefaultSchemaManagerFactory.php 2 years ago ForeignKeyConstraint.php 9 months ago Identifier.php 2 years ago Index.php 2 years ago LegacySchemaManagerFactory.php 2 years ago MySQLSchemaManager.php 9 months ago OracleSchemaManager.php 2 years ago PostgreSQLSchemaManager.php 9 months ago SQLServerSchemaManager.php 9 months ago Schema.php 2 years ago SchemaConfig.php 2 years ago SchemaDiff.php 2 years ago SchemaException.php 2 years ago SchemaManagerFactory.php 2 years ago Sequence.php 2 years ago SqliteSchemaManager.php 8 months ago Table.php 2 years ago TableDiff.php 2 years ago UniqueConstraint.php 2 years ago View.php 2 years ago
AbstractSchemaManager.php
663 lines
1 <?php
2 namespace MailPoetVendor\Doctrine\DBAL\Schema;
3 if (!defined('ABSPATH')) exit;
4 use MailPoetVendor\Doctrine\DBAL\Connection;
5 use MailPoetVendor\Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs;
6 use MailPoetVendor\Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs;
7 use MailPoetVendor\Doctrine\DBAL\Events;
8 use MailPoetVendor\Doctrine\DBAL\Exception;
9 use MailPoetVendor\Doctrine\DBAL\Exception\DatabaseRequired;
10 use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform;
11 use MailPoetVendor\Doctrine\DBAL\Result;
12 use MailPoetVendor\Doctrine\Deprecations\Deprecation;
13 use Throwable;
14 use function array_filter;
15 use function array_intersect;
16 use function array_map;
17 use function array_values;
18 use function assert;
19 use function call_user_func_array;
20 use function count;
21 use function func_get_args;
22 use function is_callable;
23 use function is_string;
24 use function preg_match;
25 use function str_replace;
26 use function strtolower;
27 abstract class AbstractSchemaManager
28 {
29 protected $_conn;
30 protected $_platform;
31 public function __construct(Connection $connection, AbstractPlatform $platform)
32 {
33 $this->_conn = $connection;
34 $this->_platform = $platform;
35 }
36 public function getDatabasePlatform()
37 {
38 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5387', 'AbstractSchemaManager::getDatabasePlatform() is deprecated.' . ' Use Connection::getDatabasePlatform() instead.');
39 return $this->_platform;
40 }
41 public function tryMethod()
42 {
43 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4897', 'AbstractSchemaManager::tryMethod() is deprecated.');
44 $args = func_get_args();
45 $method = $args[0];
46 unset($args[0]);
47 $args = array_values($args);
48 $callback = [$this, $method];
49 assert(is_callable($callback));
50 try {
51 return call_user_func_array($callback, $args);
52 } catch (Throwable $e) {
53 return \false;
54 }
55 }
56 public function listDatabases()
57 {
58 $sql = $this->_platform->getListDatabasesSQL();
59 $databases = $this->_conn->fetchAllAssociative($sql);
60 return $this->_getPortableDatabasesList($databases);
61 }
62 public function listNamespaceNames()
63 {
64 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4503', 'AbstractSchemaManager::listNamespaceNames() is deprecated,' . ' use AbstractSchemaManager::listSchemaNames() instead.');
65 $sql = $this->_platform->getListNamespacesSQL();
66 $namespaces = $this->_conn->fetchAllAssociative($sql);
67 return $this->getPortableNamespacesList($namespaces);
68 }
69 public function listSchemaNames() : array
70 {
71 throw Exception::notSupported(__METHOD__);
72 }
73 public function listSequences($database = null)
74 {
75 if ($database === null) {
76 $database = $this->getDatabase(__METHOD__);
77 } else {
78 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5284', 'Passing $database to AbstractSchemaManager::listSequences() is deprecated.');
79 }
80 $sql = $this->_platform->getListSequencesSQL($database);
81 $sequences = $this->_conn->fetchAllAssociative($sql);
82 return $this->filterAssetNames($this->_getPortableSequencesList($sequences));
83 }
84 public function listTableColumns($table, $database = null)
85 {
86 if ($database === null) {
87 $database = $this->getDatabase(__METHOD__);
88 } else {
89 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5284', 'Passing $database to AbstractSchemaManager::listTableColumns() is deprecated.');
90 }
91 $sql = $this->_platform->getListTableColumnsSQL($table, $database);
92 $tableColumns = $this->_conn->fetchAllAssociative($sql);
93 return $this->_getPortableTableColumnList($table, $database, $tableColumns);
94 }
95 protected function doListTableColumns($table, $database = null) : array
96 {
97 if ($database === null) {
98 $database = $this->getDatabase(__METHOD__);
99 } else {
100 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5284', 'Passing $database to AbstractSchemaManager::doListTableColumns() is deprecated.');
101 }
102 return $this->_getPortableTableColumnList($table, $database, $this->selectTableColumns($database, $this->normalizeName($table))->fetchAllAssociative());
103 }
104 public function listTableIndexes($table)
105 {
106 $sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase());
107 $tableIndexes = $this->_conn->fetchAllAssociative($sql);
108 return $this->_getPortableTableIndexesList($tableIndexes, $table);
109 }
110 protected function doListTableIndexes($table) : array
111 {
112 $database = $this->getDatabase(__METHOD__);
113 $table = $this->normalizeName($table);
114 return $this->_getPortableTableIndexesList($this->selectIndexColumns($database, $table)->fetchAllAssociative(), $table);
115 }
116 public function tablesExist($names)
117 {
118 if (is_string($names)) {
119 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/3580', 'The usage of a string $tableNames in AbstractSchemaManager::tablesExist() is deprecated. ' . 'Pass a one-element array instead.');
120 }
121 $names = array_map('strtolower', (array) $names);
122 return count($names) === count(array_intersect($names, array_map('strtolower', $this->listTableNames())));
123 }
124 public function listTableNames()
125 {
126 $sql = $this->_platform->getListTablesSQL();
127 $tables = $this->_conn->fetchAllAssociative($sql);
128 $tableNames = $this->_getPortableTablesList($tables);
129 return $this->filterAssetNames($tableNames);
130 }
131 protected function doListTableNames() : array
132 {
133 $database = $this->getDatabase(__METHOD__);
134 return $this->filterAssetNames($this->_getPortableTablesList($this->selectTableNames($database)->fetchAllAssociative()));
135 }
136 protected function filterAssetNames($assetNames)
137 {
138 $filter = $this->_conn->getConfiguration()->getSchemaAssetsFilter();
139 if ($filter === null) {
140 return $assetNames;
141 }
142 return array_values(array_filter($assetNames, $filter));
143 }
144 public function listTables()
145 {
146 $tableNames = $this->listTableNames();
147 $tables = [];
148 foreach ($tableNames as $tableName) {
149 $tables[] = $this->introspectTable($tableName);
150 }
151 return $tables;
152 }
153 protected function doListTables() : array
154 {
155 $database = $this->getDatabase(__METHOD__);
156 $tableColumnsByTable = $this->fetchTableColumnsByTable($database);
157 $indexColumnsByTable = $this->fetchIndexColumnsByTable($database);
158 $foreignKeyColumnsByTable = $this->fetchForeignKeyColumnsByTable($database);
159 $tableOptionsByTable = $this->fetchTableOptionsByTable($database);
160 $filter = $this->_conn->getConfiguration()->getSchemaAssetsFilter();
161 $tables = [];
162 foreach ($tableColumnsByTable as $tableName => $tableColumns) {
163 if ($filter !== null && !$filter($tableName)) {
164 continue;
165 }
166 $tables[] = new Table($tableName, $this->_getPortableTableColumnList($tableName, $database, $tableColumns), $this->_getPortableTableIndexesList($indexColumnsByTable[$tableName] ?? [], $tableName), [], $this->_getPortableTableForeignKeysList($foreignKeyColumnsByTable[$tableName] ?? []), $tableOptionsByTable[$tableName] ?? []);
167 }
168 return $tables;
169 }
170 public function listTableDetails($name)
171 {
172 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5595', '%s is deprecated. Use introspectTable() instead.', __METHOD__);
173 $columns = $this->listTableColumns($name);
174 $foreignKeys = [];
175 if ($this->_platform->supportsForeignKeyConstraints()) {
176 $foreignKeys = $this->listTableForeignKeys($name);
177 }
178 $indexes = $this->listTableIndexes($name);
179 return new Table($name, $columns, $indexes, [], $foreignKeys);
180 }
181 protected function doListTableDetails($name) : Table
182 {
183 $database = $this->getDatabase(__METHOD__);
184 $normalizedName = $this->normalizeName($name);
185 $tableOptionsByTable = $this->fetchTableOptionsByTable($database, $normalizedName);
186 if ($this->_platform->supportsForeignKeyConstraints()) {
187 $foreignKeys = $this->listTableForeignKeys($name);
188 } else {
189 $foreignKeys = [];
190 }
191 return new Table($name, $this->listTableColumns($name, $database), $this->listTableIndexes($name), [], $foreignKeys, $tableOptionsByTable[$normalizedName] ?? []);
192 }
193 protected function normalizeName(string $name) : string
194 {
195 $identifier = new Identifier($name);
196 return $identifier->getName();
197 }
198 protected function selectTableNames(string $databaseName) : Result
199 {
200 throw Exception::notSupported(__METHOD__);
201 }
202 protected function selectTableColumns(string $databaseName, ?string $tableName = null) : Result
203 {
204 throw Exception::notSupported(__METHOD__);
205 }
206 protected function selectIndexColumns(string $databaseName, ?string $tableName = null) : Result
207 {
208 throw Exception::notSupported(__METHOD__);
209 }
210 protected function selectForeignKeyColumns(string $databaseName, ?string $tableName = null) : Result
211 {
212 throw Exception::notSupported(__METHOD__);
213 }
214 protected function fetchTableColumnsByTable(string $databaseName) : array
215 {
216 return $this->fetchAllAssociativeGrouped($this->selectTableColumns($databaseName));
217 }
218 protected function fetchIndexColumnsByTable(string $databaseName) : array
219 {
220 return $this->fetchAllAssociativeGrouped($this->selectIndexColumns($databaseName));
221 }
222 protected function fetchForeignKeyColumnsByTable(string $databaseName) : array
223 {
224 if (!$this->_platform->supportsForeignKeyConstraints()) {
225 return [];
226 }
227 return $this->fetchAllAssociativeGrouped($this->selectForeignKeyColumns($databaseName));
228 }
229 protected function fetchTableOptionsByTable(string $databaseName, ?string $tableName = null) : array
230 {
231 throw Exception::notSupported(__METHOD__);
232 }
233 public function introspectTable(string $name) : Table
234 {
235 $table = $this->listTableDetails($name);
236 if ($table->getColumns() === []) {
237 throw SchemaException::tableDoesNotExist($name);
238 }
239 return $table;
240 }
241 public function listViews()
242 {
243 $database = $this->_conn->getDatabase();
244 $sql = $this->_platform->getListViewsSQL($database);
245 $views = $this->_conn->fetchAllAssociative($sql);
246 return $this->_getPortableViewsList($views);
247 }
248 public function listTableForeignKeys($table, $database = null)
249 {
250 if ($database === null) {
251 $database = $this->getDatabase(__METHOD__);
252 } else {
253 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5284', 'Passing $database to AbstractSchemaManager::listTableForeignKeys() is deprecated.');
254 }
255 $sql = $this->_platform->getListTableForeignKeysSQL($table, $database);
256 $tableForeignKeys = $this->_conn->fetchAllAssociative($sql);
257 return $this->_getPortableTableForeignKeysList($tableForeignKeys);
258 }
259 protected function doListTableForeignKeys($table, $database = null) : array
260 {
261 if ($database === null) {
262 $database = $this->getDatabase(__METHOD__);
263 } else {
264 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5284', 'Passing $database to AbstractSchemaManager::listTableForeignKeys() is deprecated.');
265 }
266 return $this->_getPortableTableForeignKeysList($this->selectForeignKeyColumns($database, $this->normalizeName($table))->fetchAllAssociative());
267 }
268 public function dropDatabase($database)
269 {
270 $this->_conn->executeStatement($this->_platform->getDropDatabaseSQL($database));
271 }
272 public function dropSchema(string $schemaName) : void
273 {
274 $this->_conn->executeStatement($this->_platform->getDropSchemaSQL($schemaName));
275 }
276 public function dropTable($name)
277 {
278 $this->_conn->executeStatement($this->_platform->getDropTableSQL($name));
279 }
280 public function dropIndex($index, $table)
281 {
282 if ($index instanceof Index) {
283 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4798', 'Passing $index as an Index object to %s is deprecated. Pass it as a quoted name instead.', __METHOD__);
284 $index = $index->getQuotedName($this->_platform);
285 }
286 if ($table instanceof Table) {
287 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4798', 'Passing $table as an Table object to %s is deprecated. Pass it as a quoted name instead.', __METHOD__);
288 $table = $table->getQuotedName($this->_platform);
289 }
290 $this->_conn->executeStatement($this->_platform->getDropIndexSQL($index, $table));
291 }
292 public function dropConstraint(Constraint $constraint, $table)
293 {
294 if ($table instanceof Table) {
295 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4798', 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.', __METHOD__);
296 $table = $table->getQuotedName($this->_platform);
297 }
298 $this->_conn->executeStatement($this->_platform->getDropConstraintSQL($constraint->getQuotedName($this->_platform), $table));
299 }
300 public function dropForeignKey($foreignKey, $table)
301 {
302 if ($foreignKey instanceof ForeignKeyConstraint) {
303 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4798', 'Passing $foreignKey as a ForeignKeyConstraint object to %s is deprecated.' . ' Pass it as a quoted name instead.', __METHOD__);
304 $foreignKey = $foreignKey->getQuotedName($this->_platform);
305 }
306 if ($table instanceof Table) {
307 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4798', 'Passing $table as a Table object to %s is deprecated. Pass it as a quoted name instead.', __METHOD__);
308 $table = $table->getQuotedName($this->_platform);
309 }
310 $this->_conn->executeStatement($this->_platform->getDropForeignKeySQL($foreignKey, $table));
311 }
312 public function dropSequence($name)
313 {
314 $this->_conn->executeStatement($this->_platform->getDropSequenceSQL($name));
315 }
316 public function dropUniqueConstraint(string $name, string $tableName) : void
317 {
318 $this->_conn->executeStatement($this->_platform->getDropUniqueConstraintSQL($name, $tableName));
319 }
320 public function dropView($name)
321 {
322 $this->_conn->executeStatement($this->_platform->getDropViewSQL($name));
323 }
324 public function createSchemaObjects(Schema $schema) : void
325 {
326 $this->_execSql($schema->toSql($this->_platform));
327 }
328 public function createDatabase($database)
329 {
330 $this->_conn->executeStatement($this->_platform->getCreateDatabaseSQL($database));
331 }
332 public function createTable(Table $table)
333 {
334 $createFlags = AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS;
335 $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags));
336 }
337 public function createSequence($sequence)
338 {
339 $this->_conn->executeStatement($this->_platform->getCreateSequenceSQL($sequence));
340 }
341 public function createConstraint(Constraint $constraint, $table)
342 {
343 $this->_conn->executeStatement($this->_platform->getCreateConstraintSQL($constraint, $table));
344 }
345 public function createIndex(Index $index, $table)
346 {
347 $this->_conn->executeStatement($this->_platform->getCreateIndexSQL($index, $table));
348 }
349 public function createForeignKey(ForeignKeyConstraint $foreignKey, $table)
350 {
351 $this->_conn->executeStatement($this->_platform->getCreateForeignKeySQL($foreignKey, $table));
352 }
353 public function createUniqueConstraint(UniqueConstraint $uniqueConstraint, string $tableName) : void
354 {
355 $this->_conn->executeStatement($this->_platform->getCreateUniqueConstraintSQL($uniqueConstraint, $tableName));
356 }
357 public function createView(View $view)
358 {
359 $this->_conn->executeStatement($this->_platform->getCreateViewSQL($view->getQuotedName($this->_platform), $view->getSql()));
360 }
361 public function dropSchemaObjects(Schema $schema) : void
362 {
363 $this->_execSql($schema->toDropSql($this->_platform));
364 }
365 public function dropAndCreateConstraint(Constraint $constraint, $table)
366 {
367 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4897', 'AbstractSchemaManager::dropAndCreateConstraint() is deprecated.' . ' Use AbstractSchemaManager::dropIndex() and AbstractSchemaManager::createIndex(),' . ' AbstractSchemaManager::dropForeignKey() and AbstractSchemaManager::createForeignKey()' . ' or AbstractSchemaManager::dropUniqueConstraint()' . ' and AbstractSchemaManager::createUniqueConstraint() instead.');
368 $this->tryMethod('dropConstraint', $constraint, $table);
369 $this->createConstraint($constraint, $table);
370 }
371 public function dropAndCreateIndex(Index $index, $table)
372 {
373 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4897', 'AbstractSchemaManager::dropAndCreateIndex() is deprecated.' . ' Use AbstractSchemaManager::dropIndex() and AbstractSchemaManager::createIndex() instead.');
374 $this->tryMethod('dropIndex', $index->getQuotedName($this->_platform), $table);
375 $this->createIndex($index, $table);
376 }
377 public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table)
378 {
379 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4897', 'AbstractSchemaManager::dropAndCreateForeignKey() is deprecated.' . ' Use AbstractSchemaManager::dropForeignKey() and AbstractSchemaManager::createForeignKey() instead.');
380 $this->tryMethod('dropForeignKey', $foreignKey, $table);
381 $this->createForeignKey($foreignKey, $table);
382 }
383 public function dropAndCreateSequence(Sequence $sequence)
384 {
385 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4897', 'AbstractSchemaManager::dropAndCreateSequence() is deprecated.' . ' Use AbstractSchemaManager::dropSequence() and AbstractSchemaManager::createSequence() instead.');
386 $this->tryMethod('dropSequence', $sequence->getQuotedName($this->_platform));
387 $this->createSequence($sequence);
388 }
389 public function dropAndCreateTable(Table $table)
390 {
391 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4897', 'AbstractSchemaManager::dropAndCreateTable() is deprecated.' . ' Use AbstractSchemaManager::dropTable() and AbstractSchemaManager::createTable() instead.');
392 $this->tryMethod('dropTable', $table->getQuotedName($this->_platform));
393 $this->createTable($table);
394 }
395 public function dropAndCreateDatabase($database)
396 {
397 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4897', 'AbstractSchemaManager::dropAndCreateDatabase() is deprecated.' . ' Use AbstractSchemaManager::dropDatabase() and AbstractSchemaManager::createDatabase() instead.');
398 $this->tryMethod('dropDatabase', $database);
399 $this->createDatabase($database);
400 }
401 public function dropAndCreateView(View $view)
402 {
403 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4897', 'AbstractSchemaManager::dropAndCreateView() is deprecated.' . ' Use AbstractSchemaManager::dropView() and AbstractSchemaManager::createView() instead.');
404 $this->tryMethod('dropView', $view->getQuotedName($this->_platform));
405 $this->createView($view);
406 }
407 public function alterSchema(SchemaDiff $schemaDiff) : void
408 {
409 $this->_execSql($this->_platform->getAlterSchemaSQL($schemaDiff));
410 }
411 public function migrateSchema(Schema $toSchema) : void
412 {
413 $schemaDiff = $this->createComparator()->compareSchemas($this->introspectSchema(), $toSchema);
414 $this->alterSchema($schemaDiff);
415 }
416 public function alterTable(TableDiff $tableDiff)
417 {
418 $this->_execSql($this->_platform->getAlterTableSQL($tableDiff));
419 }
420 public function renameTable($name, $newName)
421 {
422 $this->_execSql($this->_platform->getRenameTableSQL($name, $newName));
423 }
424 protected function _getPortableDatabasesList($databases)
425 {
426 $list = [];
427 foreach ($databases as $value) {
428 $list[] = $this->_getPortableDatabaseDefinition($value);
429 }
430 return $list;
431 }
432 protected function getPortableNamespacesList(array $namespaces)
433 {
434 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4503', 'AbstractSchemaManager::getPortableNamespacesList() is deprecated,' . ' use AbstractSchemaManager::listSchemaNames() instead.');
435 $namespacesList = [];
436 foreach ($namespaces as $namespace) {
437 $namespacesList[] = $this->getPortableNamespaceDefinition($namespace);
438 }
439 return $namespacesList;
440 }
441 protected function _getPortableDatabaseDefinition($database)
442 {
443 return $database;
444 }
445 protected function getPortableNamespaceDefinition(array $namespace)
446 {
447 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/4503', 'AbstractSchemaManager::getPortableNamespaceDefinition() is deprecated,' . ' use AbstractSchemaManager::listSchemaNames() instead.');
448 return $namespace;
449 }
450 protected function _getPortableSequencesList($sequences)
451 {
452 $list = [];
453 foreach ($sequences as $value) {
454 $list[] = $this->_getPortableSequenceDefinition($value);
455 }
456 return $list;
457 }
458 protected function _getPortableSequenceDefinition($sequence)
459 {
460 throw Exception::notSupported('Sequences');
461 }
462 protected function _getPortableTableColumnList($table, $database, $tableColumns)
463 {
464 $eventManager = $this->_platform->getEventManager();
465 $list = [];
466 foreach ($tableColumns as $tableColumn) {
467 $column = null;
468 $defaultPrevented = \false;
469 if ($eventManager !== null && $eventManager->hasListeners(Events::onSchemaColumnDefinition)) {
470 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5784', 'Subscribing to %s events is deprecated. Use a custom schema manager instead.', Events::onSchemaColumnDefinition);
471 $eventArgs = new SchemaColumnDefinitionEventArgs($tableColumn, $table, $database, $this->_conn);
472 $eventManager->dispatchEvent(Events::onSchemaColumnDefinition, $eventArgs);
473 $defaultPrevented = $eventArgs->isDefaultPrevented();
474 $column = $eventArgs->getColumn();
475 }
476 if (!$defaultPrevented) {
477 $column = $this->_getPortableTableColumnDefinition($tableColumn);
478 }
479 if ($column === null) {
480 continue;
481 }
482 $name = strtolower($column->getQuotedName($this->_platform));
483 $list[$name] = $column;
484 }
485 return $list;
486 }
487 protected abstract function _getPortableTableColumnDefinition($tableColumn);
488 protected function _getPortableTableIndexesList($tableIndexes, $tableName = null)
489 {
490 $result = [];
491 foreach ($tableIndexes as $tableIndex) {
492 $indexName = $keyName = $tableIndex['key_name'];
493 if ($tableIndex['primary']) {
494 $keyName = 'primary';
495 }
496 $keyName = strtolower($keyName);
497 if (!isset($result[$keyName])) {
498 $options = ['lengths' => []];
499 if (isset($tableIndex['where'])) {
500 $options['where'] = $tableIndex['where'];
501 }
502 $result[$keyName] = ['name' => $indexName, 'columns' => [], 'unique' => !$tableIndex['non_unique'], 'primary' => $tableIndex['primary'], 'flags' => $tableIndex['flags'] ?? [], 'options' => $options];
503 }
504 $result[$keyName]['columns'][] = $tableIndex['column_name'];
505 $result[$keyName]['options']['lengths'][] = $tableIndex['length'] ?? null;
506 }
507 $eventManager = $this->_platform->getEventManager();
508 $indexes = [];
509 foreach ($result as $indexKey => $data) {
510 $index = null;
511 $defaultPrevented = \false;
512 if ($eventManager !== null && $eventManager->hasListeners(Events::onSchemaIndexDefinition)) {
513 Deprecation::trigger('doctrine/dbal', 'https://github.com/doctrine/dbal/issues/5784', 'Subscribing to %s events is deprecated. Use a custom schema manager instead.', Events::onSchemaColumnDefinition);
514 $eventArgs = new SchemaIndexDefinitionEventArgs($data, $tableName, $this->_conn);
515 $eventManager->dispatchEvent(Events::onSchemaIndexDefinition, $eventArgs);
516 $defaultPrevented = $eventArgs->isDefaultPrevented();
517 $index = $eventArgs->getIndex();
518 }
519 if (!$defaultPrevented) {
520 $index = new Index($data['name'], $data['columns'], $data['unique'], $data['primary'], $data['flags'], $data['options']);
521 }
522 if ($index === null) {
523 continue;
524 }
525 $indexes[$indexKey] = $index;
526 }
527 return $indexes;
528 }
529 protected function _getPortableTablesList($tables)
530 {
531 $list = [];
532 foreach ($tables as $value) {
533 $list[] = $this->_getPortableTableDefinition($value);
534 }
535 return $list;
536 }
537 protected function _getPortableTableDefinition($table)
538 {
539 return $table;
540 }
541 protected function _getPortableViewsList($views)
542 {
543 $list = [];
544 foreach ($views as $value) {
545 $view = $this->_getPortableViewDefinition($value);
546 if ($view === \false) {
547 continue;
548 }
549 $viewName = strtolower($view->getQuotedName($this->_platform));
550 $list[$viewName] = $view;
551 }
552 return $list;
553 }
554 protected function _getPortableViewDefinition($view)
555 {
556 return \false;
557 }
558 protected function _getPortableTableForeignKeysList($tableForeignKeys)
559 {
560 $list = [];
561 foreach ($tableForeignKeys as $value) {
562 $list[] = $this->_getPortableTableForeignKeyDefinition($value);
563 }
564 return $list;
565 }
566 protected function _getPortableTableForeignKeyDefinition($tableForeignKey)
567 {
568 return $tableForeignKey;
569 }
570 protected function _execSql($sql)
571 {
572 foreach ((array) $sql as $query) {
573 $this->_conn->executeStatement($query);
574 }
575 }
576 public function createSchema()
577 {
578 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/5613', '%s is deprecated. Use introspectSchema() instead.', __METHOD__);
579 $schemaNames = [];
580 if ($this->_platform->supportsSchemas()) {
581 $schemaNames = $this->listNamespaceNames();
582 }
583 $sequences = [];
584 if ($this->_platform->supportsSequences()) {
585 $sequences = $this->listSequences();
586 }
587 $tables = $this->listTables();
588 return new Schema($tables, $sequences, $this->createSchemaConfig(), $schemaNames);
589 }
590 public function introspectSchema() : Schema
591 {
592 return $this->createSchema();
593 }
594 public function createSchemaConfig()
595 {
596 $schemaConfig = new SchemaConfig();
597 $schemaConfig->setMaxIdentifierLength($this->_platform->getMaxIdentifierLength());
598 $searchPaths = $this->getSchemaSearchPaths();
599 if (isset($searchPaths[0])) {
600 $schemaConfig->setName($searchPaths[0]);
601 }
602 $params = $this->_conn->getParams();
603 if (!isset($params['defaultTableOptions'])) {
604 $params['defaultTableOptions'] = [];
605 }
606 if (!isset($params['defaultTableOptions']['charset']) && isset($params['charset'])) {
607 $params['defaultTableOptions']['charset'] = $params['charset'];
608 }
609 $schemaConfig->setDefaultTableOptions($params['defaultTableOptions']);
610 return $schemaConfig;
611 }
612 public function getSchemaSearchPaths()
613 {
614 Deprecation::triggerIfCalledFromOutside('doctrine/dbal', 'https://github.com/doctrine/dbal/pull/4821', 'AbstractSchemaManager::getSchemaSearchPaths() is deprecated.');
615 $database = $this->_conn->getDatabase();
616 if ($database !== null) {
617 return [$database];
618 }
619 return [];
620 }
621 public function extractDoctrineTypeFromComment($comment, $currentType)
622 {
623 if ($this->_conn->getConfiguration()->getDisableTypeComments()) {
624 return $currentType;
625 }
626 if ($comment !== null && preg_match('(\\(DC2Type:(((?!\\)).)+)\\))', $comment, $match) === 1) {
627 return $match[1];
628 }
629 return $currentType;
630 }
631 public function removeDoctrineTypeFromComment($comment, $type)
632 {
633 if ($this->_conn->getConfiguration()->getDisableTypeComments()) {
634 return $comment;
635 }
636 if ($comment === null) {
637 return null;
638 }
639 return str_replace('(DC2Type:' . $type . ')', '', $comment);
640 }
641 private function getDatabase(string $methodName) : string
642 {
643 $database = $this->_conn->getDatabase();
644 if ($database === null) {
645 throw DatabaseRequired::new($methodName);
646 }
647 return $database;
648 }
649 public function createComparator() : Comparator
650 {
651 return new Comparator($this->_platform);
652 }
653 private function fetchAllAssociativeGrouped(Result $result) : array
654 {
655 $data = [];
656 foreach ($result->fetchAllAssociative() as $row) {
657 $tableName = $this->_getPortableTableDefinition($row);
658 $data[$tableName][] = $row;
659 }
660 return $data;
661 }
662 }
663