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

MAG2-314 - Added PHP 8.2 and PHP 8.3 compatibility to Simple Protect #558

Open
wants to merge 1 commit into
base: simple-protect
Choose a base branch
from
Open
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 Model/Api/Payolution/PrivacyDeclaration.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function getPayolutionAcceptanceText($sPaymentCode)
}

if (!$this->isUtf8($sPage)) {
$sPage = utf8_encode($sPage);
$sPage = mb_convert_encoding($sPage, 'UTF-8');
}

return $sPage;
Expand Down
4 changes: 2 additions & 2 deletions Model/Entities/ApiLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function formatArray($aArray)
{
foreach ($aArray as $sKey => $mValue) {
if (!$this->toolkitHelper->isUTF8($mValue)) {
$aArray[$sKey] = utf8_encode($mValue);
$aArray[$sKey] = mb_convert_encoding($mValue ?? '', 'UTF-8');
}
}
return $aArray;
Expand All @@ -105,7 +105,7 @@ protected function getUnserializedArray($sKey, $blSort = false)
$aRequest = unserialize($sRequest);
} catch(\Exception $exc) {
if ($this->toolkitHelper->isUTF8($sRequest)) {
$aRequest = unserialize(utf8_decode($sRequest));
$aRequest = unserialize(mb_convert_encoding($sRequest ?? '', 'ISO-8859-1', 'UTF-8'));
}
}
if (is_array($aRequest)) {
Expand Down
4 changes: 2 additions & 2 deletions Model/Entities/TransactionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function formatArray($aArray)
if (is_array($mValue)) {
$aArray[$sKey] = $this->formatArray($mValue);
} elseif (!$this->toolkitHelper->isUTF8($mValue)) {
$aArray[$sKey] = utf8_encode($mValue);
$aArray[$sKey] = mb_convert_encoding($mValue, 'UTF-8');
}
}
return $aArray;
Expand All @@ -107,7 +107,7 @@ protected function getUnserializedArray($sKey, $blSort = false)
$aRequest = unserialize($sRequest);
} catch(\Exception $exc) {
if ($this->toolkitHelper->isUTF8($sRequest)) {
$aRequest = unserialize(utf8_decode($sRequest));
$aRequest = unserialize(mb_convert_encoding($sRequest, 'ISO-8859-1', 'UTF-8'));
}
}
if (is_array($aRequest)) {
Expand Down
2 changes: 1 addition & 1 deletion Model/Methods/OnlineBankTransfer/Ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static function getBankGroups()
foreach (self::$aBankGroups as $sKey => $sTitle) {
$aReturn[] = [
'id' => $sKey,
'title' => utf8_encode($sTitle),
'title' => mb_convert_encoding($sTitle, 'UTF-8'),
];
}

Expand Down
4 changes: 2 additions & 2 deletions Model/ResourceModel/TransactionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function getParam($sKey, $sDefault = '')
if (isset($this->request[$sKey])) {
$sParam = $this->request[$sKey];
if (!$this->toolkitHelper->isUTF8($sParam)) {
$sParam = utf8_encode($sParam);
$sParam = mb_convert_encoding($sParam, 'UTF-8');
}
return $sParam;
}
Expand All @@ -141,7 +141,7 @@ public function addTransactionLogEntry($aRequest, Order $oOrder = null, $blHasBe

$sRawStatus = serialize($this->getRequest());
if (!$this->toolkitHelper->isUTF8($sRawStatus)) {
$sRawStatus = utf8_encode($sRawStatus); // needed for serializing the array
$sRawStatus = mb_convert_encoding($sRawStatus, 'UTF-8'); // needed for serializing the array
}
$sOrderId = $oOrder !== null ? $oOrder->getIncrementId() : '';
$this->getConnection()->insert(
Expand Down
4 changes: 2 additions & 2 deletions Test/Unit/Helper/ToolkitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ public function testFormatNumber()
public function testIsUTF8()
{
$input = 'not utf-8 - ä';
$result = $this->toolkit->isUTF8(utf8_decode($input));
$result = $this->toolkit->isUTF8(mb_convert_encoding($input, 'ISO-8859-1', 'UTF-8'));
$this->assertFalse($result);

$input = 'utf-8 äöü';
$result = $this->toolkit->isUTF8(utf8_encode($input));
$result = $this->toolkit->isUTF8(mb_convert_encoding($input, 'UTF-8'));
$this->assertTrue($result);
}

Expand Down
2 changes: 1 addition & 1 deletion Test/Unit/Model/Entities/ApiLogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function testGetRawRequestArray()
public function testGetRawStatusArrayException()
{
$aStatus = ['test1' => html_entity_decode(" ")];
$this->classToTest->setData('raw_request', utf8_encode(serialize($aStatus)));
$this->classToTest->setData('raw_request', mb_convert_encoding(serialize($aStatus), 'UTF-8'));
$this->toolkitHelper->method('isUTF8')->willReturn(true);

$result = $this->classToTest->getRawRequestArray();
Expand Down
2 changes: 1 addition & 1 deletion Test/Unit/Model/Entities/TransactionStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testGetRawStatusArrayNotUtf8()
public function testGetRawStatusArrayException()
{
$aStatus = ['test1' => html_entity_decode(" ")];
$this->classToTest->setData('raw_status', utf8_encode(serialize($aStatus)));
$this->classToTest->setData('raw_status', mb_convert_encoding(serialize($aStatus), 'UTF-8'));
$this->toolkitHelper->method('isUTF8')->willReturn(true);

$result = $this->classToTest->getRawStatusArray();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"email": "[email protected]"
},
"require": {
"php": "~7.0.0|~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.0.0|~8.1.0",
"php": "~7.0.0|~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.0.0|~8.1.0|~8.2.0|~8.3.0",
"magento/framework": "^100.0.0|^101.0.0|^102.0.0|^103.0.0"
},
"repositories": [
Expand Down
Loading