mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
- stopper bug in case of reinstallation/upgrade: the file keyscache.tmp could be left in case of issue in the previous execution of the setup ; the file is now deleted prior to running a new session - if a fatal error (e.g. call to undefined function) occured during the load of a file (ajax), then we had no clue that this happened ; a log has been added after the load so that we can get faster to the issue - reordered data files (not the same order in MS-Explorer) to maximize ext key resolution on the first pass - resolving external keys afterwards should work again (though the file order is avoiding this currently), as the objects are declared "dirty" and no automatic reload will be attempted during further manipulations - added a log when an external key cannot be resolved during the final round SVN:trunk[191]
68 lines
2.1 KiB
PHP
68 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* This page is called to load "asynchronously" some xml file into the database
|
|
* parameters
|
|
* 'file' string Name of the file to load
|
|
* 'session_status' string 'start', 'continue' or 'end'
|
|
* 'percent' integer 0..100 the percentage of completion once the file has been loaded
|
|
*/
|
|
require_once('../application/utils.inc.php');
|
|
require_once('../core/config.class.inc.php');
|
|
require_once('../core/cmdbsource.class.inc.php');
|
|
require_once('./setuppage.class.inc.php');
|
|
require_once('./xmldataloader.class.inc.php');
|
|
|
|
define('TMP_CONFIG_FILE', '../tmp-config-itop.php');
|
|
//define('FINAL_CONFIG_FILE', '../config-itop.php');
|
|
|
|
// Never cache this page
|
|
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
|
|
header("Expires: Fri, 17 Jul 1970 05:00:00 GMT"); // Date in the past
|
|
|
|
|
|
/**
|
|
* Main program
|
|
*/
|
|
$sFileName = Utils::ReadParam('file', '');
|
|
$sSessionStatus = Utils::ReadParam('session_status', '');
|
|
$iPercent = (integer)Utils::ReadParam('percent', 0);
|
|
setup_web_page::log("Info - Loading file: $sFileName");
|
|
|
|
try
|
|
{
|
|
if (empty($sFileName) || !file_exists($sFileName))
|
|
{
|
|
throw(new Exception("File $sFileName does not exist"));
|
|
}
|
|
|
|
$oDataLoader = new XMLDataLoader(TMP_CONFIG_FILE); // When called by the wizard, the final config is not yet there
|
|
if ($sSessionStatus == 'start')
|
|
{
|
|
$oChange = MetaModel::NewObject("CMDBChange");
|
|
$oChange->Set("date", time());
|
|
$oChange->Set("userinfo", "Initialization");
|
|
$iChangeId = $oChange->DBInsert();
|
|
setup_web_page::log("Info - starting data load session");
|
|
$oDataLoader->StartSession($oChange);
|
|
}
|
|
|
|
$oDataLoader->LoadFile($sFileName);
|
|
$sResult = sprintf("Info - loading of %s done. (Overall %d %% completed).", basename($sFileName), $iPercent);
|
|
echo $sResult;
|
|
setup_web_page::log($sResult);
|
|
|
|
if ($sSessionStatus == 'end')
|
|
{
|
|
$oDataLoader->EndSession();
|
|
setup_web_page::log("Info - ending data load session");
|
|
}
|
|
}
|
|
catch(Exception $e)
|
|
{
|
|
echo "<p>An error happened while loading the data</p>\n";
|
|
echo '<p>'.$e."</p>\n";
|
|
setup_web_page::log("Error - An error happened while loading the data. ".$e);
|
|
}
|
|
|
|
?>
|