Skip to content

Commit

Permalink
Fix bard field migration when field value is html string.
Browse files Browse the repository at this point in the history
If a bard value was saved before the bard field had any configured bard sets in v2, an html string would be saved. This normalizes that string to a set payload before migrating it.
  • Loading branch information
jesseleite committed Jun 26, 2023
1 parent 93ed208 commit 15d964b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/ContentMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@ protected function migrateReplicatorSet($set, $fieldConfigs)
*/
protected function migrateBardField($handle, $value, $config)
{
// If content was saved while bard had no sets, value may be a string, so we'll normalize to a bard text set...
if (is_string($value)) {
$value = [
['type' => 'text', 'text' => $value],
];
}

return $this->migrateReplicatorField($handle, $value, $config);
}

Expand Down
4 changes: 3 additions & 1 deletion tests/ContentMigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,9 @@ public function it_can_migrate_bards_with_no_sets()
]);

$expected = [
'some_bard' => 'Well hello there!',
'some_bard' => [
['type' => 'text', 'text' => 'Well hello there!'],
],
'blueprint' => 'speaker',
];

Expand Down

0 comments on commit 15d964b

Please sign in to comment.