Skip to content

Commit db624ff

Browse files
committed
Update the abstract controller to use the Serializer rather than direct json_ methods
1 parent 474effb commit db624ff

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,21 @@ protected function getCookieMessages($messageType = null)
268268
{
269269
/** @var $cookieManager CookieManagerInterface */
270270
$cookieManager = $this->_objectManager->get(CookieManagerInterface::class);
271-
$messages = json_decode(
272-
$cookieManager->getCookie(MessagePlugin::MESSAGES_COOKIES_NAME, json_encode([]))
273-
);
274-
if (!is_array($messages)) {
271+
272+
/** @var $jsonSerializer \Magento\Framework\Serialize\Serializer\Json */
273+
$jsonSerializer = $this->_objectManager->get(\Magento\Framework\Serialize\Serializer\Json::class);
274+
try {
275+
$messages = $jsonSerializer->unserialize(
276+
$cookieManager->getCookie(
277+
MessagePlugin::MESSAGES_COOKIES_NAME,
278+
$jsonSerializer->serialize([])
279+
)
280+
);
281+
282+
if (!is_array($messages)) {
283+
$messages = [];
284+
}
285+
} catch (\InvalidArgumentException $e) {
275286
$messages = [];
276287
}
277288

0 commit comments

Comments
 (0)