Skip to content

Commit

Permalink
Fixed user settings config key
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonkelly committed Jan 12, 2019
1 parent 5358900 commit c4fafa3
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Fixed an error where deleted sites would not be removed from category group or section project config settings.
- Fixed a bug where active records weren’t preparing their attributes correctly when being restored.
- Fixed an error that could occur when updating multi-site installs to Craft 3.1. ([#3614](https://github.com/craftcms/cms/issues/3614))
- Fixed a bug where the default user settings were getting saved with the wrong project config key.

## 3.1.0-beta.7 - 2019-01-09

Expand Down
2 changes: 1 addition & 1 deletion src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'id' => 'CraftCMS',
'name' => 'Craft CMS',
'version' => '3.1.0-beta.7',
'schemaVersion' => '3.1.14',
'schemaVersion' => '3.1.15',
'minVersionRequired' => '2.6.2788',
'basePath' => dirname(__DIR__), // Defines the @app alias
'runtimePath' => '@storage/runtime', // Defines the @runtime alias
Expand Down
2 changes: 1 addition & 1 deletion src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,7 @@ private function _generateInitialConfig(): array
'schemaVersion' => Craft::$app->schemaVersion,
'timeZone' => 'America/Los_Angeles',
],
'user' => [
'users' => [
'requireEmailVerification' => true,
'allowPublicRegistration' => false,
'defaultGroup' => null,
Expand Down
39 changes: 39 additions & 0 deletions src/migrations/m190112_124737_fix_user_settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace craft\migrations;

use Craft;
use craft\db\Migration;

/**
* m190112_124737_fix_user_settings migration.
*/
class m190112_124737_fix_user_settings extends Migration
{
/**
* @inheritdoc
*/
public function safeUp()
{
// Don't make the same config changes twice
$projectConfig = Craft::$app->getProjectConfig();
$schemaVersion = $projectConfig->get('system.schemaVersion', true);
if (version_compare($schemaVersion, '3.1.15', '>=')) {
return;
}

$wrong = $projectConfig->get('user') ?? [];
$right = $projectConfig->get('users') ?? [];
$projectConfig->set('users', array_merge($wrong, $right));
$projectConfig->remove('user');
}

/**
* @inheritdoc
*/
public function safeDown()
{
echo "m190112_124737_fix_user_settings cannot be reverted.\n";
return false;
}
}

0 comments on commit c4fafa3

Please sign in to comment.