On the Magento 2.4.8
Open file: vendor/magento/framework/Mview/TriggerCleaner.php
public function removeTriggers(): bool
{
$this->getDbTriggers();
// Get list of views that are enabled
$viewCollection = $this->viewCollectionFactory->create();
$viewList = $viewCollection->getViewsByStateMode(StateInterface::MODE_ENABLED);
// Check triggers declaration for the enabled views and update them if any changes
foreach ($viewList as $view) {
$subscriptions = $view->getSubscriptions();
foreach ($subscriptions as $subscriptionConfig) {
/* @var $subscription Subscription */
$subscription = $view->initSubscriptionInstance($subscriptionConfig);
$viewTriggers = $subscription->create(false)->getTriggers();
$this->processViewTriggers($viewTriggers, $subscription);
}
}
// Remove any remaining triggers from db that are not linked to a view
$remainingTriggers = array_diff_key($this->DbTriggers, $this->processedTriggers);
foreach ($remainingTriggers as $trigger) {
$view = $this->createViewByTableName($trigger['EVENT_OBJECT_TABLE']);
// $view->unsubscribe();
// $view->getState()->delete();
// Add this code:
if ($view->getActionClass()) {
$view->unsubscribe();
$view->getState()->delete();
}
}
return true;
}
