Merge remote-tracking branch 'origin/support/3.2' into develop

This commit is contained in:
Molkobain
2024-07-24 10:58:05 +02:00
368 changed files with 2676 additions and 12099 deletions

View File

@@ -16,6 +16,8 @@
// You should have received a copy of the GNU Affero General Public License
// along with iTop. If not, see <http://www.gnu.org/licenses/>
use Combodo\iTop\Service\InterfaceDiscovery\InterfaceDiscovery;
require_once(APPROOT.'core/tar-itop.class.inc.php');
interface BackupArchive
@@ -272,7 +274,7 @@ class DBBackup
$aExtraFiles = MetaModel::GetModuleSetting('itop-backup', 'extra_files', []);
}
foreach (utils::GetClassesForInterface('iBackupExtraFilesExtension', '', ['[\\\\/]lib[\\\\/]', '[\\\\/]node_modules[\\\\/]', '[\\\\/]test[\\\\/]', '[\\\\/]tests[\\\\/]']) as $sExtensionClass)
foreach (InterfaceDiscovery::GetInstance()->FindItopClasses(iBackupExtraFilesExtension::class) as $sExtensionClass)
{
/** @var iBackupExtraFilesExtension $oExtensionInstance */
$oExtensionInstance = new $sExtensionClass();

View File

@@ -291,4 +291,47 @@ abstract class ModuleInstallerAPI
CMDBSource::CacheReset($sDstTable);
}
/**
* Rename a table providing:
* - The original name exists
* - The destination name does not exist
*
* @param string $sOrigTable
* @param string $sDstTable
*
* @return void
* @throws CoreException
* @throws CoreUnexpectedValue
* @throws MySQLException
*/
public static function RenameTableInDB(string $sOrigTable, string $sDstTable)
{
if ($sOrigTable == $sDstTable)
{
throw new CoreUnexpectedValue("Origin table and destination table are the same");
}
if (!MetaModel::DBExists(false))
{
// Install from scratch, no migration
return;
}
if (!CMDBSource::IsTable($sOrigTable))
{
SetupLog::Warning(sprintf('Rename table in DB - Origin table %s doesn\'t exist', $sOrigTable));
return;
}
if (CMDBSource::IsTable($sDstTable))
{
SetupLog::Warning(sprintf('Rename table in DB - Destination table %s already exists', $sDstTable));
return;
}
$sQueryRename = sprintf(/** @lang MariaDB */ "RENAME TABLE `%s` TO `%s`;", $sOrigTable, $sDstTable);
CMDBSource::Query($sQueryRename);
CMDBSource::CacheReset($sOrigTable);
}
}