diff --git a/include/Addon.class.php b/include/Addon.class.php index e275b36f..5ac3cebc 100644 --- a/include/Addon.class.php +++ b/include/Addon.class.php @@ -163,12 +163,15 @@ private function loadRevisions() } catch (DBException $e) { - throw new AddonException(exception_message_db(_('load revisions'))); + throw new AddonException(exception_message_db(_('load revisions')), ErrorType::ADDON_DB_EXCEPTION); } if (!$revisions) { - throw new AddonException(_h('No revisions of this add-on exist. This should never happen.')); + throw new AddonException( + _h('No revisions of this add-on exist. This should never happen.'), + ErrorType::ADDON_REVISION_MISSING + ); } foreach ($revisions as $rev) @@ -1539,7 +1542,7 @@ public static function filterMenuTemplate($addons, $current_id = null) { $class = ''; } - elseif ($has_permission || $addon->isUserOwner()) + else if ($has_permission || $addon->isUserOwner()) { // not approved, see of we are logged in and we have permission $class = ' disabled'; @@ -1653,7 +1656,22 @@ public static function search($search_query, $type, array $search_flags) $return_addons = []; foreach ($addons as $addon) { - $return_addons[] = new static($addon); + try + { + $return_addons[] = new static($addon); + } + catch (AddonException $e) + { + if ($e->getCode() == ErrorType::ADDON_REVISION_MISSING) + { + // ignore corrupt addon + Debug::addMessage("No revision for addon = " . $addon['name']); + } + else + { + throw $e; + } + } } return $return_addons; diff --git a/include/Exceptions.class.php b/include/Exceptions.class.php index 4295ddad..76d4b8bd 100644 --- a/include/Exceptions.class.php +++ b/include/Exceptions.class.php @@ -48,6 +48,9 @@ class ErrorType extends \MyCLabs\Enum\Enum const USER_SENDING_CREATE_EMAIL = 78; // while sending create account email const USER_INACTIVE_ACCOUNT = 79; // account is not active + const ADDON_DB_EXCEPTION = 100; // a generic database exception occurred while querying some addon data + const ADDON_REVISION_MISSING = 101; // the addon Revision is missing, corrupt + const VALIDATE_NOT_IN_CHAR_RANGE = 500; // string is not in min/max char string range const VALIDATE_PASSWORDS_MATCH = 501; // passwords do not match