-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #792 from magento-troll/MAGETWO-58456
MAGETWO-58456: Remove uses of unserialize in \Magento\Rule\Model\AbstractModel and its child classes and their usages
- Loading branch information
Showing
23 changed files
with
893 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\CatalogRule\Setup; | ||
|
||
use Magento\Framework\DB\FieldDataConverterFactory; | ||
use Magento\Framework\DB\DataConverter\SerializedToJson; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use Magento\Framework\Setup\UpgradeDataInterface; | ||
use Magento\Framework\EntityManager\MetadataPool; | ||
use Magento\CatalogRule\Api\Data\RuleInterface; | ||
|
||
class UpgradeData implements UpgradeDataInterface | ||
{ | ||
/** | ||
* @var FieldDataConverterFactory | ||
*/ | ||
private $fieldDataConverterFactory; | ||
|
||
/** | ||
* @var MetadataPool | ||
*/ | ||
private $metadataPool; | ||
|
||
/** | ||
* UpgradeData constructor. | ||
* | ||
* @param FieldDataConverterFactory $fieldDataConverterFactory | ||
* @param MetadataPool $metadataPool | ||
*/ | ||
public function __construct( | ||
FieldDataConverterFactory $fieldDataConverterFactory, | ||
MetadataPool $metadataPool | ||
) { | ||
$this->fieldDataConverterFactory = $fieldDataConverterFactory; | ||
$this->metadataPool = $metadataPool; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) | ||
{ | ||
$setup->startSetup(); | ||
|
||
if (version_compare($context->getVersion(), '2.0.3', '<')) { | ||
$this->convertSerializedDataToJson($setup); | ||
} | ||
|
||
$setup->endSetup(); | ||
} | ||
|
||
/** | ||
* Convert metadata from serialized to JSON format: | ||
* | ||
* @param ModuleDataSetupInterface $setup | ||
* | ||
* @return void | ||
*/ | ||
public function convertSerializedDataToJson($setup) | ||
{ | ||
$fieldDataConverter = $this->fieldDataConverterFactory->create(SerializedToJson::class); | ||
$metadata = $this->metadataPool->getMetadata(RuleInterface::class); | ||
|
||
$fieldDataConverter->convert( | ||
$setup->getConnection(), | ||
$setup->getTable('catalogrule'), | ||
$metadata->getLinkField(), | ||
'conditions_serialized' | ||
); | ||
$fieldDataConverter->convert( | ||
$setup->getConnection(), | ||
$setup->getTable('catalogrule'), | ||
$metadata->getLinkField(), | ||
'actions_serialized' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.