From bff0cce776d45b5302137f8b51592f2adb1dbcf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89bano=20Penha=20Andrello=20Lopes?= Date: Wed, 17 Jul 2019 21:01:08 -0300 Subject: [PATCH] 3.4.0: Magento 2 validation fixes --- Helper/FulfillmentHelper.php | 29 +++++++++++++++++++---- Model/Casedata.php | 15 +++++++++--- Model/Message/BuiltinConflict.php | 2 +- Model/Payment/DataMapper.php | 4 ++-- Ui/Component/Listing/Columns/CaseLink.php | 11 ++++++++- 5 files changed, 49 insertions(+), 12 deletions(-) diff --git a/Helper/FulfillmentHelper.php b/Helper/FulfillmentHelper.php index d0604361..593780fb 100644 --- a/Helper/FulfillmentHelper.php +++ b/Helper/FulfillmentHelper.php @@ -10,6 +10,7 @@ use Signifyd\Connect\Logger\Logger; use Signifyd\Core\SignifydModel; use Magento\Sales\Model\ResourceModel\Order as OrderResourceModel; +use Magento\Framework\Serialize\SerializerInterface; class FulfillmentHelper { @@ -48,6 +49,22 @@ class FulfillmentHelper */ protected $configHelper; + /** + * @var SerializerInterface + */ + protected $serializer; + + /** + * FulfillmentHelper constructor. + * @param CasedataFactory $casedataFactory + * @param FulfillmentFactory $fulfillmentFactory + * @param CasedataResourceModel $casedataResourceModel + * @param FulfillmentResourceModel $fulfillmentResourceModel + * @param OrderResourceModel $orderResourceModel + * @param Logger $logger + * @param ConfigHelper $configHelper + * @param SerializerInterface $serializer + */ public function __construct( CasedataFactory $casedataFactory, FulfillmentFactory $fulfillmentFactory, @@ -55,7 +72,8 @@ public function __construct( FulfillmentResourceModel $fulfillmentResourceModel, OrderResourceModel $orderResourceModel, Logger $logger, - ConfigHelper $configHelper + ConfigHelper $configHelper, + SerializerInterface $serializer ) { $this->casedataFactory = $casedataFactory; $this->fulfillmentFactory = $fulfillmentFactory; @@ -66,6 +84,7 @@ public function __construct( $this->logger = $logger; $this->configHelper = $configHelper; + $this->serializer = $serializer; } public function postFulfillmentToSignifyd(\Magento\Sales\Model\Order\Shipment $shipment) @@ -156,11 +175,11 @@ public function prepareFulfillmentToDatabase(\Signifyd\Models\Fulfillment $fulfi $fulfillment->setData('created_at', $fulfillmentData->createdAt); $fulfillment->setData('delivery_email', $fulfillmentData->deliveryEmail); $fulfillment->setData('fulfillment_status', $fulfillmentData->fulfillmentStatus); - $fulfillment->setData('tracking_numbers', serialize($fulfillmentData->trackingNumbers)); - $fulfillment->setData('tracking_urls', serialize($fulfillmentData->trackingUrls)); - $fulfillment->setData('products', serialize($fulfillmentData->products)); + $fulfillment->setData('tracking_numbers', $this->serializer->serialize($fulfillmentData->trackingNumbers)); + $fulfillment->setData('tracking_urls', $this->serializer->serialize($fulfillmentData->trackingUrls)); + $fulfillment->setData('products', $this->serializer->serialize($fulfillmentData->products)); $fulfillment->setData('shipment_status', $fulfillmentData->shipmentStatus); - $fulfillment->setData('delivery_address', serialize($fulfillmentData->deliveryAddress)); + $fulfillment->setData('delivery_address', $this->serializer->serialize($fulfillmentData->deliveryAddress)); $fulfillment->setData('recipient_name', $fulfillmentData->recipientName); $fulfillment->setData('confirmation_name', $fulfillmentData->confirmationName); $fulfillment->setData('confirmation_phone', $fulfillmentData->confirmationPhone); diff --git a/Model/Casedata.php b/Model/Casedata.php index 26d0d002..7927a0da 100644 --- a/Model/Casedata.php +++ b/Model/Casedata.php @@ -14,6 +14,7 @@ use Magento\Framework\ObjectManagerInterface; use Magento\Sales\Model\Order; use Signifyd\Connect\Logger\Logger; +use Magento\Framework\Serialize\SerializerInterface; /** * ORM model declaration for case data @@ -67,6 +68,11 @@ class Casedata extends AbstractModel */ protected $logger; + /** + * @var SerializerInterface + */ + protected $serializer; + /** * Casedata constructor. * @param Context $context @@ -74,6 +80,7 @@ class Casedata extends AbstractModel * @param \Signifyd\Connect\Helper\ConfigHelper $configHelper * @param InvoiceService $invoiceService * @param Logger + * @param SerializerInterface $serializer */ public function __construct( Context $context, @@ -83,7 +90,8 @@ public function __construct( InvoiceSender $invoiceSender, ObjectManagerInterface $objectManager, \Magento\Sales\Model\OrderFactory $orderFactory, - Logger $logger + Logger $logger, + SerializerInterface $serializer ) { $this->configHelper = $configHelper; @@ -92,6 +100,7 @@ public function __construct( $this->objectManager = $objectManager; $this->orderFactory = $orderFactory; $this->logger = $logger; + $this->serializer = $serializer; parent::__construct($context, $registry); } @@ -516,7 +525,7 @@ public function getEntries($index = null) $entries = $this->getData('entries_text'); if (!empty($entries)) { - @$entries = unserialize($entries); + $entries = $this->serializer->unserialize($entries); } if (!is_array($entries)) { @@ -539,7 +548,7 @@ public function setEntries($index, $value = null) $entries[$index] = $value; } - @$entries = serialize($entries); + $entries = $this->serializer->serialize($entries); $this->setData('entries_text', $entries); return $this; diff --git a/Model/Message/BuiltinConflict.php b/Model/Message/BuiltinConflict.php index 2343f2ba..1b9bd064 100644 --- a/Model/Message/BuiltinConflict.php +++ b/Model/Message/BuiltinConflict.php @@ -78,7 +78,7 @@ public function isDisplayed() */ public function getIdentity() { - return md5('SIGNIFYD_CONNECT_BUILTIN_CONFLICT'); + return sha1('SIGNIFYD_CONNECT_BUILTIN_CONFLICT'); } /** * Retrieve message text diff --git a/Model/Payment/DataMapper.php b/Model/Payment/DataMapper.php index 0538ee67..f18717ca 100644 --- a/Model/Payment/DataMapper.php +++ b/Model/Payment/DataMapper.php @@ -87,7 +87,7 @@ public function checkMethod(\Magento\Sales\Api\Data\OrderPaymentInterface $order * @param \Magento\Sales\Model\Order $order * @return string */ - final public function getCode(\Magento\Sales\Model\Order $order) + public function getCode(\Magento\Sales\Model\Order $order) { if ($this->getDataCalled) { return null; @@ -103,7 +103,7 @@ final public function getCode(\Magento\Sales\Model\Order $order) * @param \Magento\Sales\Model\Order $order * @return string */ - final public function getData(\Magento\Sales\Model\Order $order) + public function getData(\Magento\Sales\Model\Order $order) { $this->checkMethod($order->getPayment()); return $this->getPaymentData($order); diff --git a/Ui/Component/Listing/Columns/CaseLink.php b/Ui/Component/Listing/Columns/CaseLink.php index ca7ff376..e1221b3c 100644 --- a/Ui/Component/Listing/Columns/CaseLink.php +++ b/Ui/Component/Listing/Columns/CaseLink.php @@ -9,6 +9,7 @@ use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Ui\Component\Listing\Columns\Column; +use Magento\Framework\Serialize\SerializerInterface; /** * Class CaseLink @@ -20,11 +21,17 @@ class CaseLink extends Column */ protected $objectManager; + /** + * @var SerializerInterface + */ + protected $serializer; + /** * CaseLink constructor. * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory * @param ObjectManagerInterface $objectManager + * @param SerializerInterface $serializer * @param array $components * @param array $data */ @@ -32,10 +39,12 @@ public function __construct( ContextInterface $context, UiComponentFactory $uiComponentFactory, ObjectManagerInterface $objectManager, + SerializerInterface $serializer, array $components = [], array $data = [] ) { $this->objectManager = $objectManager; + $this->serializer = $serializer; parent::__construct($context, $uiComponentFactory, $components, $data); } @@ -59,7 +68,7 @@ public function prepareDataSource(array $dataSource) $entries = $case->getEntriesText(); if (!empty($entries)) { - @$entries = unserialize($entries); + $entries = $this->serializer->unserialize($entries); if (is_array($entries) && isset($entries['testInvestigation']) && $entries['testInvestigation'] == true) { $item[$name] = "TEST: {$item[$name]}"; }