Skip to content

Commit 371da7f

Browse files
committed
AC-3557: Fix potential problems with RFC: Deprecate passing null for Magento sample-data
1 parent e28e651 commit 371da7f

File tree

7 files changed

+11
-9
lines changed

7 files changed

+11
-9
lines changed

app/code/Magento/CatalogRuleSampleData/Model/Rule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function convertSerializedData($data)
128128
preg_match_all($regexp, $data, $matches);
129129
$replacement = null;
130130
foreach ($matches[1] as $matchedId => $matchedItem) {
131-
$extractedData = array_filter(explode(",", $matchedItem));
131+
$extractedData = array_filter(explode(",", $matchedItem ?? ''));
132132
foreach ($extractedData as $extractedItem) {
133133
$separatedData = array_filter(explode('=', $extractedItem));
134134
if ($separatedData[0] == 'url_key') {

app/code/Magento/CatalogSampleData/Model/Attribute.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function install(array $fixtures)
108108
foreach ($rows as $row) {
109109
$data = [];
110110
foreach ($row as $key => $value) {
111-
$data[$header[$key]] = trim($value);
111+
$data[$header[$key]] = trim($value ?? '');
112112
}
113113
$data['attribute_set'] = explode("\n", $data['attribute_set']);
114114

@@ -144,7 +144,7 @@ public function install(array $fixtures)
144144

145145
if (is_array($data['attribute_set'])) {
146146
foreach ($data['attribute_set'] as $setName) {
147-
$setName = trim($setName);
147+
$setName = trim($setName ?? '');
148148
$attributeCount++;
149149
$attributeSet = $this->processAttributeSet($setName);
150150
$attributeGroupId = $attributeSet->getDefaultGroupId();
@@ -171,7 +171,7 @@ public function install(array $fixtures)
171171
protected function getOption($attribute, $data)
172172
{
173173
$result = [];
174-
$data['option'] = explode("\n", $data['option']);
174+
$data['option'] = explode("\n", $data['option'] ?? '');
175175
/** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\Collection $options */
176176
$options = $this->attrOptionCollectionFactory->create()
177177
->setAttributeFilter($attribute->getId())

app/code/Magento/CatalogSampleData/Model/Product/Converter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ protected function getArrayValue($value)
165165
if (is_array($value)) {
166166
return $value;
167167
}
168-
if (false !== strpos($value, "\n")) {
168+
if ($value !== null && false !== strpos($value, "\n")) {
169169
$value = array_filter(explode("\n", $value));
170170
}
171171
return !is_array($value) ? [$value] : $value;

app/code/Magento/ConfigurableSampleData/Model/Product/Converter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected function convertAttributeValues($valuesData)
139139
$values = [];
140140
$prices = [];
141141
foreach ($valuesData as $item) {
142-
$itemData = explode(';', $item);
142+
$itemData = explode(';', $item ?? '');
143143
if (!empty($itemData[0])) {
144144
$values[] = $itemData[0];
145145
}

app/code/Magento/SwatchesSampleData/Model/Swatches.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ private function getOptionSwatchVisual(array $attributeData)
126126
{
127127
$optionSwatch = ['value' => []];
128128
foreach ($attributeData['option'] as $optionKey => $optionValue) {
129-
if (substr($optionValue, 0, 1) == '#' && strlen($optionValue) == 7) {
129+
if ($optionValue !== null && substr($optionValue, 0, 1) == '#'
130+
&& strlen($optionValue) == 7) {
130131
$optionSwatch['value'][$optionKey] = $optionValue;
131132
} else if (!empty($this->colorMap[$optionValue])) {
132133
$optionSwatch['value'][$optionKey] = $this->colorMap[$optionValue];

app/code/Magento/ThemeSampleData/Model/HeadStyle.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ public function __construct(
5757

5858
public function add($contentFile, $cssFile)
5959
{
60-
$styleContent = preg_replace('/^\/\*[\s\S]+\*\//', '', file_get_contents($contentFile));
60+
$styleContent = preg_replace('/^\/\*[\s\S]+\*\//', '',
61+
file_get_contents($contentFile ?? ''));
6162
if (empty($styleContent)) {
6263
return;
6364
}

app/code/Magento/WishlistSampleData/Model/Wishlist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function install(array $fixtures)
8080
if (!$wishlist->getId()) {
8181
continue;
8282
}
83-
$productSkuList = explode("\n", $row['product_list']);
83+
$productSkuList = explode("\n", $row['product_list'] ?? '');
8484
$this->helper->addProductsToWishlist($wishlist, $productSkuList);
8585
}
8686
}

0 commit comments

Comments
 (0)