Skip to content

Commit 4d7c025

Browse files
PB-370: Introduce upgrade mechanism for Page Builder content
- skip elements that does not have padding - add more cases to test
1 parent 02cb82e commit 4d7c025

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

app/code/Magento/PageBuilder/Model/Dom/Document.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,13 @@ public function getMetadata($key = null)
209209
*/
210210
public function stripHtmlWrapperTags(): string
211211
{
212-
$result = '';
213212
preg_match('/<body>(.*)<\/body>/s', $this->saveHTML(), $matches);
214-
215-
if (isset($matches[1])) {
216-
$result = preg_replace_callback(
217-
'/=\"(%7B%7B[^"]*%7D%7D)\"/m',
218-
function ($matches) {
219-
return urldecode($matches[0]);
220-
},
221-
$matches[1]
222-
);
223-
}
224-
return $result;
213+
return preg_replace_callback(
214+
'/=\"(%7B%7B[^"]*%7D%7D)\"/m',
215+
function ($matches) {
216+
return urldecode($matches[0]);
217+
},
218+
$matches[1]
219+
);
225220
}
226221
}

app/code/Magento/PageBuilder/Setup/Converters/FixFullWidthRowPadding.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,15 @@ public function convert($value)
4444
$style = $row->getAttribute("style");
4545
preg_match("/padding:(.*?);/", $style, $results);
4646
$padding = isset($results[1]) ? trim($results[1]) : '';
47+
if (!$padding) {
48+
continue;
49+
}
4750
// remove padding from main row element
4851
$row->removeStyle("padding");
4952
// add padding to inner row element
5053
$innerDiv = $row->querySelector(".row-full-width-inner");
5154
$innerDiv->addStyle("padding", $padding);
5255
}
53-
return $fullWidthRows->count() > 0 ? ($document->stripHtmlWrapperTags() ?: $value) : $value;
56+
return $fullWidthRows->count() > 0 ? $document->stripHtmlWrapperTags(): $value;
5457
}
5558
}

0 commit comments

Comments
 (0)