mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-28 22:54:12 +01:00
Compare commits
20 Commits
designer-p
...
support/3.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f7ce0837e | ||
|
|
7df09541ac | ||
|
|
7fb0ae48f9 | ||
|
|
e89a8edae0 | ||
|
|
f6366057c9 | ||
|
|
b5c79e1d75 | ||
|
|
5045ec4afa | ||
|
|
88e0f17164 | ||
|
|
de54676b9f | ||
|
|
e5129c9618 | ||
|
|
d0f816109b | ||
|
|
05642cdf84 | ||
|
|
031305cfbf | ||
|
|
471422b274 | ||
|
|
5573a222c8 | ||
|
|
83eb2b81e3 | ||
|
|
86d2a3424d | ||
|
|
cd1c6f5ec5 | ||
|
|
2ee30692ff | ||
|
|
9aa13f57d8 |
@@ -199,7 +199,7 @@ class DatamodelsXmlFiles extends AbstractGlobFileVersionUpdater
|
||||
libxml_clear_errors();
|
||||
$oFileXml->formatOutput = true;
|
||||
$oFileXml->preserveWhiteSpace = false;
|
||||
$oFileXml->loadXML($sFileContent);
|
||||
$oFileXml->loadXML($sFileContent, LIBXML_BIGLINES);
|
||||
|
||||
$oFileItopFormat = new iTopDesignFormat($oFileXml);
|
||||
|
||||
|
||||
@@ -347,6 +347,7 @@ EOF
|
||||
{
|
||||
$oPage->add('<div class="ui-dialog-header">'.$sIntroduction.'</div>');
|
||||
}
|
||||
$oPage->add('<div class="designer-dialog-error"></div>');
|
||||
$this->Render($oPage);
|
||||
$oPage->add('</div>');
|
||||
|
||||
|
||||
@@ -611,12 +611,12 @@ class CMDBSource
|
||||
catch (mysqli_sql_exception $e)
|
||||
{
|
||||
self::LogDeadLock($e, true);
|
||||
throw new MySQLException('Failed to issue SQL query', array('query' => $sSql, $e));
|
||||
throw new MySQLException('Failed to issue SQL query', ['query' => $sSql, $e, 'stack' => $e->getTraceAsString()]);
|
||||
} finally {
|
||||
$oKPI->ComputeStats('Query exec (mySQL)', $sSql);
|
||||
}
|
||||
if ($oResult === false) {
|
||||
$aContext = array('query' => $sSql);
|
||||
$aContext = ["\nstack" => (new Exception(''))->getTraceAsString(), "\nquery" => $sSql];
|
||||
|
||||
$iMySqlErrorNo = DbConnectionWrapper::GetDbConnection(true)->errno;
|
||||
$aMySqlHasGoneAwayErrorCodes = MySQLHasGoneAwayException::getErrorCodes();
|
||||
|
||||
@@ -71,6 +71,14 @@ class DesignDocument extends DOMDocument
|
||||
$this->preserveWhiteSpace = true; // otherwise the formatOutput option would have no effect
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function loadXML(string $source, int $options = 0) : bool
|
||||
{
|
||||
return parent::loadXML($source, $options | LIBXML_BIGLINES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overload of the standard API
|
||||
*
|
||||
|
||||
@@ -6801,12 +6801,14 @@ abstract class MetaModel
|
||||
if ($bMustBeFound && empty($aRow))
|
||||
{
|
||||
$sNotFoundErrorMessage = "No result for the single row query";
|
||||
IssueLog::Info($sNotFoundErrorMessage, LogChannels::CMDB_SOURCE, [
|
||||
$e = new CoreException($sNotFoundErrorMessage);
|
||||
IssueLog::Error($sNotFoundErrorMessage, LogChannels::CMDB_SOURCE, [
|
||||
'class' => $sClass,
|
||||
'key' => $iKey,
|
||||
'sql_query' => $sSQL,
|
||||
'stack' => $e->getTraceAsString(),
|
||||
]);
|
||||
throw new CoreException($sNotFoundErrorMessage);
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $aRow;
|
||||
|
||||
@@ -548,6 +548,7 @@ function ValidateWithPattern(sFieldId, bMandatory, sPattern, sFormId, aForbidden
|
||||
if (sMessage)
|
||||
{
|
||||
$('#'+sFieldId).attr('data-tooltip-content', sMessage);
|
||||
$('#'+sFieldId).attr('data-tooltip-theme', 'error');
|
||||
CombodoTooltip.InitTooltipFromMarkup($('#'+sFieldId), true);
|
||||
$('#'+sFieldId)[0]._tippy.show();
|
||||
}
|
||||
|
||||
@@ -69,14 +69,37 @@ class MFException extends Exception
|
||||
* MFException constructor.
|
||||
*
|
||||
* @inheritDoc
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $code: error code
|
||||
* @param DesignElement $oNode: dom node
|
||||
* @param string|null $sXPath: XML xpath: if provided used in exception message. otherwise computed via $oNode
|
||||
* @param string $sExtraInfo: additional information stored in exception
|
||||
* @param DesignElement|null $oParentFallbackNode: fallback dom node (usually parent). in case $oNode XML line is wrong (set to 0), line number computed/displayed in error message comes from $oParentFallbackNode
|
||||
*/
|
||||
public function __construct($message = null, $code = null, $iSourceLineNumber = 0, $sXPath = '', $sExtraInfo = '', $previous = null)
|
||||
public function __construct(string $message, int $code, DesignElement $oNode, ?string $sXPath = null, string $sExtraInfo = '', ?DesignElement $oParentFallbackNode = null)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
$iSourceLineNumber = ModelFactory::GetXMLLineNumber($oNode);
|
||||
if ($iSourceLineNumber==0 && ! is_null($oParentFallbackNode)){
|
||||
$iSourceLineNumber = ModelFactory::GetXMLLineNumber($oParentFallbackNode);
|
||||
}
|
||||
|
||||
if (is_null($sXPath)){
|
||||
$sXPath = DesignDocument::GetItopNodePath($oNode);
|
||||
}
|
||||
|
||||
$this->iSourceLineNumber = $iSourceLineNumber;
|
||||
$this->iSourceLineOffset = 0;
|
||||
$this->sXPath = $sXPath;
|
||||
$this->sExtraInfo = $sExtraInfo;
|
||||
parent::__construct("$sXPath at line $iSourceLineNumber: $message", $code);
|
||||
|
||||
$aContext = [
|
||||
'error' => $code,
|
||||
'stack' => $this->getTraceAsString(),
|
||||
'extra_info' => $sExtraInfo,
|
||||
];
|
||||
\IssueLog::Error($this->getMessage(), null, $aContext);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,6 +219,10 @@ class MFModule
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_dir($sRootDir)) {
|
||||
$sRootDir = APPROOT.$sRootDir;
|
||||
}
|
||||
|
||||
// Scan the module's root directory to find the datamodel(*).xml files
|
||||
if ($hDir = opendir($sRootDir))
|
||||
{
|
||||
@@ -749,10 +776,7 @@ class ModelFactory
|
||||
case 'define_if_not_exists':
|
||||
/** @var \MFElement $oParentNode */
|
||||
$oParentNode = $oSubClassNode->parentNode;
|
||||
$iLine = ModelFactory::GetXMLLineNumber($oParentNode);
|
||||
$sItopNodePath = DesignDocument::GetItopNodePath($oParentNode);
|
||||
throw new MFException("$sItopNodePath at line $iLine: _delta=\"$sParentDeltaSpec\" not supported for classes in hierarchy",
|
||||
MFException::NOT_FOUND, $iLine, $sItopNodePath);
|
||||
throw new MFException("_delta=\"$sParentDeltaSpec\" not supported for classes in hierarchy", MFException::NOT_FOUND, $oParentNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,10 +832,7 @@ class ModelFactory
|
||||
// Move class after new parent class (before its next sibling)
|
||||
$oNodeForTargetParent = $oTargetDocument->GetNodes("/itop_design/classes/class[@id=\"$sParentClassName\"]")->item(0);
|
||||
if (is_null($oNodeForTargetParent)) {
|
||||
$iLine = ModelFactory::GetXMLLineNumber($oSourceParentClassNode);
|
||||
$sItopNodePath = DesignDocument::GetItopNodePath($oSourceParentClassNode);
|
||||
throw new MFException($sItopNodePath." at line $iLine: invalid parent class '$sParentClassName'",
|
||||
MFException::NOT_FOUND, $iLine, $sItopNodePath);
|
||||
throw new MFException("invalid parent class '$sParentClassName'", MFException::NOT_FOUND, $oSourceParentClassNode);
|
||||
}
|
||||
$oNextParentSibling = $oNodeForTargetParent->nextSibling;
|
||||
if ($oNextParentSibling) {
|
||||
@@ -839,20 +860,14 @@ class ModelFactory
|
||||
if (!$oTargetNode || $oTargetNode->IsRemoved()) {
|
||||
// The node does not exist or is marked as removed
|
||||
if ($bMustExist) {
|
||||
$iLine = ModelFactory::GetXMLLineNumber($oSourceNode);
|
||||
$sItopNodePath = DesignDocument::GetItopNodePath($oSourceNode);
|
||||
throw new MFException($sItopNodePath.' at line '.$iLine.': could not be found or marked as removed',
|
||||
MFException::NOT_FOUND, $iLine, $sItopNodePath);
|
||||
throw new MFException("could not be found or marked as removed", MFException::NOT_FOUND, $oSourceNode);
|
||||
}
|
||||
if ($bIfExists) {
|
||||
// Do not continue deeper
|
||||
$oTargetNode = null;
|
||||
} else {
|
||||
if (!$bSpecifiedMerge && $sMode === self::LOAD_DELTA_MODE_STRICT && ($sSearchId !== '' || is_null($oSourceNode->GetFirstElementChild()))) {
|
||||
$iLine = ModelFactory::GetXMLLineNumber($oSourceNode);
|
||||
$sItopNodePath = DesignDocument::GetItopNodePath($oSourceNode);
|
||||
throw new MFException($sItopNodePath.' at line '.$iLine.': could not be found or marked as removed (strict mode)',
|
||||
MFException::NOT_FOUND, $iLine, $sItopNodePath, 'strict mode');
|
||||
throw new MFException("could not be found or marked as removed (strict mode)", MFException::NOT_FOUND, $oSourceNode, null, 'strict mode');
|
||||
}
|
||||
|
||||
// Ignore renaming non-existant node
|
||||
@@ -901,10 +916,7 @@ class ModelFactory
|
||||
if (is_null($oSourceNode->GetFirstElementChild()) && $oTargetParentNode instanceof MFElement) {
|
||||
// Leaf node
|
||||
if ($sMode === self::LOAD_DELTA_MODE_STRICT && !$oSourceNode->hasAttribute('_rename_from') && trim($oSourceNode->GetText('')) !== '') {
|
||||
$iLine = ModelFactory::GetXMLLineNumber($oSourceNode);
|
||||
$sItopNodePath = DesignDocument::GetItopNodePath($oSourceNode);
|
||||
throw new MFException($sItopNodePath.' at line '.$iLine.': cannot be modified without _delta flag (strict mode)',
|
||||
MFException::AMBIGUOUS_LEAF, $iLine, $sItopNodePath, 'strict mode');
|
||||
throw new MFException("cannot be modified without _delta flag (strict mode)", MFException::AMBIGUOUS_LEAF, $oSourceNode, null, 'strict mode');
|
||||
} else {
|
||||
// Lax mode: same as redefine
|
||||
// Replace the existing node by the given node - copy child nodes as well
|
||||
@@ -912,7 +924,7 @@ class ModelFactory
|
||||
if (trim($oSourceNode->GetText('')) !== '') {
|
||||
$oTargetNode = $oTargetDocument->importNode($oSourceNode, true);
|
||||
$sSearchId = $oSourceNode->hasAttribute('_rename_from') ? $oSourceNode->getAttribute('_rename_from') : $oSourceNode->getAttribute('id');
|
||||
$oTargetParentNode->RedefineChildNode($oTargetNode, $sSearchId);
|
||||
$oTargetParentNode->RedefineChildNode($oTargetNode, $sSearchId, $oSourceNode);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -956,7 +968,7 @@ class ModelFactory
|
||||
// Replace the existing node by the given node - copy child nodes as well
|
||||
/** @var \MFElement $oTargetNode */
|
||||
$oTargetNode = $oTargetDocument->importNode($oSourceNode, true);
|
||||
$oTargetParentNode->RedefineChildNode($oTargetNode, $sSearchId);
|
||||
$oTargetParentNode->RedefineChildNode($oTargetNode, $sSearchId, $oSourceNode);
|
||||
break;
|
||||
|
||||
case 'delete_if_exists':
|
||||
@@ -976,25 +988,18 @@ class ModelFactory
|
||||
case 'delete':
|
||||
/** @var \MFElement $oTargetNode */
|
||||
$oTargetNode = $oTargetParentNode->_FindChildNode($oSourceNode, $sSearchId);
|
||||
$sPath = MFDocument::GetItopNodePath($oSourceNode);
|
||||
$iLine = $this->GetXMLLineNumber($oSourceNode);
|
||||
|
||||
if ($oTargetNode == null) {
|
||||
throw new MFException($sPath.' at line '.$iLine.": could not be deleted (not found)", MFException::COULD_NOT_BE_DELETED,
|
||||
$iLine, $sPath);
|
||||
throw new MFException("could not be deleted (not found)", MFException::COULD_NOT_BE_DELETED, $oSourceNode);
|
||||
}
|
||||
if ($oTargetNode->IsRemoved()) {
|
||||
throw new MFException($sPath.' at line '.$iLine.": could not be deleted (already marked as deleted)",
|
||||
MFException::ALREADY_DELETED, $iLine, $sPath);
|
||||
throw new MFException("could not be deleted (already marked as deleted)", MFException::ALREADY_DELETED, $oSourceNode);
|
||||
}
|
||||
$oTargetNode->Delete();
|
||||
break;
|
||||
|
||||
default:
|
||||
$sPath = MFDocument::GetItopNodePath($oSourceNode);
|
||||
$iLine = $this->GetXMLLineNumber($oSourceNode);
|
||||
throw new MFException($sPath.' at line '.$iLine.": unexpected value for attribute _delta: '".$sDeltaSpec."'",
|
||||
MFException::INVALID_DELTA, $iLine, $sPath, $sDeltaSpec);
|
||||
throw new MFException("unexpected value for attribute _delta: '".$sDeltaSpec."'", MFException::INVALID_DELTA, $oSourceNode, null, $sDeltaSpec);
|
||||
}
|
||||
|
||||
if ($oTargetNode && $oTargetNode->parentNode) {
|
||||
@@ -2124,7 +2129,7 @@ class MFElement extends Combodo\iTop\DesignElement
|
||||
*/
|
||||
public function IsInDefinition()
|
||||
{
|
||||
// Iterate through the parents: reset the flag if any of them has a flag set
|
||||
// Iterate through the parents: reset the flag if any of them has a flag set
|
||||
for ($oParent = $this; $oParent instanceof MFElement; $oParent = $oParent->parentNode)
|
||||
{
|
||||
if ($oParent->GetAlteration() != '')
|
||||
@@ -2201,14 +2206,12 @@ class MFElement extends Combodo\iTop\DesignElement
|
||||
if ($oExisting)
|
||||
{
|
||||
if (!$oExisting->IsRemoved()) {
|
||||
$sPath = MFDocument::GetItopNodePath($oNode);
|
||||
$iLine = ModelFactory::GetXMLLineNumber($oNode);
|
||||
$sExistingPath = MFDocument::GetItopNodePath($oExisting).' created_in: ['.$oExisting->getAttribute('_created_in').']';
|
||||
$iExistingLine = ModelFactory::GetXMLLineNumber($oExisting);
|
||||
$sExceptionMessage = <<<EOF
|
||||
`{$sPath}` at line {$iLine} could not be added : already exists in `{$sExistingPath}` at line {$iExistingLine}
|
||||
could not be added : already exists in `{$sExistingPath}` at line {$iExistingLine}
|
||||
EOF;
|
||||
throw new MFException($sExceptionMessage, MFException::COULD_NOT_BE_ADDED, $iLine, $sPath);
|
||||
throw new MFException($sExceptionMessage, MFException::COULD_NOT_BE_ADDED, $oNode);
|
||||
}
|
||||
$oExisting->ReplaceWithSingleNode($oNode);
|
||||
$sFlag = 'replaced';
|
||||
@@ -2229,13 +2232,14 @@ EOF;
|
||||
*
|
||||
* @param MFElement $oNode The node (including all subnodes) to set
|
||||
* @param string|null $sSearchId
|
||||
* @param mixed $oParentFallbackNode: provided to print accurate line number in case $oNode line is 0
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @throws MFException
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function RedefineChildNode(MFElement $oNode, $sSearchId = null)
|
||||
public function RedefineChildNode(MFElement $oNode, $sSearchId = null, $oParentFallbackNode=null)
|
||||
{
|
||||
// First: cleanup any flag behind the new node, and eventually add trace data
|
||||
$oNode->ApplyChanges();
|
||||
@@ -2245,17 +2249,13 @@ EOF;
|
||||
if (!$oExisting)
|
||||
{
|
||||
$sPath = MFDocument::GetItopNodePath($this)."/".$oNode->tagName.(empty($sSearchId) ? '' : "[$sSearchId]");
|
||||
$iLine = ModelFactory::GetXMLLineNumber($oNode);
|
||||
throw new MFException($sPath." at line $iLine: could not be modified (not found)", MFException::COULD_NOT_BE_MODIFIED_NOT_FOUND,
|
||||
$sPath, $iLine);
|
||||
throw new MFException('could not be modified (not found)', MFException::COULD_NOT_BE_MODIFIED_NOT_FOUND, $oNode, $sPath, '', $oParentFallbackNode);
|
||||
}
|
||||
$sPrevFlag = $oExisting->GetAlteration();
|
||||
$sOldId = $oExisting->getAttribute('_old_id');
|
||||
if ($oExisting->IsRemoved()) {
|
||||
$sPath = MFDocument::GetItopNodePath($this)."/".$oNode->tagName.(empty($sSearchId) ? '' : "[$sSearchId]");
|
||||
$iLine = ModelFactory::GetXMLLineNumber($oNode);
|
||||
throw new MFException($sPath." at line $iLine: could not be modified (marked as deleted)",
|
||||
MFException::COULD_NOT_BE_MODIFIED_ALREADY_DELETED, $sPath, $iLine);
|
||||
throw new MFException('could not be modified (marked as deleted)', MFException::COULD_NOT_BE_MODIFIED_ALREADY_DELETED, $oNode, $sPath, '', $oParentFallbackNode);
|
||||
}
|
||||
$oExisting->ReplaceWithSingleNode($oNode);
|
||||
if (!$this->IsInDefinition()) {
|
||||
|
||||
@@ -120,10 +120,6 @@ class ModuleDiscovery
|
||||
$aArgs['module_file'] = $sFilePath;
|
||||
|
||||
list($sModuleName, $sModuleVersion) = static::GetModuleName($sId);
|
||||
if ($sModuleVersion == '')
|
||||
{
|
||||
$sModuleVersion = '1.0.0';
|
||||
}
|
||||
|
||||
if (array_key_exists($sModuleName, self::$m_aModuleVersionByName))
|
||||
{
|
||||
@@ -233,7 +229,7 @@ class ModuleDiscovery
|
||||
}
|
||||
ksort($aDependencies);
|
||||
$aOrderedModules = [];
|
||||
$iLoopCount = 1;
|
||||
$iLoopCount = 0;
|
||||
while(($iLoopCount < count($aModules)) && (count($aDependencies) > 0) )
|
||||
{
|
||||
foreach($aDependencies as $sId => $aRemainingDeps)
|
||||
@@ -308,16 +304,8 @@ class ModuleDiscovery
|
||||
// Separate the module names from their version for an easier comparison later
|
||||
foreach($aOrderedModules as $sModuleId)
|
||||
{
|
||||
$aMatches = array();
|
||||
if (preg_match('|^([^/]+)/(.*)$|', $sModuleId, $aMatches))
|
||||
{
|
||||
$aModuleVersions[$aMatches[1]] = $aMatches[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
// No version number found, assume 1.0.0
|
||||
$aModuleVersions[$sModuleId] = '1.0.0';
|
||||
}
|
||||
list($sModuleName, $sVersion) = self::GetModuleName($sModuleId);
|
||||
$aModuleVersions[$sModuleName] = $sVersion;
|
||||
}
|
||||
if (preg_match_all('/([^\(\)&| ]+)/', $sDepString, $aMatches))
|
||||
{
|
||||
@@ -456,13 +444,17 @@ class ModuleDiscovery
|
||||
{
|
||||
$sName = $aMatches[1];
|
||||
$sVersion = $aMatches[2];
|
||||
if ($sVersion === ""){
|
||||
$sVersion = "1.0.0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$sName = $sModuleId;
|
||||
$sVersion = "";
|
||||
$sVersion = "1.0.0";
|
||||
}
|
||||
return array($sName, $sVersion);
|
||||
|
||||
return [$sName, $sVersion];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -773,7 +773,7 @@ abstract class Controller extends AbstractController
|
||||
{
|
||||
// iTop 3.1 and older compatibility, if not an URI we don't know if its relative to app root or module root
|
||||
if (strpos($sLinkedScript, "://") === false) {
|
||||
$this->m_oPage->add_linked_script($sLinkedScript);
|
||||
$this->m_oPage->LinkScriptFromAppRoot(utils::LocalPath($sLinkedScript, APPROOT));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1280,18 +1280,19 @@ JS;
|
||||
protected function AddCompatibilityFiles(string $sFileType, string $sMode): void
|
||||
{
|
||||
$sConstantName = 'COMPATIBILITY_'.strtoupper($sMode).'_LINKED_'. ($sFileType === static::ENUM_COMPATIBILITY_FILE_TYPE_CSS ? 'STYLESHEETS' : 'SCRIPTS') .'_REL_PATH';
|
||||
$sMethodName = 'add_linked_'.($sFileType === static::ENUM_COMPATIBILITY_FILE_TYPE_CSS ? 'stylesheet' : 'script');
|
||||
$sMethodName = 'Link'.($sFileType === static::ENUM_COMPATIBILITY_FILE_TYPE_CSS ? 'Resource' : 'Script').'FromAppRoot';
|
||||
|
||||
|
||||
// Add ancestors files
|
||||
foreach (array_reverse(class_parents(static::class)) as $sParentClass) {
|
||||
foreach (constant($sParentClass.'::'.$sConstantName) as $sFile) {
|
||||
$this->$sMethodName(utils::GetAbsoluteUrlAppRoot().$sFile);
|
||||
$this->$sMethodName($sFile);
|
||||
}
|
||||
}
|
||||
|
||||
// Add current class files
|
||||
foreach (constant('static::'.$sConstantName) as $sFile) {
|
||||
$this->$sMethodName(utils::GetAbsoluteUrlAppRoot().$sFile);
|
||||
$this->$sMethodName($sFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -664,6 +664,7 @@ JS;
|
||||
$aResult['data'] = ['error_message' => $e->getHtmlMessage()];
|
||||
} else {
|
||||
$oPage->AddHeaderMessage($e->getHtmlMessage(), 'message_error');
|
||||
$oObj->Reload();
|
||||
$oObj->DisplayModifyForm($oPage,
|
||||
array('wizard_container' => true)); // wizard_container: display the wizard border and the title
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class SessionHandler extends \SessionHandler
|
||||
$iCreationTime = $aJson['creation_time'];
|
||||
}
|
||||
} else {
|
||||
IssueLog::Debug(__METHOD__ . ': not a json due (session file corruption?)', null, [ 'sPreviousFileVersionContent' => $sPreviousFileVersionContent ]);
|
||||
$aJson=[];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2440,7 +2440,9 @@ class SynchroReplica extends DBObject implements iDisplay
|
||||
// Really modified ?
|
||||
if ($oDestObj->IsModified())
|
||||
{
|
||||
$oDestObj::SetCurrentChange($oChange);
|
||||
if(method_exists(get_class($oDestObj), "SetCurrentChange")){
|
||||
$oDestObj::SetCurrentChange($oChange);
|
||||
}
|
||||
$oDestObj->DBUpdate();
|
||||
$bModified = true;
|
||||
$oStatLog->AddTrace('Updated object - Values: {'.implode(', ', $aValueTrace).'}', $this);
|
||||
@@ -2499,7 +2501,10 @@ class SynchroReplica extends DBObject implements iDisplay
|
||||
$aValueTrace[] = "$sAttCode: $value";
|
||||
}
|
||||
}
|
||||
$oDestObj::SetCurrentChange($oChange);
|
||||
|
||||
if(method_exists(get_class($oDestObj), "SetCurrentChange")){
|
||||
$oDestObj::SetCurrentChange($oChange);
|
||||
}
|
||||
$iNew = $oDestObj->DBInsert();
|
||||
|
||||
$this->Set('dest_id', $oDestObj->GetKey());
|
||||
|
||||
@@ -179,14 +179,14 @@ abstract class TestHandler
|
||||
}
|
||||
catch (CoreException $e)
|
||||
{
|
||||
//$this->ReportError($e->getMessage());
|
||||
//$this->ReportError($e->__tostring());
|
||||
//$this->ReportErrors($e->getMessage());
|
||||
//$this->ReportErrors($e->__tostring());
|
||||
$this->ReportError($e->getMessage().' - '.$e->getTraceAsHtml());
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
//$this->ReportError($e->getMessage());
|
||||
//$this->ReportError($e->__tostring());
|
||||
//$this->ReportErrors($e->getMessage());
|
||||
//$this->ReportErrors($e->__tostring());
|
||||
$this->ReportError('class '.get_class($e).' --- '.$e->getMessage().' - '.$e->getTraceAsString());
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
@@ -397,7 +397,7 @@ class TestMyBizModel extends TestBizModel
|
||||
|
||||
protected function DoExecute()
|
||||
{
|
||||
// $this->ReportError("Found two different OQL expression out of the (same?) filter: <em>$sExpr1</em> != <em>$sExpr2</em>");
|
||||
// $this->ReportErrors("Found two different OQL expression out of the (same?) filter: <em>$sExpr1</em> != <em>$sExpr2</em>");
|
||||
// $this->ReportSuccess('Found '.$oSet->Count()." objects of class $sClassName");
|
||||
//$this->test_linksinfo();
|
||||
//$this->test_list_attributes();
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Combodo\iTop\Test\UnitTest\Setup;
|
||||
|
||||
use Combodo\iTop\Test\UnitTest\ItopTestCase;
|
||||
|
||||
class ModuleDiscoveryTest extends ItopTestCase
|
||||
{
|
||||
public function GetModuleNameProvider()
|
||||
{
|
||||
return [
|
||||
'nominal' => [
|
||||
'sModuleId' => 'a/1.2.3',
|
||||
'name' => 'a',
|
||||
'version' => '1.2.3',
|
||||
],
|
||||
'develop' => [
|
||||
'sModuleId' => 'a/1.2.3-dev',
|
||||
'name' => 'a',
|
||||
'version' => '1.2.3-dev',
|
||||
],
|
||||
'missing version => 1.0.0' => [
|
||||
'sModuleId' => 'a/',
|
||||
'name' => 'a',
|
||||
'version' => '1.0.0',
|
||||
],
|
||||
'missing everything except name' => [
|
||||
'sModuleId' => 'a',
|
||||
'name' => 'a',
|
||||
'version' => '1.0.0',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->RequireOnceItopFile('setup/modulediscovery.class.inc.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider GetModuleNameProvider
|
||||
*/
|
||||
public function testGetModuleName($sModuleId, $expectedName, $expectedVersion)
|
||||
{
|
||||
$this->assertEquals([$expectedName, $expectedVersion], \ModuleDiscovery::GetModuleName($sModuleId));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -316,4 +316,13 @@ class SessionHandlerTest extends ItopDataTestCase
|
||||
|
||||
$this->assertEquals('gabuzomeu', $aJson['shadok'] ?? '', "Should report the current login mode in [shadok]: $sFirstContent");
|
||||
}
|
||||
|
||||
public function testGenerateSessionContentWithPreviousNonArrayContentAndWithAdditionalDataProvidedBySessionHandlerExtension()
|
||||
{
|
||||
\utils::GetConfig()->Set('sessions_tracking.session_handler_extension', 'Combodo\iTop\Test\UnitTest\SessionTracker\BasicSessionHandlerExtension');
|
||||
$this->CreateUserAndLogIn();
|
||||
$oSessionHandler = new SessionHandler();
|
||||
$sContent = $this->GenerateSessionContent($oSessionHandler, json_encode(null));
|
||||
$this->assertNotNull($sContent, "Call to CompleteSessionData should NOT fail due to Argument #1 (\$aJson) must be of type array, null given");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user