Skip to content

Commit 4beb3d7

Browse files
committed
Merge branch 'main' into next
2 parents 1c93e5b + 1f54fc7 commit 4beb3d7

File tree

101 files changed

+225
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+225
-154
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,15 @@
14011401
"code"
14021402
]
14031403
},
1404+
{
1405+
"login": "Judx",
1406+
"name": "Juho Hölsä",
1407+
"avatar_url": "https://avatars.githubusercontent.com/u/15036353?v=4",
1408+
"profile": "https://juhoholsa.com/",
1409+
"contributions": [
1410+
"code"
1411+
]
1412+
}
14041413
],
14051414
"contributorsPerLine": 7
14061415
}

.github/workflows/check-files.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171

7272
- name: Get changed files
7373
id: changed-files-specific
74-
uses: tj-actions/changed-files@v35
74+
uses: tj-actions/changed-files@v36
7575
with:
7676
files: |
7777
composer.*

app/code/core/Mage/Adminhtml/Block/Report/Grid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public function addGrandTotals($total)
412412
* recalc totals if we have average
413413
*/
414414
foreach ($this->getColumns() as $key => $_column) {
415-
if (strpos($_column->getTotal(), '/') !== false) {
415+
if (str_contains($_column->getTotal(), '/')) {
416416
list($t1, $t2) = explode('/', $_column->getTotal());
417417
if ($this->getGrandTotals()->getData($t2) != 0) {
418418
$this->getGrandTotals()->setData(

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Form/Account.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function getFormValues()
125125
{
126126
$data = $this->getCustomer()->getData();
127127
foreach ($this->getQuote()->getData() as $key => $value) {
128-
if (strpos($key, 'customer_') === 0) {
128+
if (str_starts_with($key, 'customer_')) {
129129
$data[substr($key, 9)] = $value;
130130
}
131131
}

app/code/core/Mage/Adminhtml/Block/Urlrewrite/Edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function getButtonsHtml($area = null)
195195
if ($this->_buttonsHtml === null) {
196196
$this->_buttonsHtml = parent::getButtonsHtml();
197197
foreach ($this->_children as $alias => $child) {
198-
if (strpos($alias, '_button') !== false) {
198+
if (str_contains($alias, '_button')) {
199199
$this->unsetChild($alias);
200200
}
201201
}

app/code/core/Mage/Adminhtml/Helper/Js.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Mage_Adminhtml_Helper_Js extends Mage_Core_Helper_Js
4343
*/
4444
public function decodeGridSerializedInput($encoded)
4545
{
46-
$isSimplified = (strpos($encoded, '=') === false);
46+
$isSimplified = !str_contains($encoded, '=');
4747
$result = [];
4848
parse_str($encoded, $decoded);
4949
foreach ($decoded as $key => $value) {

app/code/core/Mage/Adminhtml/Model/Sales/Order/Create.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ protected function _parseOptions(Mage_Sales_Model_Quote_Item $item, $additionalO
903903
foreach (explode("\n", $additionalOptions) as $_additionalOption) {
904904
if (strlen(trim($_additionalOption))) {
905905
try {
906-
if (strpos($_additionalOption, ':') === false) {
906+
if (!str_contains($_additionalOption, ':')) {
907907
Mage::throwException(
908908
Mage::helper('adminhtml')->__('There is an error in one of the option rows.')
909909
);

app/code/core/Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ public function deleteFilesAction()
121121
foreach ($files as $file) {
122122
$file = $helper->idDecode($file);
123123
$_filePath = realpath($path . DS . $file);
124-
if (strpos($_filePath, realpath($path)) === 0 &&
125-
strpos($_filePath, realpath($helper->getStorageRoot())) === 0
124+
if (str_starts_with($_filePath, realpath($path)) &&
125+
str_starts_with($_filePath, realpath($helper->getStorageRoot()))
126126
) {
127127
$this->getStorage()->deleteFile($path . DS . $file);
128128
}

app/code/core/Mage/Adminhtml/controllers/Report/StatisticsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected function _getCollectionNames()
8787
throw new Exception(Mage::helper('adminhtml')->__('No report code specified.'));
8888
}
8989

90-
if (!is_array($codes) && strpos($codes, ',') === false) {
90+
if (!is_array($codes) && !str_contains($codes, ',')) {
9191
$codes = [$codes];
9292
} elseif (!is_array($codes)) {
9393
$codes = explode(',', $codes);

app/code/core/Mage/Adminhtml/controllers/System/Convert/GuiController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function uploadPostAction()
118118
public function downloadAction()
119119
{
120120
$filename = $this->getRequest()->getParam('filename');
121-
if (!$filename || strpos($filename, '..') !== false || $filename[0] === '.') {
121+
if (!$filename || str_contains($filename, '..') || $filename[0] === '.') {
122122
return;
123123
}
124124
$this->_initProfile();

app/code/core/Mage/Api/Model/Server/V2/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __call($function, $args)
3838
$nodes = Mage::getSingleton('api/config')->getNode('v2/resources_function_prefix')->children();
3939
foreach ($nodes as $resource => $prefix) {
4040
$prefix = $prefix->asArray();
41-
if (strpos($function, $prefix) !== false) {
41+
if (str_contains($function, $prefix)) {
4242
$method = substr($function, strlen($prefix));
4343
$apiKey = $resource . '.' . strtolower($method[0]) . substr($method, 1);
4444
}

app/code/core/Mage/Api/Model/Server/Wsi/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function __call($function, $args)
5252
$nodes = Mage::getSingleton('api/config')->getNode('v2/resources_function_prefix')->children();
5353
foreach ($nodes as $resource => $prefix) {
5454
$prefix = $prefix->asArray();
55-
if (strpos($function, $prefix) !== false) {
55+
if (str_contains($function, $prefix)) {
5656
$method = substr($function, strlen($prefix));
5757
$apiKey = $resource . '.' . strtolower($method[0]) . substr($method, 1);
5858
}

app/code/core/Mage/Api2/Model/Acl/Global/Rule/Tree.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ public function getPostResources()
183183
$prefixPrivilege = self::NAME_PRIVILEGE . self::ID_SEPARATOR;
184184
$nameResource = null;
185185
foreach ($checkedResources as $i => $item) {
186-
if (strpos($item, $prefixResource) === 0) {
186+
if (str_starts_with($item, $prefixResource)) {
187187
$nameResource = substr($item, mb_strlen($prefixResource, 'UTF-8'));
188188
$resources[$nameResource] = [];
189-
} elseif (strpos($item, $prefixPrivilege) === 0) {
189+
} elseif (str_starts_with($item, $prefixPrivilege)) {
190190
$name = substr($item, mb_strlen($prefixPrivilege, 'UTF-8'));
191191
$namePrivilege = str_replace($nameResource . self::ID_SEPARATOR, '', $name);
192192
$resources[$nameResource][$namePrivilege] = $allow;
@@ -201,14 +201,14 @@ public function getPostResources()
201201
$prefixAttribute = self::NAME_ATTRIBUTE . self::ID_SEPARATOR;
202202
$nameResource = null;
203203
foreach ($checkedResources as $i => $item) {
204-
if (strpos($item, $prefixResource) === 0) {
204+
if (str_starts_with($item, $prefixResource)) {
205205
$nameResource = substr($item, mb_strlen($prefixResource, 'UTF-8'));
206206
$resources[$nameResource] = [];
207-
} elseif (strpos($item, $prefixOperation) === 0) {
207+
} elseif (str_starts_with($item, $prefixOperation)) {
208208
$name = substr($item, mb_strlen($prefixOperation, 'UTF-8'));
209209
$operationName = str_replace($nameResource . self::ID_SEPARATOR, '', $name);
210210
$resources[$nameResource][$operationName] = [];
211-
} elseif (strpos($item, $prefixAttribute) === 0) {
211+
} elseif (str_starts_with($item, $prefixAttribute)) {
212212
$name = substr($item, mb_strlen($prefixOperation, 'UTF-8'));
213213
$attributeName = str_replace(
214214
$nameResource . self::ID_SEPARATOR . $operationName . self::ID_SEPARATOR,

app/code/core/Mage/Catalog/Model/Category/Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public function move($categoryId, $parentId, $afterId = null)
354354
$afterId = array_pop(explode(',', $parentChildren));
355355
}
356356

357-
if (strpos($parent_category->getPath(), $category->getPath()) === 0) {
357+
if (str_starts_with($parent_category->getPath(), $category->getPath())) {
358358
$this->_fault('not_moved', "Operation do not allow to move a parent category to any of children category");
359359
}
360360

app/code/core/Mage/Catalog/Model/Product/Attribute/Backend/Media.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function addImage(
273273
$move = false,
274274
$exclude = true
275275
) {
276-
if (strpos($file, chr(0)) !== false
276+
if (str_contains($file, chr(0))
277277
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $file)
278278
) {
279279
throw new Exception('Detected malicious path or filename input.');

app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,14 +800,14 @@ protected function _getBytesIniValue($ini_key)
800800
{
801801
$_bytes = @ini_get($ini_key);
802802

803-
// kilobytes
804803
if (stristr($_bytes, 'k')) {
804+
// kilobytes
805805
$_bytes = (int) $_bytes * 1024;
806-
// megabytes
807806
} elseif (stristr($_bytes, 'm')) {
807+
// megabytes
808808
$_bytes = (int) $_bytes * 1024 * 1024;
809-
// gigabytes
810809
} elseif (stristr($_bytes, 'g')) {
810+
// gigabytes
811811
$_bytes = (int) $_bytes * 1024 * 1024 * 1024;
812812
}
813813
return (int)$_bytes;

app/code/core/Mage/Catalog/Model/Resource/Layer/Filter/Price.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected function _getSelect($filter)
112112
$wherePart = $select->getPart(Zend_Db_Select::WHERE);
113113
$excludedWherePart = Mage_Catalog_Model_Resource_Product_Collection::MAIN_TABLE_ALIAS . '.status';
114114
foreach ($wherePart as $key => $wherePartItem) {
115-
if (strpos($wherePartItem, $excludedWherePart) !== false) {
115+
if (str_contains($wherePartItem, $excludedWherePart)) {
116116
$wherePart[$key] = new Zend_Db_Expr('1=1');
117117
continue;
118118
}
@@ -121,7 +121,7 @@ protected function _getSelect($filter)
121121
$select->setPart(Zend_Db_Select::WHERE, $wherePart);
122122
$excludeJoinPart = Mage_Catalog_Model_Resource_Product_Collection::MAIN_TABLE_ALIAS . '.entity_id';
123123
foreach ($priceIndexJoinConditions as $condition) {
124-
if (strpos($condition, $excludeJoinPart) !== false) {
124+
if (str_contains($condition, $excludeJoinPart)) {
125125
continue;
126126
}
127127
$select->where($this->_replaceTableAlias($condition));

app/code/core/Mage/Catalog/Model/Template/Filter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function storeDirective($construction)
104104
$params['_query'] = [];
105105
}
106106
foreach ($params as $k => $v) {
107-
if (strpos($k, '_query_') === 0) {
107+
if (str_starts_with($k, '_query_')) {
108108
$params['_query'][substr($k, 7)] = $v;
109109
unset($params[$k]);
110110
}

app/code/core/Mage/Catalog/Model/Url.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ public function getUnusedPath($storeId, $requestPath, $idPath)
608608
*/
609609
public function getUnusedPathByUrlKey($storeId, $requestPath, $idPath, $urlKey)
610610
{
611-
if (strpos($idPath, 'product') !== false) {
611+
if (str_contains($idPath, 'product')) {
612612
$suffix = $this->getProductUrlSuffix($storeId);
613613
} else {
614614
$suffix = $this->getCategoryUrlSuffix($storeId);
@@ -805,7 +805,7 @@ public function getProductRequestPath($product, $category)
805805
* Check if existing request past can be used
806806
*/
807807
if ($product->getUrlKey() == '' && !empty($requestPath)
808-
&& strpos($existingRequestPath, $requestPath) === 0
808+
&& str_starts_with($existingRequestPath, $requestPath)
809809
) {
810810
$existingRequestPath = preg_replace(
811811
'/^' . preg_quote($requestPath, '/') . '/',

app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function deleteDirectory($path)
226226
$io->getFilteredPath($path)
227227
));
228228
}
229-
if (strpos($pathCmp, chr(0)) !== false
229+
if (str_contains($pathCmp, chr(0))
230230
|| preg_match('#(^|[\\\\/])\.\.($|[\\\\/])#', $pathCmp)
231231
) {
232232
throw new Exception('Detected malicious path or filename input.');
@@ -239,7 +239,7 @@ public function deleteDirectory($path)
239239
Mage::throwException(Mage::helper('cms')->__('Cannot delete directory %s.', $io->getFilteredPath($path)));
240240
}
241241

242-
if (strpos($pathCmp, $rootCmp) === 0) {
242+
if (str_starts_with($pathCmp, $rootCmp)) {
243243
$io->rmdir($this->getThumbnailRoot() . DS . ltrim(substr($pathCmp, strlen($rootCmp)), '\\/'), true);
244244
}
245245
}
@@ -319,7 +319,7 @@ public function getThumbnailPath($filePath, $checkFile = false)
319319
{
320320
$mediaRootDir = $this->getHelper()->getStorageRoot();
321321

322-
if (strpos($filePath, $mediaRootDir) === 0) {
322+
if (str_starts_with($filePath, $mediaRootDir)) {
323323
$thumbPath = $this->getThumbnailRoot() . DS . substr($filePath, strlen($mediaRootDir));
324324

325325
if (!$checkFile || is_readable($thumbPath)) {
@@ -340,7 +340,7 @@ public function getThumbnailPath($filePath, $checkFile = false)
340340
public function getThumbnailUrl($filePath, $checkFile = false)
341341
{
342342
$mediaRootDir = Mage::getConfig()->getOptions()->getMediaDir() . DS;
343-
if (strpos($filePath, $mediaRootDir) === 0) {
343+
if (str_starts_with($filePath, $mediaRootDir)) {
344344
$thumbSuffix = self::THUMBS_DIRECTORY_NAME . DS . substr($filePath, strlen($mediaRootDir));
345345
if (!$checkFile || is_readable($this->getHelper()->getStorageRoot() . $thumbSuffix)) {
346346
$randomIndex = '?rand=' . time();
@@ -420,7 +420,7 @@ public function getThumbsPath($filePath = false)
420420
$mediaRootDir = Mage::getConfig()->getOptions()->getMediaDir();
421421
$thumbnailDir = $this->getThumbnailRoot();
422422

423-
if ($filePath && strpos($filePath, $mediaRootDir) === 0) {
423+
if ($filePath && str_starts_with($filePath, $mediaRootDir)) {
424424
$thumbnailDir .= DS . dirname(substr($filePath, strlen($mediaRootDir)));
425425
}
426426

app/code/core/Mage/Core/Block/Template.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function assign($key, $value = null)
156156
*/
157157
public function setScriptPath($dir)
158158
{
159-
if (strpos($dir, '..') === false && ($dir === Mage::getBaseDir('design') || strpos(realpath($dir), realpath(Mage::getBaseDir('design'))) === 0)) {
159+
if (!str_contains($dir, '..') && ($dir === Mage::getBaseDir('design') || str_starts_with(realpath($dir), realpath(Mage::getBaseDir('design'))))) {
160160
$this->_viewDir = $dir;
161161
} else {
162162
Mage::log('Not valid script path:' . $dir, Zend_Log::CRIT, null, true);
@@ -245,7 +245,7 @@ public function fetchView($fileName)
245245
try {
246246
if (strpos($this->_viewDir . DS . $fileName, '..') === false
247247
&&
248-
($this->_viewDir == Mage::getBaseDir('design') || strpos(realpath($this->_viewDir), realpath(Mage::getBaseDir('design'))) === 0)
248+
($this->_viewDir == Mage::getBaseDir('design') || str_starts_with(realpath($this->_viewDir), realpath(Mage::getBaseDir('design'))))
249249
) {
250250
include $this->_viewDir . DS . $fileName;
251251
} else {

app/code/core/Mage/Core/Controller/Request/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public function getHttpHost($trimPort = true)
329329
$host = $hostParts[0];
330330
}
331331

332-
if (strpos($host, ',') !== false || strpos($host, ';') !== false) {
332+
if (str_contains($host, ',') || str_contains($host, ';')) {
333333
$response = new Zend_Controller_Response_Http();
334334
$response->setHttpResponseCode(400)->sendHeaders();
335335
exit();

app/code/core/Mage/Core/Controller/Varien/Action.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -805,12 +805,12 @@ protected function _getRefererUrl()
805805
*/
806806
protected function _isUrlInternal($url)
807807
{
808-
if (strpos($url, 'http') !== false) {
808+
if (str_contains($url, 'http')) {
809809
/**
810810
* Url must start from base secure or base unsecure url
811811
*/
812-
if ((strpos($url, Mage::app()->getStore()->getBaseUrl()) === 0)
813-
|| (strpos($url, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true)) === 0)
812+
if (str_starts_with($url, Mage::app()->getStore()->getBaseUrl())
813+
|| str_starts_with($url, Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, true))
814814
) {
815815
return true;
816816
}

app/code/core/Mage/Core/Controller/Varien/Router/Standard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public function getControllerFileName($realModule, $controller)
431431
*/
432432
public function validateControllerFileName($fileName)
433433
{
434-
if ($fileName && is_readable($fileName) && strpos($fileName, '//') === false) {
434+
if ($fileName && is_readable($fileName) && !str_contains($fileName, '//')) {
435435
return true;
436436
}
437437
return false;

app/code/core/Mage/Core/Helper/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function getRemoteAddr($ipToLong = false)
134134
return false;
135135
}
136136

137-
if (strpos($this->_remoteAddr, ',') !== false) {
137+
if (str_contains($this->_remoteAddr, ',')) {
138138
$ipList = explode(',', $this->_remoteAddr);
139139
$this->_remoteAddr = trim(reset($ipList));
140140
}

app/code/core/Mage/Core/Helper/String.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public function parseQueryStr($str)
337337
*/
338338
protected function _validateQueryStr($str)
339339
{
340-
if (!$str || (strpos($str, '=') === false)) {
340+
if (!$str || !str_contains($str, '=')) {
341341
return false;
342342
}
343343
return true;

app/code/core/Mage/Core/Helper/Url.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ public function decodePunycode($url)
199199
*/
200200
private function _isPunycode($host)
201201
{
202-
if (strpos($host, 'xn--') === 0 || strpos($host, '.xn--') !== false
203-
|| strpos($host, 'XN--') === 0 || strpos($host, '.XN--') !== false
202+
if (str_starts_with($host, 'xn--') || str_contains($host, '.xn--')
203+
|| str_starts_with($host, 'XN--') || str_contains($host, '.XN--')
204204
) {
205205
return true;
206206
}

app/code/core/Mage/Core/Helper/Url/Rewrite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function _validateRequestPath($requestPath)
5151
$this->__('Request path length exceeds allowed %s symbols.', self::TARGET_PATH_ALLOWED_LENGTH)
5252
);
5353
}
54-
if (strpos($requestPath, '//') !== false) {
54+
if (str_contains($requestPath, '//')) {
5555
throw new Mage_Core_Exception(
5656
$this->__('Two and more slashes together are not permitted in request path'),
5757
self::VERR_MANYSLASHES

app/code/core/Mage/Core/Model/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ public function isCurrentlySecure()
13101310
$offloaderHeader = strtoupper(trim((string) Mage::getConfig()->getNode(Mage_Core_Model_Store::XML_PATH_OFFLOADER_HEADER, 'default')));
13111311
if ($offloaderHeader) {
13121312
$offloaderHeader = preg_replace('/[^A-Z]+/', '_', $offloaderHeader);
1313-
$offloaderHeader = strpos($offloaderHeader, 'HTTP_') === 0 ? $offloaderHeader : 'HTTP_' . $offloaderHeader;
1313+
$offloaderHeader = str_starts_with($offloaderHeader, 'HTTP_') ? $offloaderHeader : 'HTTP_' . $offloaderHeader;
13141314
if (!empty($_SERVER[$offloaderHeader]) && $_SERVER[$offloaderHeader] !== 'http') {
13151315
return true;
13161316
}

0 commit comments

Comments
 (0)