Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHP 8.1] Fix passing null to preg_split limit param #2616

Merged
merged 1 commit into from
Sep 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/core/Mage/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public function isDevAllowed($storeId = null)
$allowedIps = Mage::getStoreConfig(self::XML_PATH_DEV_ALLOW_IPS, $storeId);
$remoteAddr = Mage::helper('core/http')->getRemoteAddr();
if (!empty($allowedIps) && !empty($remoteAddr)) {
$allowedIps = preg_split('#\s*,\s*#', $allowedIps, null, PREG_SPLIT_NO_EMPTY);
$allowedIps = preg_split('#\s*,\s*#', $allowedIps, -1, PREG_SPLIT_NO_EMPTY);
if (array_search($remoteAddr, $allowedIps) === false
&& array_search(Mage::helper('core/http')->getHttpHost(), $allowedIps) === false) {
$allow = false;
Expand Down
4 changes: 2 additions & 2 deletions app/code/core/Mage/Core/Helper/String.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function str_split($str, $length = 1, $keepWords = false, $trim = false,
}
} // split smartly, keeping words
else {
$split = preg_split('/(' . $wordSeparatorRegex . '+)/siu', $str, null, PREG_SPLIT_DELIM_CAPTURE);
$split = preg_split('/(' . $wordSeparatorRegex . '+)/siu', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
$i = 0;
$space = '';
$spaceLen = 0;
Expand Down Expand Up @@ -253,7 +253,7 @@ public function str_split($str, $length = 1, $keepWords = false, $trim = false,
public function splitWords($str, $uniqueOnly = false, $maxWordLength = 0, $wordSeparatorRegexp = '\s')
{
$result = [];
$split = preg_split('#' . $wordSeparatorRegexp . '#siu', $str, null, PREG_SPLIT_NO_EMPTY);
$split = preg_split('#' . $wordSeparatorRegexp . '#siu', $str, -1, PREG_SPLIT_NO_EMPTY);
foreach ($split as $word) {
if ($uniqueOnly) {
$result[$word] = $word;
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Cron/Model/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function _construct()
*/
public function setCronExpr($expr)
{
$e = preg_split('#\s+#', $expr, null, PREG_SPLIT_NO_EMPTY);
$e = preg_split('#\s+#', $expr, -1, PREG_SPLIT_NO_EMPTY);
if (count($e) < 5 || count($e) > 6) {
throw Mage::exception('Mage_Cron', 'Invalid cron expression: '.$expr);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Rule/Model/Condition/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ public function getValueParsed()
if (!$this->hasValueParsed()) {
$value = $this->getData('value');
if ($this->isArrayOperatorType() && is_string($value)) {
$value = preg_split('#\s*[,;]\s*#', $value, null, PREG_SPLIT_NO_EMPTY);
$value = preg_split('#\s*[,;]\s*#', $value, -1, PREG_SPLIT_NO_EMPTY);
}
$this->setValueParsed($value);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Db/Adapter/Pdo/Mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ public function multi_query($sql)
*/
protected function _splitMultiQuery($sql)
{
$parts = preg_split('#(;|\'|"|\\\\|//|--|\n|/\*|\*/)#', $sql, null,
$parts = preg_split('#(;|\'|"|\\\\|//|--|\n|/\*|\*/)#', $sql, -1,
PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE
);

Expand Down
2 changes: 1 addition & 1 deletion lib/Varien/Event/Observer/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Varien_Event_Observer_Cron extends Varien_Event_Observer
*/
public function isValidFor(Varien_Event $event)
{
$e = preg_split('#\s+#', $this->getCronExpr(), null, PREG_SPLIT_NO_EMPTY);
$e = preg_split('#\s+#', $this->getCronExpr(), -1, PREG_SPLIT_NO_EMPTY);
if (count($e) !== 5) {
return false;
}
Expand Down