mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 18:18:46 +02:00
Bug fix: when removing a module (like Incident Management) that contained Triggers to such objects, the remaining triggers must be deleted because they reference a non-existing class.
SVN:trunk[1402]
This commit is contained in:
@@ -17,6 +17,7 @@ SetupWebPage::AddModule(
|
||||
),
|
||||
'mandatory' => true,
|
||||
'visible' => false,
|
||||
'installer' => 'TicketsInstaller',
|
||||
|
||||
// Components
|
||||
//
|
||||
@@ -41,4 +42,31 @@ SetupWebPage::AddModule(
|
||||
)
|
||||
);
|
||||
|
||||
// Module installation handler
|
||||
//
|
||||
class TicketsInstaller extends ModuleInstallerAPI
|
||||
{
|
||||
public static function AfterDatabaseCreation(Config $oConfiguration, $sPreviousVersion, $sCurrentVersion)
|
||||
{
|
||||
// Delete all Triggers corresponding to a no more valid class
|
||||
$oSearch = new DBObjectSearch('TriggerOnObject');
|
||||
$oSet = new DBObjectSet($oSearch);
|
||||
$oChange = null;
|
||||
while($oTrigger = $oSet->Fetch())
|
||||
{
|
||||
if (!MetaModel::IsValidClass($oTrigger->Get('target_class')))
|
||||
{
|
||||
if ($oChange == null)
|
||||
{
|
||||
// Create the change for its first use
|
||||
$oChange = new CMDBChange;
|
||||
$oChange->Set("date", time());
|
||||
$oChange->Set("userinfo", "Uninstallation");
|
||||
$oChange->DBInsert();
|
||||
}
|
||||
$oTrigger->DBDeleteTracked($oChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user