Skip to content

Commit 8fb4122

Browse files
committed
Merge remote-tracking branch 'origin/AC-3162-p11' into delivery-bunch-w22
2 parents c57019b + d87f070 commit 8fb4122

File tree

14 files changed

+77
-56
lines changed

14 files changed

+77
-56
lines changed

app/code/Magento/Weee/Plugin/Checkout/CustomerData/Cart.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Magento\Weee\Plugin\Checkout\CustomerData;
88

9+
/**
10+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
11+
*/
912
class Cart extends \Magento\Tax\Plugin\Checkout\CustomerData\Cart
1013
{
1114
/**

lib/internal/Magento/Framework/DB/AbstractMapper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ public function addExpressionFieldToSelect($alias, $expression, $fields)
152152
}
153153
$fullExpression = $expression;
154154
foreach ($fields as $fieldKey => $fieldItem) {
155+
$fieldItem = $fieldItem !== null ? $fieldItem : '';
156+
$fullExpression = $fullExpression !== null ? $fullExpression : '';
155157
$fullExpression = str_replace('{{' . $fieldKey . '}}', $fieldItem, $fullExpression);
156158
}
157159
$this->getSelect()->columns([$alias => $fullExpression]);

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ public function rawFetchRow($sql, $field = null)
527527
protected function _checkDdlTransaction($sql)
528528
{
529529
if ($this->getTransactionLevel() > 0) {
530-
$sql = ltrim(preg_replace('/\s+/', ' ', $sql));
530+
$sql = $sql !== null ? ltrim(preg_replace('/\s+/', ' ', $sql)) : '';
531531
$sqlMessage = explode(' ', $sql, 3);
532532
$startSql = strtolower(substr($sqlMessage[0], 0, 3));
533533
if (in_array($startSql, $this->_ddlRoutines) && strcasecmp($sqlMessage[1], 'temporary') !== 0) {
@@ -623,7 +623,10 @@ protected function _query($sql, $bind = [])
623623
*/
624624
public function query($sql, $bind = [])
625625
{
626-
if (strpos(rtrim($sql, " \t\n\r\0;"), ';') !== false && count($this->_splitMultiQuery($sql)) > 1) {
626+
if ($sql !== null &&
627+
strpos(rtrim($sql, " \t\n\r\0;"), ';') !== false &&
628+
count($this->_splitMultiQuery($sql)) > 1
629+
) {
627630
throw new \Magento\Framework\Exception\LocalizedException(
628631
new Phrase("Multiple queries can't be executed. Run a single query and try again.")
629632
);
@@ -746,6 +749,7 @@ protected function _convertMixedBind(&$sql, &$bind)
746749
{
747750
$positions = [];
748751
$offset = 0;
752+
$sql = (string)$sql;
749753
// get positions
750754
while (true) {
751755
$pos = strpos($sql, '?', $offset);
@@ -879,7 +883,7 @@ protected function _splitMultiQuery($sql)
879883
public function dropForeignKey($tableName, $fkName, $schemaName = null)
880884
{
881885
$foreignKeys = $this->getForeignKeys($tableName, $schemaName);
882-
$fkName = strtoupper($fkName);
886+
$fkName = $fkName !== null ? strtoupper($fkName) : '';
883887
if (substr($fkName, 0, 3) == 'FK_') {
884888
$fkName = substr($fkName, 3);
885889
}
@@ -1220,7 +1224,7 @@ public function showTableStatus($tableName, $schemaName = null)
12201224
private function isMysql8EngineUsed(): bool
12211225
{
12221226
if (!$this->isMysql8Engine) {
1223-
$version = $this->fetchPairs("SHOW variables LIKE 'version'")['version'];
1227+
$version = $this->fetchPairs("SHOW variables LIKE 'version'")['version'] ?? '';
12241228
$this->isMysql8Engine = (bool) preg_match('/^(8\.)/', $version);
12251229
}
12261230

@@ -1430,11 +1434,11 @@ public function getIndexList($tableName, $schemaName = null)
14301434
$fieldColumn = 'Column_name';
14311435
$fieldIndexType = 'Index_type';
14321436

1433-
if (strtolower($row[$fieldKeyName]) == AdapterInterface::INDEX_TYPE_PRIMARY) {
1437+
if (strtolower($row[$fieldKeyName] ?? '') == AdapterInterface::INDEX_TYPE_PRIMARY) {
14341438
$indexType = AdapterInterface::INDEX_TYPE_PRIMARY;
14351439
} elseif ($row[$fieldNonUnique] == 0) {
14361440
$indexType = AdapterInterface::INDEX_TYPE_UNIQUE;
1437-
} elseif (strtolower($row[$fieldIndexType]) == AdapterInterface::INDEX_TYPE_FULLTEXT) {
1441+
} elseif (strtolower($row[$fieldIndexType] ?? '') == AdapterInterface::INDEX_TYPE_FULLTEXT) {
14381442
$indexType = AdapterInterface::INDEX_TYPE_FULLTEXT;
14391443
} else {
14401444
$indexType = AdapterInterface::INDEX_TYPE_INDEX;
@@ -2368,7 +2372,7 @@ protected function _getIndexesDefinition(Table $table)
23682372
*/
23692373
protected function isNdb(Table $table)
23702374
{
2371-
$engineType = strtolower($table->getOption('type'));
2375+
$engineType = strtolower($table->getOption('type') ?? '');
23722376
return $engineType == 'ndb' || $engineType == 'ndbcluster';
23732377
}
23742378

@@ -2783,7 +2787,7 @@ public function addIndex(
27832787
}
27842788
$fieldSql = implode(',', $fieldSql);
27852789

2786-
switch (strtolower($indexType)) {
2790+
switch (strtolower((string)$indexType)) {
27872791
case AdapterInterface::INDEX_TYPE_PRIMARY:
27882792
$condition = 'PRIMARY KEY';
27892793
break;
@@ -2806,7 +2810,7 @@ public function addIndex(
28062810
$result = $this->rawQuery($query);
28072811
$cycle = false;
28082812
} catch (\Exception $e) {
2809-
if (in_array(strtolower($indexType), ['primary', 'unique'])) {
2813+
if ($indexType !== null && in_array(strtolower($indexType), ['primary', 'unique'])) {
28102814
$match = [];
28112815
// phpstan:ignore
28122816
if (preg_match('#SQLSTATE\[23000\]: [^:]+: 1062[^\']+\'([\d.-]+)\'#', $e->getMessage(), $match)) {
@@ -2837,7 +2841,7 @@ public function dropIndex($tableName, $keyName, $schemaName = null)
28372841
{
28382842
$indexList = $this->getIndexList($tableName, $schemaName);
28392843
$indexType = 'index';
2840-
$keyName = strtoupper($keyName);
2844+
$keyName = $keyName !== null ? strtoupper($keyName) : '';
28412845
if (!isset($indexList[$keyName])) {
28422846
return true;
28432847
}
@@ -3076,7 +3080,7 @@ public function prepareSqlCondition($fieldName, $condition)
30763080
*/
30773081
protected function _prepareQuotedSqlCondition($text, $value, $fieldName)
30783082
{
3079-
$text = str_replace('{{fieldName}}', $fieldName, $text);
3083+
$text = str_replace('{{fieldName}}', (string)$fieldName, (string)$text);
30803084
$sql = $this->quoteInto($text, $value);
30813085
return $sql;
30823086
}
@@ -3480,7 +3484,7 @@ public function getIndexName($tableName, $fields, $indexType = '')
34803484
$fields = implode('_', $fields);
34813485
}
34823486

3483-
switch (strtolower($indexType)) {
3487+
switch (strtolower((string)$indexType)) {
34843488
case AdapterInterface::INDEX_TYPE_UNIQUE:
34853489
$prefix = 'unq_';
34863490
break;

lib/internal/Magento/Framework/DB/ExpressionConverter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ExpressionConverter
7676
*/
7777
public static function shortName($name)
7878
{
79-
return strtr($name, self::$_translateMap);
79+
return $name !== null ? strtr($name, self::$_translateMap) : '';
8080
}
8181

8282
/**
@@ -103,7 +103,7 @@ public static function addTranslate($from, $to)
103103
*/
104104
public static function shortenEntityName($entityName, $prefix)
105105
{
106-
if (strlen($entityName) > self::MYSQL_IDENTIFIER_LEN) {
106+
if ($entityName !== null && strlen($entityName) > self::MYSQL_IDENTIFIER_LEN) {
107107
$shortName = ExpressionConverter::shortName($entityName);
108108
if (strlen($shortName) > self::MYSQL_IDENTIFIER_LEN) {
109109
// md5() here is not for cryptographic use.

lib/internal/Magento/Framework/DB/FieldDataConverter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class FieldDataConverter
2121
/**
2222
* Batch size env variable name
2323
*/
24-
const BATCH_SIZE_VARIABLE_NAME = 'DATA_CONVERTER_BATCH_SIZE';
24+
public const BATCH_SIZE_VARIABLE_NAME = 'DATA_CONVERTER_BATCH_SIZE';
2525

2626
/**
2727
* Default batch size for data converter
2828
*/
29-
const DEFAULT_BATCH_SIZE = 50000;
29+
public const DEFAULT_BATCH_SIZE = 50000;
3030

3131
/**
3232
* @var Generator
@@ -95,7 +95,7 @@ public function convert(
9595
$field,
9696
QueryModifierInterface $queryModifier = null
9797
) {
98-
$identifiers = explode(',', $identifier);
98+
$identifiers = explode(',', (string)$identifier);
9999
if (count($identifiers) > 1) {
100100
$this->processTableWithCompositeIdentifier($connection, $table, $identifiers, $field, $queryModifier);
101101
} else {

lib/internal/Magento/Framework/DB/Helper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function _prepareOrder(\Magento\Framework\DB\Select $select, $autoRese
5959
protected function _truncateAliasName($field, $reverse = false)
6060
{
6161
$string = $field;
62-
if (!is_numeric($field) && (strpos($field, '.') !== false)) {
62+
if ($field !== null && !is_numeric($field) && (strpos($field, '.') !== false)) {
6363
$size = strpos($field, '.');
6464
if ($reverse) {
6565
$string = substr($field, 0, $size);
@@ -121,7 +121,7 @@ protected function _prepareHaving(\Magento\Framework\DB\Select $select, $autoRes
121121
/**
122122
* Looking for column expression in the having clause
123123
*/
124-
if (strpos($having, $correlationName) !== false) {
124+
if ($having !== null && strpos($having, $correlationName) !== false) {
125125
if (is_string($column)) {
126126
/**
127127
* Replace column expression to column alias in having clause

lib/internal/Magento/Framework/DB/Helper/AbstractHelper.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<?php
22
/**
3-
* Abstract DB helper class
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86
namespace Magento\Framework\DB\Helper;
97

8+
/**
9+
* Abstract DB helper class
10+
*/
1011
abstract class AbstractHelper
1112
{
1213
/**
@@ -63,7 +64,7 @@ protected function getConnection()
6364
*/
6465
public function escapeLikeValue($value, $options = [])
6566
{
66-
$value = str_replace('\\', '\\\\', $value);
67+
$value = $value !== null ? str_replace('\\', '\\\\', $value) : '';
6768

6869
$replaceFrom = [];
6970
$replaceTo = [];
@@ -99,8 +100,7 @@ public function escapeLikeValue($value, $options = [])
99100
}
100101

101102
/**
102-
* Escapes, quotes and adds escape symbol to LIKE expression.
103-
* For options and escaping see escapeLikeValue().
103+
* Escapes, quotes and adds escape symbol to LIKE expression. For options and escaping see escapeLikeValue().
104104
*
105105
* @param string $value
106106
* @param array $options
@@ -111,8 +111,7 @@ public function escapeLikeValue($value, $options = [])
111111
abstract public function addLikeEscape($value, $options = []);
112112

113113
/**
114-
* Returns case insensitive LIKE construction.
115-
* For options and escaping see escapeLikeValue().
114+
* Returns case insensitive LIKE construction. For options and escaping see escapeLikeValue().
116115
*
117116
* @param string $field
118117
* @param string $value

lib/internal/Magento/Framework/DB/Platform/Quote.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,11 @@
77

88
use Magento\Framework\DB\Select;
99

10-
/**
11-
* Class Quote
12-
*/
1310
class Quote
1411
{
1512
/**
13+
* Return quoted identifier
14+
*
1615
* @param string $identifier
1716
* @return string
1817
*/
@@ -22,6 +21,8 @@ public function quoteIdentifier($identifier)
2221
}
2322

2423
/**
24+
* Return quoted column with alias
25+
*
2526
* @param string $identifier
2627
* @param string|null $alias
2728
* @return string
@@ -32,6 +33,8 @@ public function quoteColumnAs($identifier, $alias = null)
3233
}
3334

3435
/**
36+
* Return quoted table with alias
37+
*
3538
* @param string $identifier
3639
* @param string|null $alias
3740
* @return string
@@ -42,6 +45,8 @@ public function quoteTableAs($identifier, $alias = null)
4245
}
4346

4447
/**
48+
* Return quoted identifier with alias
49+
*
4550
* @param string $identifier
4651
* @param string|null $alias
4752
* @return string
@@ -81,16 +86,20 @@ protected function quoteIdentifierAs($identifier, $alias = null)
8186
}
8287

8388
/**
89+
* Replace quote symbol
90+
*
8491
* @param string $value
8592
* @return string
8693
*/
8794
protected function replaceQuoteSymbol($value)
8895
{
8996
$symbol = $this->getQuoteIdentifierSymbol();
90-
return ($symbol . str_replace("$symbol", "$symbol$symbol", $value) . $symbol);
97+
return ($symbol . str_replace("$symbol", "$symbol$symbol", (string)$value) . $symbol);
9198
}
9299

93100
/**
101+
* Get quote identifier symbol
102+
*
94103
* @return string
95104
*/
96105
protected function getQuoteIdentifierSymbol()

lib/internal/Magento/Framework/DB/Select.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ class Select extends \Zend_Db_Select
3636
/**
3737
* Condition type
3838
*/
39-
const TYPE_CONDITION = 'TYPE_CONDITION';
39+
public const TYPE_CONDITION = 'TYPE_CONDITION';
4040

4141
/**
4242
* Straight join key
4343
*/
44-
const STRAIGHT_JOIN = 'straightjoin';
44+
public const STRAIGHT_JOIN = 'straightjoin';
4545

4646
/**
4747
* Straight join SQL directive.
4848
*/
49-
const SQL_STRAIGHT_JOIN = 'STRAIGHT_JOIN';
49+
public const SQL_STRAIGHT_JOIN = 'STRAIGHT_JOIN';
5050

5151
/**
5252
* @var Select\SelectRenderer
@@ -248,7 +248,8 @@ protected function _resetJoinLeft()
248248
protected function _findTableInCond($table, $cond)
249249
{
250250
$quote = $this->_adapter->getQuoteIdentifierSymbol();
251-
251+
$cond = (string)$cond;
252+
$table = (string)$table;
252253
if (strpos($cond, $quote . $table . $quote . '.') !== false) {
253254
return true;
254255
}
@@ -385,7 +386,7 @@ public function deleteFromSelect($table)
385386
*/
386387
public function setPart($part, $value)
387388
{
388-
$part = strtolower($part);
389+
$part = $part !== null ? strtolower($part) : '';
389390
if (!array_key_exists($part, $this->_parts)) {
390391
throw new \Zend_Db_Select_Exception("Invalid Select part '{$part}'");
391392
}

lib/internal/Magento/Framework/Data/Form/Filter/Striptags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Striptags implements \Magento\Framework\Data\Form\Filter\FilterInterface
2121
*/
2222
public function inputFilter($value)
2323
{
24-
return strip_tags($value);
24+
return $value !== null ? strip_tags($value) : '';
2525
}
2626

2727
/**

0 commit comments

Comments
 (0)