-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
662e9ae
commit b0a6b51
Showing
3 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace craft\migrations; | ||
|
||
use craft\db\Migration; | ||
use craft\db\Query; | ||
use craft\db\Table; | ||
use craft\helpers\ArrayHelper; | ||
use craft\helpers\Json; | ||
|
||
/** | ||
* m190121_120000_fix_redactor_settings migration. | ||
*/ | ||
class m190121_120000_fix_redactor_settings extends Migration | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeUp() | ||
{ | ||
$fields = (new Query()) | ||
->select(['id', 'settings']) | ||
->from([Table::FIELDS]) | ||
->where(['type' => 'craft\\redactor\\Field']) | ||
->all($this->db); | ||
|
||
foreach ($fields as $field) { | ||
$settings = Json::decode($field['settings']); | ||
if (is_array($settings) && array_key_exists('availableAssetSources', $settings)) { | ||
$settings['availableVolumes'] = ArrayHelper::remove($settings, 'availableAssetSources'); | ||
$this->update(Table::FIELDS, ['settings' => Json::encode($settings)], ['id' => $field['id']]); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function safeDown() | ||
{ | ||
echo "m190121_120000_fix_redactor_settings cannot be reverted.\n"; | ||
|
||
return false; | ||
} | ||
} |