Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [UNRELEASED]

- Uninstall process

## [3.0.1 End-of-Life Updater] - 2025-11-13

- Fix Twig error on migration_status page
Expand Down
44 changes: 43 additions & 1 deletion inc/type.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ public static function deleteFile($filename)
}
}

public static function deleteFolder(string $folder)
{
if (!is_dir($folder)) {
return;
}

$it = new RecursiveDirectoryIterator($folder, FilesystemIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);

foreach ($files as $file) {
if ($file->isDir()) {
rmdir($file->getRealPath());
} else {
unlink($file->getRealPath());
}
}

rmdir($folder);
}


public static function getCompleteClassFilename($name)
{
Expand Down Expand Up @@ -289,6 +309,16 @@ public static function deleteTable($itemtype)
$preferences = new DisplayPreference();
$preferences->deleteByCriteria(["itemtype" => $itemtype]);
$DB->dropTable(getTableForItemType($itemtype), true);


if (strlen(getTableForItemType($itemtype) . "Model") <= 64) {
$DB->dropTable(getTableForItemType($itemtype . "Model"), true);
}

if (strlen(getTableForItemType($itemtype) . "Type") <= 64) {
$DB->dropTable(getTableForItemType($itemtype . "Type"), true);
}

}


Expand All @@ -301,7 +331,9 @@ public static function deleteItemsTable($itemtype)
{
/** @var DBmysql $DB */
global $DB;
$DB->dropTable(getTableForItemType($itemtype) . "_items", true);
if (strlen(getTableForItemType($itemtype) . "_items") <= 64) {
$DB->dropTable(getTableForItemType($itemtype) . "_items", true);
}
}

/**
Expand Down Expand Up @@ -660,6 +692,13 @@ public static function uninstall()
self::deleteItemtypeReferencesInGLPI(self::class);

foreach ($DB->request(['FROM' => 'glpi_plugin_genericobject_types']) as $type) {

// GLPI 11 migration may change plugin itemtype from glpi_plugin_genericobject_types table during CustomAsset migration
// rely on original name to get correct itemtype
if (str_starts_with($type['itemtype'], 'Glpi\\CustomAsset\\')) {
$type['itemtype'] = self::getClassByName($type['name']);
}

//Delete references to PluginGenericobjectType in the following tables
self::deleteItemtypeReferencesInGLPI($type['itemtype']);
//Dropd files and classes
Expand All @@ -668,6 +707,9 @@ public static function uninstall()

//Delete table
$migration->dropTable('glpi_plugin_genericobject_types');

self::deleteFolder(GENERICOBJECT_DOC_DIR);

}


Expand Down