Skip to content

Commit

Permalink
Fixed a MySQL error that would occur if you ran `php craft db/convert…
Browse files Browse the repository at this point in the history
…-charset` with custom views defined in the database.

Issue #15598
  • Loading branch information
angrybrad committed Aug 27, 2024
1 parent 72fcd36 commit 8be79e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes for Craft CMS 4

## Unreleased

- Fixed a MySQL error that would occur if you ran `php craft db/convert-charset` with custom views defined in the database. ([#15598](https://github.com/craftcms/cms/issues/15598))

## 4.11.5 - 2024-08-26

- Fixed a bug where it wasn’t possible to override named transforms in GraphQL queries. ([#15572](https://github.com/craftcms/cms/issues/15572))
Expand Down
7 changes: 7 additions & 0 deletions src/console/controllers/DbController.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ public function actionConvertCharset(?string $charset = null, ?string $collation

$schema = $db->getSchema();
$tableNames = $schema->getTableNames();
$dbName= Craft::$app->getConfig()->getDb()->database;

// See if there are any views to skip from this command.
$views = $db->createCommand("SELECT TABLE_NAME FROM information_schema.tables WHERE TABLE_SCHEMA = '" . $dbName . "' AND TABLE_TYPE = 'VIEW'")->queryColumn();

// Remove any views from the list of tables
$tableNames = array_diff($tableNames, $views);

if (empty($tableNames)) {
$this->stderr('Could not find any database tables.' . PHP_EOL, Console::FG_RED);
Expand Down

0 comments on commit 8be79e0

Please sign in to comment.