Skip to content

Commit 1541725

Browse files
committed
Merge remote-tracking branch 'karyna/fix-deprecation-issues-php8.1-part3' into ph-delivery
2 parents a294238 + 002a772 commit 1541725

File tree

6 files changed

+48
-39
lines changed

6 files changed

+48
-39
lines changed

app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ public function __construct(
177177
TotalRecordsResolverFactory $totalRecordsResolverFactory = null,
178178
DefaultFilterStrategyApplyCheckerInterface $defaultFilterStrategyApplyChecker = null
179179
) {
180-
$this->searchResultFactory = $searchResultFactory ?? \Magento\Framework\App\ObjectManager::getInstance()
181-
->get(\Magento\Framework\Api\Search\SearchResultFactory::class);
180+
$this->searchResultFactory = $searchResultFactory
181+
?? ObjectManager::getInstance()->get(SearchResultFactory::class);
182182
parent::__construct(
183183
$entityFactory,
184184
$logger,
@@ -377,7 +377,7 @@ public function _loadEntities($printQuery = false, $logQuery = false)
377377
$query = $this->getSelect();
378378
$rows = $this->_fetchAll($query);
379379
} catch (\Exception $e) {
380-
$this->printLogQuery(false, true, $query);
380+
$this->printLogQuery(false, true, $query ?? 'n/a');
381381
throw $e;
382382
}
383383

@@ -455,7 +455,7 @@ protected function _renderFiltersBefore()
455455
}
456456

457457
if ($this->searchRequestName !== 'quick_search_container'
458-
|| strlen(trim($this->queryText))
458+
|| ($this->queryText && strlen(trim($this->queryText)))
459459
) {
460460
$this->prepareSearchTermFilter();
461461
$this->preparePriceAggregation();

app/code/Magento/Config/Console/Command/ConfigShowCommand.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ class ConfigShowCommand extends Command
3131
/**#@+
3232
* Names of input arguments or options.
3333
*/
34-
const INPUT_OPTION_SCOPE = 'scope';
35-
const INPUT_OPTION_SCOPE_CODE = 'scope-code';
36-
const INPUT_ARGUMENT_PATH = 'path';
34+
public const INPUT_OPTION_SCOPE = 'scope';
35+
public const INPUT_OPTION_SCOPE_CODE = 'scope-code';
36+
public const INPUT_ARGUMENT_PATH = 'path';
3737
/**#@-*/
3838

39-
/**#@-*/
39+
/**
40+
* @var ValidatorInterface
41+
*/
4042
private $scopeValidator;
4143

4244
/**
@@ -165,7 +167,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
165167
try {
166168
$this->scope = $input->getOption(self::INPUT_OPTION_SCOPE);
167169
$this->scopeCode = $input->getOption(self::INPUT_OPTION_SCOPE_CODE);
168-
$this->inputPath = trim($input->getArgument(self::INPUT_ARGUMENT_PATH), '/');
170+
$inputPath = $input->getArgument(self::INPUT_ARGUMENT_PATH);
171+
$this->inputPath = $inputPath !== null ? trim($inputPath, '/') : '';
169172

170173
$configValue = $this->emulatedAreaProcessor->process(function () {
171174
$this->scopeValidator->isValid($this->scope, $this->scopeCode);

app/code/Magento/GiftMessage/Model/GiftMessageManager.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ public function __construct(
2525
}
2626

2727
/**
28+
* Save gift message information.
29+
*
2830
* @param array $giftMessages
2931
* @param \Magento\Quote\Model\Quote $quote
3032
* @return $this
3133
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
34+
* @SuppressWarnings(PHPMD.NPathComplexity)
3235
*/
3336
public function add($giftMessages, $quote)
3437
{
@@ -61,11 +64,12 @@ public function add($giftMessages, $quote)
6164
$giftMessage->load($entity->getGiftMessageId());
6265
}
6366

64-
if (trim($message['message']) == '') {
67+
if (isset($message['message']) && trim($message['message']) == '') {
6568
if ($giftMessage->getId()) {
6669
try {
6770
$giftMessage->delete();
6871
$entity->setGiftMessageId(0)->save();
72+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
6973
} catch (\Exception $e) {
7074
}
7175
}
@@ -84,6 +88,7 @@ public function add($giftMessages, $quote)
8488
)->save();
8589

8690
$entity->setGiftMessageId($giftMessage->getId())->save();
91+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
8792
} catch (\Exception $e) {
8893
}
8994
}

app/code/Magento/GiftMessage/view/frontend/templates/inline.phtml

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
* See COPYING.txt for license details.
55
*/
66

7+
// phpcs:disable Magento2.Files.LineLength, Generic.Files.LineLength
8+
79
/** @var \Magento\Framework\View\Helper\SecureHtmlRenderer $secureRenderer */
10+
/** @var Magento\Framework\Escaper $escaper */
811
?>
912
<?php $_giftMessage = false;
1013
switch ($block->getCheckoutType()):
@@ -61,9 +64,7 @@ switch ($block->getCheckoutType()):
6164
name="giftmessage[quote][<?= (int) $block->getEntity()->getId() ?>][from]"
6265
id="gift-message-whole-from"
6366
title="<?= $block->escapeHtmlAttr(__('From')) ?>"
64-
value="<?= /* @noEscape */ $block
65-
->getEscaped($block->getMessage()->getSender(), $block->getDefaultFrom())
66-
?>"
67+
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage()->getSender() ?? '', $block->getDefaultFrom()) ?>"
6768
class="input-text">
6869
</div>
6970
</div>
@@ -75,9 +76,8 @@ switch ($block->getCheckoutType()):
7576
<input type="text"
7677
name="giftmessage[quote][<?= (int) $block->getEntity()->getId() ?>][to]"
7778
id="gift-message-whole-to" title="<?= $block->escapeHtmlAttr(__('To')) ?>"
78-
value="<?= /* @noEscape */ $block
79-
->getEscaped($block->getMessage()->getRecipient(), $block->getDefaultTo())
80-
?>" class="input-text">
79+
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage()->getRecipient() ?? '', $block->getDefaultTo()) ?>"
80+
class="input-text">
8181
</div>
8282
</div>
8383
<div class="field text">
@@ -87,7 +87,7 @@ switch ($block->getCheckoutType()):
8787
<div class="control">
8888
<textarea id="gift-message-whole-message" class="input-text"
8989
name="giftmessage[quote][<?=(int)$block->getEntity()->getId()?>][message]"
90-
title="<?= $block->escapeHtmlAttr(__('Message')) ?>" rows="5" cols="10"><?= /* @noEscape */ $block->getEscaped($block->getMessage()->getMessage()) ?></textarea>
90+
title="<?= $block->escapeHtmlAttr(__('Message')) ?>" rows="5" cols="10"><?= $escaper->escapeHtml($block->getMessage()->getMessage()) ?></textarea>
9191
</div>
9292
</div>
9393
</fieldset>
@@ -165,7 +165,7 @@ script;
165165
value=
166166
"<?= /* @noEscape */
167167
$block->getEscaped(
168-
$block->getMessage($_item)->getSender(),
168+
$block->getMessage($_item)->getSender() ?? '',
169169
$block->getDefaultFrom()
170170
) ?>" class="input-text">
171171
</div>
@@ -179,8 +179,7 @@ script;
179179
name="giftmessage[quote_item][<?= (int) $_item->getId() ?>][to]"
180180
id="gift-message-<?= (int) $_item->getId() ?>-to"
181181
title="<?= $block->escapeHtmlAttr(__('To')) ?>"
182-
value="<?= /* @noEscape */ $block->getEscaped($block
183-
->getMessage($_item)->getRecipient(), $block->getDefaultTo()) ?>"
182+
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage($_item)->getRecipient() ?? '', $block->getDefaultTo()) ?>"
184183
class="input-text">
185184
</div>
186185
</div>
@@ -194,7 +193,7 @@ script;
194193
name="giftmessage[quote_item][<?= (int) $_item->getId()
195194
?>][message]"
196195
title="<?= $block->escapeHtmlAttr(__('Message')) ?>"
197-
rows="5" cols="40"><?= /* @noEscape */ $block->getEscaped($block->getMessage($_item)->getMessage()) ?></textarea>
196+
rows="5" cols="40"><?= $escaper->escapeHtml($block->getMessage($_item)->getMessage()) ?></textarea>
198197
</div>
199198
</div>
200199
</fieldset>
@@ -221,6 +220,7 @@ script;
221220
</dt>
222221
</dl>
223222
</fieldset>
223+
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
224224
<script type="text/x-magento-init">
225225
{
226226
"#allow_gift_options, #allow_gift_options_for_order, #allow_gift_options_for_items": {
@@ -291,8 +291,8 @@ script;
291291
->getId() ?>][from]"
292292
id="gift-message-<?= (int) $block->getEntity()->getId() ?>-from"
293293
title="<?= $block->escapeHtmlAttr(__('From')) ?>"
294-
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage()
295-
->getSender(), $block->getDefaultFrom()) ?>" class="input-text">
294+
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage()->getSender() ?? '', $block->getDefaultFrom()) ?>"
295+
class="input-text">
296296
</div>
297297
</div>
298298
<div class="field to">
@@ -304,8 +304,8 @@ script;
304304
->getId() ?>][to]"
305305
id="gift-message-<?= (int) $block->getEntity()->getId() ?>-to"
306306
title="<?= $block->escapeHtmlAttr(__('To')) ?>"
307-
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage()
308-
->getRecipient(), $block->getDefaultTo()) ?>" class="input-text">
307+
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage()->getRecipient() ?? '', $block->getDefaultTo()) ?>"
308+
class="input-text">
309309
</div>
310310
</div>
311311
<div class="field text">
@@ -316,7 +316,7 @@ script;
316316
<textarea id="gift-message-<?= (int) $block->getEntity()->getId() ?>-message"
317317
class="input-text" name="giftmessage[quote_address][<?= (int) $block
318318
->getEntity()->getId() ?>][message]"
319-
title="<?= $block->escapeHtmlAttr(__('Message')) ?>" rows="5" cols="40"><?= /* @noEscape */ $block->getEscaped($block->getMessage()->getMessage()) ?></textarea>
319+
title="<?= $block->escapeHtmlAttr(__('Message')) ?>" rows="5" cols="40"><?= $escaper->escapeHtml($block->getMessage()->getMessage()) ?></textarea>
320320
</div>
321321
</div>
322322
</fieldset>
@@ -391,9 +391,8 @@ script;
391391
name="giftmessage[quote_address_item][<?= (int) $_item->getId()
392392
?>][from]" id="gift-message-<?= (int) $_item->getId() ?>-from"
393393
title="<?= $block->escapeHtmlAttr(__('From')) ?>"
394-
value="<?= /* @noEscape */ $block->getEscaped($block
395-
->getMessage($_item)->getSender(), $block->getDefaultFrom())
396-
?>" class="input-text">
394+
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage($_item)->getSender() ?? '', $block->getDefaultFrom()) ?>"
395+
class="input-text">
397396
</div>
398397
</div>
399398
<div class="field to">
@@ -405,10 +404,8 @@ script;
405404
name="giftmessage[quote_address_item][<?= (int) $_item->getId()
406405
?>][to]" id="gift-message-<?= (int) $_item->getId() ?>-to"
407406
title="<?= $block->escapeHtmlAttr(__('To')) ?>"
408-
value=
409-
"<?= /* @noEscape */ $block->getEscaped($block
410-
->getMessage($_item)->getRecipient(), $block->getDefaultTo())
411-
?>" class="input-text">
407+
value="<?= /* @noEscape */ $block->getEscaped($block->getMessage($_item)->getRecipient() ?? '', $block->getDefaultTo()) ?>"
408+
class="input-text">
412409
</div>
413410
</div>
414411
<div class="field text">
@@ -421,7 +418,7 @@ script;
421418
name="giftmessage[quote_address_item][<?= (int) $_item
422419
->getId() ?>][message]"
423420
title="<?= $block->escapeHtmlAttr(__('Message')) ?>" rows="5"
424-
cols="10"><?= /* @noEscape */ $block->getEscaped($block->getMessage($_item)->getMessage()) ?></textarea>
421+
cols="10"><?= $escaper->escapeHtml($block->getMessage($_item)->getMessage()) ?></textarea>
425422
</div>
426423
</div>
427424
</fieldset>
@@ -437,7 +434,8 @@ script;
437434
</dt>
438435
</dl>
439436
</fieldset>
440-
<?php $entityId = (int) $block->getEntity()->getId(); ?>
437+
<?php $entityId = (int) $block->getEntity()->getId(); ?>
438+
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
441439
<script type="text/x-magento-init">
442440
{
443441
"#allow_gift_options_<?= /* @noEscape */ $entityId ?>, #allow_gift_options_for_order_<?= /* @noEscape */ $entityId ?>, #allow_gift_options_for_items_<?= /* @noEscape */ $entityId ?>": {
@@ -449,6 +447,7 @@ script;
449447
break;
450448
endswitch;
451449
if ($_giftMessage): ?>
450+
<?php // phpcs:ignore Magento2.Legacy.PhtmlTemplate ?>
452451
<script type="text/x-magento-init">
453452
{
454453
"#shipping_method_form": {

app/code/Magento/OfflinePayments/Model/Banktransfer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class Banktransfer extends \Magento\Payment\Model\Method\AbstractMethod
1717
{
18-
const PAYMENT_METHOD_BANKTRANSFER_CODE = 'banktransfer';
18+
public const PAYMENT_METHOD_BANKTRANSFER_CODE = 'banktransfer';
1919

2020
/**
2121
* Payment method code
@@ -52,6 +52,7 @@ class Banktransfer extends \Magento\Payment\Model\Method\AbstractMethod
5252
*/
5353
public function getInstructions()
5454
{
55-
return trim($this->getConfigData('instructions'));
55+
$instructions = $this->getConfigData('instructions');
56+
return $instructions !== null ? trim($instructions) : '';
5657
}
5758
}

app/code/Magento/OfflinePayments/Model/Cashondelivery.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
class Cashondelivery extends \Magento\Payment\Model\Method\AbstractMethod
1717
{
18-
const PAYMENT_METHOD_CASHONDELIVERY_CODE = 'cashondelivery';
18+
public const PAYMENT_METHOD_CASHONDELIVERY_CODE = 'cashondelivery';
1919

2020
/**
2121
* Payment method code
@@ -52,6 +52,7 @@ class Cashondelivery extends \Magento\Payment\Model\Method\AbstractMethod
5252
*/
5353
public function getInstructions()
5454
{
55-
return trim($this->getConfigData('instructions'));
55+
$instructions = $this->getConfigData('instructions');
56+
return $instructions !== null ? trim($instructions) : '';
5657
}
5758
}

0 commit comments

Comments
 (0)