File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
lib/internal/Magento/Framework/Mview Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -54,23 +54,24 @@ public function __construct(
54
54
*/
55
55
public function removeTriggers (): bool
56
56
{
57
+ // Get list of views that are enabled
57
58
$ viewCollection = $ this ->viewCollectionFactory ->create ();
58
59
$ viewList = $ viewCollection ->getViewsByStateMode (StateInterface::MODE_ENABLED );
59
60
60
- // Unsubscribe mviews
61
+ // Unsubscribe existing view to remove triggers from db
61
62
foreach ($ viewList as $ view ) {
62
63
$ view ->unsubscribe ();
63
64
}
64
65
65
- // Unsubscribe old views that still have triggers in db
66
+ // Remove any remaining triggers from db that are not linked to a view
66
67
$ triggerTableNames = $ this ->getTableNamesWithTriggers ();
67
68
foreach ($ triggerTableNames as $ tableName ) {
68
69
$ view = $ this ->createViewByTableName ($ tableName );
69
70
$ view ->unsubscribe ();
70
71
$ view ->getState ()->delete ();
71
72
}
72
73
73
- // Re-subscribe mviews
74
+ // Restore the previous state of the views to add triggers back to db
74
75
foreach ($ viewList as $ view ) {
75
76
$ view ->subscribe ();
76
77
}
@@ -100,6 +101,9 @@ private function getTableNamesWithTriggers(): array
100
101
/**
101
102
* Create view by db table name
102
103
*
104
+ * Create a view that has the table name so that unsubscribe can be used to
105
+ * remove triggers with the correct naming structure from the db
106
+ *
103
107
* @param string $tableName
104
108
* @return ViewInterface
105
109
*/
You can’t perform that action at this time.
0 commit comments