Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.7] Add warning alert if upgrade command is not completed #3550

Draft
wants to merge 3 commits into
base: 4.7
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
use craft\fixfks\controllers\RestoreController;
use craft\gql\ElementQueryConditionBuilder;
use craft\helpers\Console;
use craft\helpers\Cp;
use craft\helpers\Db;
use craft\helpers\FileHelper;
use craft\helpers\UrlHelper;
Expand Down Expand Up @@ -270,12 +271,34 @@ public function init(): void
$this->_registerDebugPanels();

if ($request->getIsCpRequest()) {
$this->_checkUpgradeCommandHasFinished();
$this->_registerStoreAddressAuthHandlers();
}
});
Craft::setAlias('@commerceLib', Craft::getAlias('@craft/commerce/../lib'));
}

private function _checkUpgradeCommandHasFinished()
{
$v3Columns = \craft\commerce\console\controllers\UpgradeController::$_v3droppableColumns;
// do any of the columns exist:
$columnsExist = false;
foreach ($v3Columns as $column) {
if (Craft::$app->getDb()->columnExists($column['table'], $column['column'])) {
$columnsExist = true;
break;
}
}

if ($columnsExist) {
Event::on(Cp::class, Cp::EVENT_REGISTER_ALERTS, static function($event) {
$event->alerts[] = [
'content' => Craft::t('commerce', '<strong>Commerce 4 upgrade incomplete.</strong> Please ensure the <a href="https://craftcms.com/docs/commerce/4.x/upgrading.html#performing-the-upgrade" target="_blank" rel="noopener noreferrer">Commerce 4 upgrade command</a> has finished running.'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lukeholder just popping in because I recently started updating some translations that include brand names and saw that this was relevant. Because the brand names aren’t translated, I’ve started wrapping them with <span lang="en"></span> so that screen readers switch their pronunciation to English when encountering them in the context of another language.

You can see an example of this in this recent commit, and Brandon also provided some guidance here about ensuring they're not being escaped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @gcamacho079 ! will do.

];
});
}
}

/**
* @inheritdoc
*/
Expand Down
4 changes: 2 additions & 2 deletions src/console/controllers/UpgradeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private function _getOrphanedCustomerIds(): array
*
* @var array<array{table: string, column: string}>
*/
private array $_v3droppableColumns = [
public static array $_v3droppableColumns = [
['table' => '{{%commerce_taxzones}}', 'column' => 'v3isCountryBased'],
['table' => '{{%commerce_shippingzones}}', 'column' => 'v3isCountryBased'],
['table' => '{{%commerce_taxzones}}', 'column' => 'v3zipCodeConditionFormula'],
Expand Down Expand Up @@ -318,7 +318,7 @@ public function actionRun(): int
$this->db->createCommand()->dropTableIfExists($table)->execute();
}

foreach ($this->_v3droppableColumns as ['table' => $table, 'column' => $column]) {
foreach (static::$_v3droppableColumns as ['table' => $table, 'column' => $column]) {
if ($this->db->columnExists($table, $column)) {
Db::dropForeignKeyIfExists($table, $column, $this->db);
Db::dropIndexIfExists($table, $column, db: $this->db);
Expand Down
Loading