IssueResolver_Controller.php: job does not stop after error or no issues found.

This commit is contained in:
KarpAlex
2022-02-18 11:01:45 +01:00
parent a6771df4dd
commit 45f789ebf9
+67 -64
View File
@@ -33,79 +33,82 @@ abstract class IssueResolver_Controller extends JOB_Controller
if (isError($openIssuesRes))
{
$this->logError(getError($openIssuesRes));
return;
}
// log info if no data found
if (!hasData($openIssuesRes))
else
{
$this->logInfo("No open issues found");
return;
}
$openIssues = getData($openIssuesRes);
foreach ($openIssues as $issue)
{
if (isset($this->_codeLibMappings[$issue->fehlercode]))
// log info if no data found
if (!hasData($openIssuesRes))
{
$this->logInfo("No open issues found");
}
else
{
$libName = $this->_codeLibMappings[$issue->fehlercode];
// add person id and oe kurzbz automatically as params, merge it with additional params
// decode bewerbung_parameter into assoc array
$params = array_merge(
array('issue_id' => $issue->issue_id, 'issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz),
isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array()
);
$openIssues = getData($openIssuesRes);
// if called from extension (extension name set), path includes extension names, otherwise it is the core library folder
$libRootPath = isset($this->_extensionName) ? 'extensions/'.$this->_extensionName.'/' : '';
$issuesLibPath = $libRootPath.self::ISSUES_FOLDER.'/';
$issuesLibFilePath = DOC_ROOT.'application/' . $libRootPath.'libraries/'.self::ISSUES_FOLDER.'/'.$libName.'.php';
// check if library file exists
if (!file_exists($issuesLibFilePath))
foreach ($openIssues as $issue)
{
// log error and continue with next issue if not
$this->logError("Issue library file ".$issuesLibFilePath." does not exist");
continue;
}
// load library connected to fehlercode
$this->load->library(
$issuesLibPath.$libName
);
$lowercaseLibName = mb_strtolower($libName);
// check if method is defined in libary class
if (!is_callable(array($this->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME)))
{
// log error and continue with next issue if not
$this->logError("Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName");
continue;
}
// call the function for checking for issue resolution
$issueResolvedRes = $this->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params);
if (isError($issueResolvedRes))
{
$this->logError(getError($issueResolvedRes));
}
else
{
$issueResolvedData = getData($issueResolvedRes);
if ($issueResolvedData === true)
if (isset($this->_codeLibMappings[$issue->fehlercode]))
{
// set issue to resolved if needed
$behobenRes = $this->issueslib->setBehoben($issue->issue_id, null);
$libName = $this->_codeLibMappings[$issue->fehlercode];
if (isError($behobenRes))
$this->logError(getError($behobenRes));
// add person id and oe kurzbz automatically as params, merge it with additional params
// decode bewerbung_parameter into assoc array
$params = array_merge(
array('issue_id' => $issue->issue_id, 'issue_person_id' => $issue->person_id, 'issue_oe_kurzbz' => $issue->oe_kurzbz),
isset($issue->behebung_parameter) ? json_decode($issue->behebung_parameter, true) : array()
);
// if called from extension (extension name set), path includes extension names, otherwise it is the core library folder
$libRootPath = isset($this->_extensionName) ? 'extensions/' . $this->_extensionName . '/' : '';
$issuesLibPath = $libRootPath . self::ISSUES_FOLDER . '/';
$issuesLibFilePath = DOC_ROOT . 'application/' . $libRootPath . 'libraries/' . self::ISSUES_FOLDER . '/' . $libName . '.php';
// check if library file exists
if (!file_exists($issuesLibFilePath))
{
// log error and continue with next issue if not
$this->logError("Issue library file " . $issuesLibFilePath . " does not exist");
continue;
}
// load library connected to fehlercode
$this->load->library(
$issuesLibPath . $libName
);
$lowercaseLibName = mb_strtolower($libName);
// check if method is defined in libary class
if (!is_callable(array($this->{$lowercaseLibName}, self::CHECK_ISSUE_RESOLVED_METHOD_NAME)))
{
// log error and continue with next issue if not
$this->logError("Method " . self::CHECK_ISSUE_RESOLVED_METHOD_NAME . " is not defined in library $lowercaseLibName");
continue;
}
// call the function for checking for issue resolution
$issueResolvedRes = $this->{$lowercaseLibName}->{self::CHECK_ISSUE_RESOLVED_METHOD_NAME}($params);
if (isError($issueResolvedRes))
{
$this->logError(getError($issueResolvedRes));
}
else
$this->logInfo("Issue " . $issue->issue_id . " successfully resolved");
{
$issueResolvedData = getData($issueResolvedRes);
if ($issueResolvedData === true)
{
// set issue to resolved if needed
$behobenRes = $this->issueslib->setBehoben($issue->issue_id, null);
if (isError($behobenRes))
$this->logError(getError($behobenRes));
else
$this->logInfo("Issue " . $issue->issue_id . " successfully resolved");
}
}
}
}
}