From 2b6779af8f01fea2f93bc40819a0da2f5c405ddb Mon Sep 17 00:00:00 2001
From: "Fedor A. Fetisov" <faf@ossg.ru>
Date: Tue, 6 Feb 2018 02:11:36 +0300
Subject: [PATCH] Fix handling of information on updates for absent plugins

---
 .../classes/Mibew/Maintenance/UpdateChecker.php    | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/mibew/libs/classes/Mibew/Maintenance/UpdateChecker.php b/src/mibew/libs/classes/Mibew/Maintenance/UpdateChecker.php
index 27a82610..bf3cf0c7 100644
--- a/src/mibew/libs/classes/Mibew/Maintenance/UpdateChecker.php
+++ b/src/mibew/libs/classes/Mibew/Maintenance/UpdateChecker.php
@@ -298,6 +298,20 @@ class UpdateChecker
             }
         }
 
+        // Remove information about updates for absent plugins.
+        $updates = AvailableUpdate::all();
+        $plugins = PluginUtils::discoverPlugins();
+        foreach ($updates as $update) {
+            $name = $update->target;
+            // Skip information about the core.
+            if (!strcmp($name, 'core')) {
+                continue;
+            }
+            elseif (!in_array($name, $plugins)) {
+                $this->deleteUpdate($name);
+            }
+        }
+
         return true;
     }