mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 09:15:15 +02:00
Ent 7080 error servicios elementos modulo
This commit is contained in:
parent
078ab1657f
commit
eb5e295286
@ -207,7 +207,7 @@ class Module extends Entity
|
|||||||
if (is_numeric($id_agent_module) === true
|
if (is_numeric($id_agent_module) === true
|
||||||
&& $id_agent_module > 0
|
&& $id_agent_module > 0
|
||||||
) {
|
) {
|
||||||
if ($nodeId !== null) {
|
if ($nodeId > 0) {
|
||||||
$this->nodeId = $nodeId;
|
$this->nodeId = $nodeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1022,12 +1022,13 @@ class Module extends Entity
|
|||||||
/**
|
/**
|
||||||
* Calculates cascade protection service value for this service.
|
* Calculates cascade protection service value for this service.
|
||||||
*
|
*
|
||||||
* @param integer|null $id_node Meta searching node will use this field.
|
* @param integer|null $id_node Meta searching node will use this field.
|
||||||
|
* @param boolean $connected Connected to a node.
|
||||||
*
|
*
|
||||||
* @return integer CPS value.
|
* @return integer CPS value.
|
||||||
* @throws \Exception On error.
|
* @throws \Exception On error.
|
||||||
*/
|
*/
|
||||||
public function calculateCPS(?int $id_node=null)
|
public function calculateCPS(?int $id_node=null, bool $connected=false)
|
||||||
{
|
{
|
||||||
if ($this->cps() < 0) {
|
if ($this->cps() < 0) {
|
||||||
return $this->cps();
|
return $this->cps();
|
||||||
@ -1047,6 +1048,7 @@ class Module extends Entity
|
|||||||
// Here could happen 2 things.
|
// Here could happen 2 things.
|
||||||
// 1. Metaconsole service is using this method impersonating node DB.
|
// 1. Metaconsole service is using this method impersonating node DB.
|
||||||
// 2. Node service is trying to find parents into metaconsole.
|
// 2. Node service is trying to find parents into metaconsole.
|
||||||
|
// 3. Impersonated node searching metaconsole.
|
||||||
if (empty($id_node) === true
|
if (empty($id_node) === true
|
||||||
&& is_metaconsole() === false
|
&& is_metaconsole() === false
|
||||||
&& has_metaconsole() === true
|
&& has_metaconsole() === true
|
||||||
@ -1119,6 +1121,38 @@ class Module extends Entity
|
|||||||
if ($r !== NOERR) {
|
if ($r !== NOERR) {
|
||||||
throw new \Exception(__('Cannot connect to node %d', $r));
|
throw new \Exception(__('Cannot connect to node %d', $r));
|
||||||
}
|
}
|
||||||
|
} else if (is_metaconsole() === true
|
||||||
|
// True in impersonated nodes.
|
||||||
|
&& has_metaconsole() === false
|
||||||
|
&& empty($id_node) === true
|
||||||
|
) {
|
||||||
|
// Impersonated node checking metaconsole.
|
||||||
|
\enterprise_hook('metaconsole_restore_db');
|
||||||
|
|
||||||
|
$mc_parents = db_get_all_rows_sql(
|
||||||
|
sprintf(
|
||||||
|
'SELECT id_service,
|
||||||
|
cps,
|
||||||
|
cascade_protection,
|
||||||
|
name
|
||||||
|
FROM `tservice_element` te
|
||||||
|
INNER JOIN `tservice` t ON te.id_service = t.id
|
||||||
|
WHERE te.id_agente_modulo = %d',
|
||||||
|
$this->id_agente_modulo()
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
// Restore impersonation.
|
||||||
|
\enterprise_include_once('include/functions_metaconsole.php');
|
||||||
|
$r = \enterprise_hook(
|
||||||
|
'metaconsole_connect',
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
$id_node,
|
||||||
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cps = 0;
|
$cps = 0;
|
||||||
|
@ -922,7 +922,8 @@ class Item extends CachedModel
|
|||||||
// Can't fetch an agent with an invalid Id.
|
// Can't fetch an agent with an invalid Id.
|
||||||
$agentId = static::extractAgentId($itemData);
|
$agentId = static::extractAgentId($itemData);
|
||||||
if ($agentId === null) {
|
if ($agentId === null) {
|
||||||
throw new \InvalidArgumentException('invalid agent Id');
|
$agentId = 0;
|
||||||
|
// throw new \InvalidArgumentException('invalid agent Id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Staticgraph don't need to have an agent.
|
// Staticgraph don't need to have an agent.
|
||||||
@ -956,7 +957,8 @@ class Item extends CachedModel
|
|||||||
$agent = \db_get_row_sql($sql);
|
$agent = \db_get_row_sql($sql);
|
||||||
|
|
||||||
if ($agent === false) {
|
if ($agent === false) {
|
||||||
throw new \Exception('error fetching the data from the DB');
|
return $agentData;
|
||||||
|
// throw new \Exception('error fetching the data from the DB');
|
||||||
}
|
}
|
||||||
|
|
||||||
// The agent name should be a valid string or a null value.
|
// The agent name should be a valid string or a null value.
|
||||||
@ -996,7 +998,8 @@ class Item extends CachedModel
|
|||||||
// Can't fetch an module with a invalid Id.
|
// Can't fetch an module with a invalid Id.
|
||||||
$moduleId = static::extractModuleId($itemData);
|
$moduleId = static::extractModuleId($itemData);
|
||||||
if ($moduleId === null) {
|
if ($moduleId === null) {
|
||||||
throw new \InvalidArgumentException('invalid module Id');
|
$moduleId = 0;
|
||||||
|
// throw new \InvalidArgumentException('invalid module Id');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Staticgraph don't need to have a module.
|
// Staticgraph don't need to have a module.
|
||||||
@ -1037,7 +1040,8 @@ class Item extends CachedModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($moduleName === false) {
|
if ($moduleName === false) {
|
||||||
throw new \Exception('error fetching the data from the DB');
|
return $moduleData;
|
||||||
|
// throw new \Exception('error fetching the data from the DB');
|
||||||
}
|
}
|
||||||
|
|
||||||
$moduleData['moduleName'] = $moduleName['nombre'];
|
$moduleData['moduleName'] = $moduleName['nombre'];
|
||||||
|
@ -123,6 +123,11 @@ final class Clock extends Item
|
|||||||
*/
|
*/
|
||||||
protected function decode(array $data): array
|
protected function decode(array $data): array
|
||||||
{
|
{
|
||||||
|
// Default values.
|
||||||
|
if (empty($data['height']) === true) {
|
||||||
|
$data['height'] = ($data['width'] / 2);
|
||||||
|
}
|
||||||
|
|
||||||
$clockData = parent::decode($data);
|
$clockData = parent::decode($data);
|
||||||
$clockData['type'] = CLOCK;
|
$clockData['type'] = CLOCK;
|
||||||
$clockData['clockType'] = static::extractClockType($data);
|
$clockData['clockType'] = static::extractClockType($data);
|
||||||
|
@ -31,6 +31,25 @@ final class Label extends Item
|
|||||||
*/
|
*/
|
||||||
protected function decode(array $data): array
|
protected function decode(array $data): array
|
||||||
{
|
{
|
||||||
|
$data['label'] = \preg_replace(
|
||||||
|
'/overflow: hidden;/',
|
||||||
|
'',
|
||||||
|
$data['label']
|
||||||
|
);
|
||||||
|
// Default values.
|
||||||
|
if ((empty($data['width']) === true)
|
||||||
|
&& (empty($data['height']) === true)
|
||||||
|
) {
|
||||||
|
preg_match(
|
||||||
|
'/visual_font_size_(.*)pt/',
|
||||||
|
$data['label'],
|
||||||
|
$matches
|
||||||
|
);
|
||||||
|
|
||||||
|
$data['width'] = (($matches[1] * 10) + 5);
|
||||||
|
$data['height'] = ($matches[1] * 2.5);
|
||||||
|
}
|
||||||
|
|
||||||
$return = parent::decode($data);
|
$return = parent::decode($data);
|
||||||
$return['type'] = LABEL;
|
$return['type'] = LABEL;
|
||||||
return $return;
|
return $return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user