Skip to content

Commit 8befc13

Browse files
author
Joan He
committed
MAGETWO-99282: Eliminate @escapeNotVerified in Magento_Catalog module
1 parent d3581c4 commit 8befc13

File tree

12 files changed

+101
-33
lines changed

12 files changed

+101
-33
lines changed

app/code/Magento/Backend/Test/Unit/Block/Widget/Grid/Column/Filter/TextTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ protected function setUp()
3131
->setMethods(['getEscaper'])
3232
->disableOriginalConstructor()
3333
->getMock();
34-
$this->escaper = $this->createPartialMock(\Magento\Framework\Escaper::class, ['escapeHtml']);
34+
$this->escaper = $this->createPartialMock(
35+
\Magento\Framework\Escaper::class,
36+
['escapeHtml', 'escapeHtmlAttr']
37+
);
3538
$this->helper = $this->createMock(\Magento\Framework\DB\Helper::class);
3639

3740
$this->context->expects($this->once())->method('getEscaper')->willReturn($this->escaper);
@@ -60,6 +63,9 @@ public function testGetHtml()
6063
$this->block->setColumn($column);
6164

6265
$this->escaper->expects($this->any())->method('escapeHtml')->willReturn('escapedHtml');
66+
$this->escaper->expects($this->once())
67+
->method('escapeHtmlAttr')
68+
->willReturnCallback(function($string) {return $string;});
6369
$column->expects($this->any())->method('getId')->willReturn('id');
6470
$column->expects($this->once())->method('getHtmlId')->willReturn('htmlId');
6571

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/AttributeSet.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
namespace Magento\Catalog\Block\Adminhtml\Product\Edit;
1313

14+
/**
15+
* Admin AttributeSet block
16+
*/
1417
class AttributeSet extends \Magento\Backend\Block\Widget\Form
1518
{
1619
/**

app/code/Magento/Catalog/Block/Adminhtml/Product/Edit/Tab/Attributes/Search.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
namespace Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Attributes;
1313

14+
/**
15+
* Admin product attribute search block
16+
*/
1417
class Search extends \Magento\Backend\Block\Widget
1518
{
1619
/**
@@ -62,6 +65,8 @@ protected function _construct()
6265
}
6366

6467
/**
68+
* Get selector options
69+
*
6570
* @return array
6671
*/
6772
public function getSelectorOptions()
@@ -110,6 +115,8 @@ public function getSuggestedAttributes($labelPart, $templateId = null)
110115
}
111116

112117
/**
118+
* Get add attribute url
119+
*
113120
* @return string
114121
*/
115122
public function getAddAttributeUrl()

app/code/Magento/Catalog/Block/Product/Gallery.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Magento\Framework\Data\Collection;
1717

1818
/**
19+
* Product gallery block
20+
*
1921
* @api
2022
* @since 100.0.2
2123
*/
@@ -43,6 +45,8 @@ public function __construct(
4345
}
4446

4547
/**
48+
* Prepare layout
49+
*
4650
* @return $this
4751
*/
4852
protected function _prepareLayout()
@@ -52,6 +56,8 @@ protected function _prepareLayout()
5256
}
5357

5458
/**
59+
* Get product
60+
*
5561
* @return Product
5662
*/
5763
public function getProduct()
@@ -60,6 +66,8 @@ public function getProduct()
6066
}
6167

6268
/**
69+
* Get gallery collection
70+
*
6371
* @return Collection
6472
*/
6573
public function getGalleryCollection()
@@ -68,6 +76,8 @@ public function getGalleryCollection()
6876
}
6977

7078
/**
79+
* Get current image
80+
*
7181
* @return Image|null
7282
*/
7383
public function getCurrentImage()
@@ -85,6 +95,8 @@ public function getCurrentImage()
8595
}
8696

8797
/**
98+
* Get image url
99+
*
88100
* @return string
89101
*/
90102
public function getImageUrl()
@@ -93,6 +105,8 @@ public function getImageUrl()
93105
}
94106

95107
/**
108+
* Get image file
109+
*
96110
* @return mixed
97111
*/
98112
public function getImageFile()
@@ -124,6 +138,8 @@ public function getImageWidth()
124138
}
125139

126140
/**
141+
* Get previous image
142+
*
127143
* @return Image|false
128144
*/
129145
public function getPreviousImage()
@@ -143,6 +159,8 @@ public function getPreviousImage()
143159
}
144160

145161
/**
162+
* Get next image
163+
*
146164
* @return Image|false
147165
*/
148166
public function getNextImage()
@@ -166,6 +184,8 @@ public function getNextImage()
166184
}
167185

168186
/**
187+
* Get previous image url
188+
*
169189
* @return false|string
170190
*/
171191
public function getPreviousImageUrl()
@@ -178,6 +198,8 @@ public function getPreviousImageUrl()
178198
}
179199

180200
/**
201+
* Get next image url
202+
*
181203
* @return false|string
182204
*/
183205
public function getNextImageUrl()

app/code/Magento/Catalog/Block/Product/View.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ public function getJsonConfig()
187187
}
188188

189189
$tierPrices = [];
190-
$tierPricesList = $product->getPriceInfo()->getPrice('tier_price')->getTierPriceList();
190+
$priceInfo = $product->getPriceInfo();
191+
$tierPricesList = $priceInfo->getPrice('tier_price')->getTierPriceList();
191192
foreach ($tierPricesList as $tierPrice) {
192193
$tierPrices[] = $tierPrice['price']->getValue() * 1;
193194
}
@@ -196,15 +197,15 @@ public function getJsonConfig()
196197
'priceFormat' => $this->_localeFormat->getPriceFormat(),
197198
'prices' => [
198199
'oldPrice' => [
199-
'amount' => $product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue() * 1,
200+
'amount' => $priceInfo->getPrice('regular_price')->getAmount()->getValue() * 1,
200201
'adjustments' => []
201202
],
202203
'basePrice' => [
203-
'amount' => $product->getPriceInfo()->getPrice('final_price')->getAmount()->getBaseAmount() * 1,
204+
'amount' => $priceInfo->getPrice('final_price')->getAmount()->getBaseAmount() * 1,
204205
'adjustments' => []
205206
],
206207
'finalPrice' => [
207-
'amount' => $product->getPriceInfo()->getPrice('final_price')->getAmount()->getValue() * 1,
208+
'amount' => $priceInfo->getPrice('final_price')->getAmount()->getValue() * 1,
208209
'adjustments' => []
209210
]
210211
],

app/code/Magento/Catalog/Block/Product/View/Gallery.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,18 @@ public function getGalleryImagesJson()
137137
$imagesItems = [];
138138
/** @var DataObject $image */
139139
foreach ($this->getGalleryImages() as $image) {
140-
$imageItem = new DataObject([
141-
'thumb' => $image->getData('small_image_url'),
142-
'img' => $image->getData('medium_image_url'),
143-
'full' => $image->getData('large_image_url'),
144-
'caption' => ($image->getLabel() ?: $this->getProduct()->getName()),
145-
'position' => $image->getData('position'),
146-
'isMain' => $this->isMainImage($image),
147-
'type' => str_replace('external-', '', $image->getMediaType()),
148-
'videoUrl' => $image->getVideoUrl(),
149-
]);
140+
$imageItem = new DataObject(
141+
[
142+
'thumb' => $image->getData('small_image_url'),
143+
'img' => $image->getData('medium_image_url'),
144+
'full' => $image->getData('large_image_url'),
145+
'caption' => ($image->getLabel() ?: $this->getProduct()->getName()),
146+
'position' => $image->getData('position'),
147+
'isMain' => $this->isMainImage($image),
148+
'type' => str_replace('external-', '', $image->getMediaType()),
149+
'videoUrl' => $image->getVideoUrl(),
150+
]
151+
);
150152
foreach ($this->getGalleryImagesConfig()->getItems() as $imageConfig) {
151153
$imageItem->setData(
152154
$imageConfig->getData('json_object_key'),

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/composite/fieldset/qty.phtml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@
1212
<div class="field admin__field">
1313
<label class="label admin__field-label"><span><?= $block->escapeHtml(__('Quantity')) ?></span></label>
1414
<div class="control admin__field-control">
15-
<input id="product_composite_configure_input_qty"
16-
class="input-text admin__control-text qty"
17-
type="text"
18-
name="qty"
19-
value="<?= $block->getQtyValue() * 1 ?>">
15+
<input id="product_composite_configure_input_qty" class="input-text admin__control-text qty" type="text" name="qty" value="<?= $block->getQtyValue() * 1 ?>">
2016
</div>
2117
</div>
2218
</fieldset>

app/code/Magento/Catalog/view/base/templates/product/composite/fieldset/options/view/checkable.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ if ($option) : ?>
6262
product-custom-option
6363
<?= $block->getSkipJsReloadPrice() ? '' : 'opConfig.reloadPrice()' ?>"
6464
name="options[<?= $block->escapeHtmlAttr($option->getId()) ?>]<?= /* @noEscape */ $arraySign ?>"
65-
id="options_<?= $block->escapeHtmlAttr($option->getId()) . '_' . $count ?>"
65+
id="options_<?= $block->escapeHtmlAttr($option->getId() . '_' . $count) ?>"
6666
value="<?= $block->escapeHtmlAttr($value->getOptionTypeId()) ?>"
6767
<?= $block->escapeHtml($checked) ?>
6868
data-selector="<?= $block->escapeHtmlAttr($dataSelector) ?>"
6969
price="<?= $block->escapeHtmlAttr($block->getCurrencyByStore($value)) ?>"
7070
/>
7171
<label class="label admin__field-label"
72-
for="options_<?= $block->escapeHtmlAttr($option->getId()) . '_' . $count ?>">
72+
for="options_<?= $block->escapeHtmlAttr($option->getId() . '_' . $count) ?>">
7373
<span>
7474
<?= $block->escapeHtml($value->getTitle()) ?>
7575
</span>

app/code/Magento/Wishlist/Helper/Data.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper
117117
* @param \Magento\Customer\Helper\View $customerViewHelper
118118
* @param WishlistProviderInterface $wishlistProvider
119119
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
120-
* @param Escaper $escaper
121120
*/
122121
public function __construct(
123122
\Magento\Framework\App\Helper\Context $context,
@@ -128,8 +127,7 @@ public function __construct(
128127
\Magento\Framework\Data\Helper\PostHelper $postDataHelper,
129128
\Magento\Customer\Helper\View $customerViewHelper,
130129
WishlistProviderInterface $wishlistProvider,
131-
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository,
132-
Escaper $escaper = null
130+
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository
133131
) {
134132
$this->_coreRegistry = $coreRegistry;
135133
$this->_customerSession = $customerSession;
@@ -139,7 +137,7 @@ public function __construct(
139137
$this->_customerViewHelper = $customerViewHelper;
140138
$this->wishlistProvider = $wishlistProvider;
141139
$this->productRepository = $productRepository;
142-
$this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
140+
$this->escaper = ObjectManager::getInstance()->get(Escaper::class);
143141
parent::__construct($context);
144142
}
145143

lib/internal/Magento/Framework/View/Element/AbstractBlock.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,13 @@ public function toHtml()
680680
'html' => $html,
681681
]
682682
);
683-
$this->_eventManager->dispatch('view_block_abstract_to_html_after', [
684-
'block' => $this,
685-
'transport' => $transportObject
686-
]);
683+
$this->_eventManager->dispatch(
684+
'view_block_abstract_to_html_after',
685+
[
686+
'block' => $this,
687+
'transport' => $transportObject
688+
]
689+
);
687690
$html = $transportObject->getHtml();
688691

689692
return $html;
@@ -973,8 +976,8 @@ public function escapeXssInUrl($data)
973976
*
974977
* Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc)
975978
*
976-
* @param string $data
977-
* @param bool $addSlashes
979+
* @param string $data
980+
* @param bool $addSlashes
978981
* @return string
979982
* @deprecated 100.2.0
980983
*/

0 commit comments

Comments
 (0)