Skip to content

Commit

Permalink
MAGETWO-80188: [2.2.x] - Prevent change log entry when nothing has ch…
Browse files Browse the repository at this point in the history
…anged #4893
  • Loading branch information
dhorytskyi committed Oct 11, 2017
1 parent 8c6fe80 commit 64e6854
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions lib/internal/Magento/Framework/Mview/View/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Ddl\Trigger;
use Magento\Framework\DB\Ddl\TriggerFactory;
use Magento\Framework\Mview\ViewInterface;

class Subscription implements SubscriptionInterface
{
Expand All @@ -21,12 +23,12 @@ class Subscription implements SubscriptionInterface
protected $connection;

/**
* @var \Magento\Framework\DB\Ddl\TriggerFactory
* @var TriggerFactory
*/
protected $triggerFactory;

/**
* @var \Magento\Framework\Mview\View\CollectionInterface
* @var CollectionInterface
*/
protected $viewCollection;

Expand Down Expand Up @@ -67,21 +69,21 @@ class Subscription implements SubscriptionInterface

/**
* @param ResourceConnection $resource
* @param \Magento\Framework\DB\Ddl\TriggerFactory $triggerFactory
* @param \Magento\Framework\Mview\View\CollectionInterface $viewCollection
* @param \Magento\Framework\Mview\ViewInterface $view
* @param TriggerFactory $triggerFactory
* @param CollectionInterface $viewCollection
* @param ViewInterface $view
* @param string $tableName
* @param string $columnName
* @param array $ignoredUpdateColumns
*/
public function __construct(
ResourceConnection $resource,
\Magento\Framework\DB\Ddl\TriggerFactory $triggerFactory,
\Magento\Framework\Mview\View\CollectionInterface $viewCollection,
\Magento\Framework\Mview\ViewInterface $view,
TriggerFactory $triggerFactory,
CollectionInterface $viewCollection,
ViewInterface $view,
$tableName,
$columnName,
$ignoredUpdateColumns = []
array $ignoredUpdateColumns = []
) {
$this->connection = $resource->getConnection();
$this->triggerFactory = $triggerFactory;
Expand All @@ -94,9 +96,9 @@ public function __construct(
}

/**
* Create subsciption
* Create subscription
*
* @return \Magento\Framework\Mview\View\SubscriptionInterface
* @return SubscriptionInterface
*/
public function create()
{
Expand All @@ -113,7 +115,7 @@ public function create()

// Add statements for linked views
foreach ($this->getLinkedViews() as $view) {
/** @var \Magento\Framework\Mview\ViewInterface $view */
/** @var ViewInterface $view */
$trigger->addStatement($this->buildStatement($event, $view->getChangelog()));
}

Expand All @@ -127,7 +129,7 @@ public function create()
/**
* Remove subscription
*
* @return \Magento\Framework\Mview\View\SubscriptionInterface
* @return SubscriptionInterface
*/
public function remove()
{
Expand All @@ -142,7 +144,7 @@ public function remove()

// Add statements for linked views
foreach ($this->getLinkedViews() as $view) {
/** @var \Magento\Framework\Mview\ViewInterface $view */
/** @var ViewInterface $view */
$trigger->addStatement($this->buildStatement($event, $view->getChangelog()));
}

Expand All @@ -165,10 +167,10 @@ public function remove()
protected function getLinkedViews()
{
if (!$this->linkedViews) {
$viewList = $this->viewCollection->getViewsByStateMode(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED);
$viewList = $this->viewCollection->getViewsByStateMode(StateInterface::MODE_ENABLED);

foreach ($viewList as $view) {
/** @var \Magento\Framework\Mview\ViewInterface $view */
/** @var ViewInterface $view */
// Skip the current view
if ($view->getId() == $this->getView()->getId()) {
continue;
Expand All @@ -189,10 +191,10 @@ protected function getLinkedViews()
* Build trigger statement for INSERT, UPDATE, DELETE events
*
* @param string $event
* @param \Magento\Framework\Mview\View\ChangelogInterface $changelog
* @param ChangelogInterface $changelog
* @return string
*/
protected function buildStatement($event, $changelog)
protected function buildStatement(string $event, ChangelogInterface $changelog)
{
switch ($event) {
case Trigger::EVENT_INSERT:
Expand Down Expand Up @@ -259,7 +261,7 @@ private function getAfterEventTriggerName($event)
/**
* Retrieve View related to subscription
*
* @return \Magento\Framework\Mview\ViewInterface
* @return ViewInterface
* @codeCoverageIgnore
*/
public function getView()
Expand Down

0 comments on commit 64e6854

Please sign in to comment.