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

Fixed null deprecation in UnserializeArray.php #4394

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5644286
Fixed issue #4352 null deprecation in UnserializeArray.php
kiatng Nov 28, 2024
e3cd1d6
Added @ to suppress warnings and notices
kiatng Nov 28, 2024
be23e65
Suppress PHPMD ErrorControlOperator
kiatng Nov 28, 2024
f73292b
Fix suppress PHPMD ErrorControlOperator
kiatng Nov 28, 2024
8e41850
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Nov 28, 2024
18fd93c
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Nov 29, 2024
852bdc6
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Dec 9, 2024
c70f0da
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Dec 25, 2024
349f27e
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Dec 31, 2024
dbb3095
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Jan 1, 2025
3039d23
Merge branch 'main' into 4352_nd_unserialize_array
kiatng Jan 5, 2025
f9d40e7
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Jan 6, 2025
adef3d2
Update app/code/core/Mage/Core/Helper/UnserializeArray.php
sreichel Jan 6, 2025
debdfad
Update app/code/core/Mage/Core/Helper/UnserializeArray.php
kiatng Jan 9, 2025
bd9d6c3
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Jan 11, 2025
9108f22
updated test result
sreichel Jan 11, 2025
c5edea4
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Jan 11, 2025
af8bf19
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Jan 15, 2025
d219722
sonar-1
sreichel Jan 15, 2025
7cb2366
Merge remote-tracking branch 'kiatng/4352_nd_unserialize_array' into …
sreichel Jan 15, 2025
20d73a9
Merge branch 'main' into 4352_nd_unserialize_array
sreichel Jan 15, 2025
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
4 changes: 3 additions & 1 deletion app/code/core/Mage/Core/Helper/UnserializeArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ class Mage_Core_Helper_UnserializeArray
* @param string $str
* @return array
* @throws Exception
* @SuppressWarnings("PHPMD.ErrorControlOperator")
*/
public function unserialize($str)
{
try {
$result = unserialize($str, ['allowed_classes' => false]);
$str = is_null($str) ? '' : $str;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sreichel In my test, line 34 is redundant. Why not remove it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested again, but w/o it you are passing null to unserialize.

Please revome it from PR and lets see what happens.

$result = @unserialize($str, ['allowed_classes' => false]);
kiatng marked this conversation as resolved.
Show resolved Hide resolved
if ($result === false && $str !== serialize(false)) {
throw new Exception('Error unserializing data.');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Mage/Core/Helper/UnserializeArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function provideUnserialize(): Generator
'',
];
yield 'random string' => [
'unserialize(): Error at offset 0 of 3 bytes',
'Error unserializing data.',
'abc',
];
yield 'valid' => [
Expand Down
Loading