Skip to content
Permalink
Browse files
Merge pull request #718 from tarasfrompir/patch-40
update callMethodSafe and seek CrossLinked methods
  • Loading branch information
sergejey committed Mar 31, 2020
2 parents d52f13c + 1e059a8 commit 54546a40a0d4f470aa5f3ecea8b5d198e879e110
Showing 1 changed file with 16 additions and 5 deletions.
@@ -475,6 +475,10 @@ function getMethodByName($name, $class_id, $id)
*/
function raiseEvent($name, $params = 0, $parent = 0)
{
if (!is_array($params)) {
$params = array();
}
$params['raiseEvent'] = '1';
$this->callMethodSafe($name,$params);
}

@@ -486,34 +490,41 @@ function callClassMethod($name, $params = 0)
function callMethodSafe($name, $params = 0) {
startMeasure('callMethodSafe');
$current_call = $this->object_title . '.' . $name;
$call_stack = array();
if (is_array($params)) {
$current_call .= '.' . md5(json_encode($params));
$call_stack = $params['m_c_s'];
$raiseEvent = $params['raiseEvent'];
}
$call_stack = array();
if (IsSet($_SERVER['REQUEST_URI']) && ($_SERVER['REQUEST_URI'] != '')) {
if (isset($_GET['m_c_s']) && is_array($_GET['m_c_s'])) {
$call_stack = $_GET['m_c_s'];
$raiseEvent = $_GET['raiseEvent'];
}
if (in_array($current_call, $call_stack)) {
$call_stack[] = $current_call;
DebMes("Warning: cross-linked call of " . $current_call . "\nlog:\n" . implode(" -> \n", $call_stack));
return 0;
}
}
$call_stack[] = $current_call;

if (!is_array($params)) {
$params = array();
}
if (IsSet($_SERVER['REQUEST_URI']) && ($_SERVER['REQUEST_URI'] != '')) {

$call_stack[] = $current_call;
$params['raiseEvent'] = $raiseEvent;
$params['m_c_s'] = $call_stack;

if (IsSet($_SERVER['REQUEST_URI']) && ($_SERVER['REQUEST_URI'] != '') && !$raiseEvent && count($call_stack)>1) {
$result = $this->callMethod($name, $params);
} else {
$params['m_c_s'] = $call_stack;
$result = callAPI('/api/method/' . urlencode($this->object_title . '.' . $name), 'GET', $params);
}
endMeasure('callMethodSafe');
return $result;
}

/**
* Title
*

0 comments on commit 54546a4

Please sign in to comment.