Skip to content
This repository was archived by the owner on Apr 4, 2024. It is now read-only.

Commit be1df49

Browse files
committed
fix(install): set missing agent base url on cli_install
Signed-off-by: Domingo Oropeza <[email protected]>
1 parent 0799368 commit be1df49

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

install/install.php

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -337,22 +337,15 @@ function pluginFusioninventoryInstall($version, $migrationname = 'Migration') {
337337
/*
338338
* Define when install agent_base_url in glpi_plugin_fusioninventory_entities
339339
*/
340-
$full_url = filter_input(INPUT_SERVER, "PHP_SELF");
341-
$https = filter_input(INPUT_SERVER, "HTTPS");
342-
$http_host = filter_input(INPUT_SERVER, "HTTP_HOST");
343-
if (!empty($full_url) && !strstr($full_url, 'cli_install.php')) {
344-
if (!empty($https)) {
345-
$agent_base_url = 'https://'.$http_host.$full_url;
346-
} else {
347-
$agent_base_url = 'http://'.$http_host.$full_url;
348-
}
349-
$agent_base_url = str_replace('/front/plugin.form.php', '', $agent_base_url);
350-
$DB->update(
351-
'glpi_plugin_fusioninventory_entities', [
352-
'agent_base_url' => $agent_base_url
353-
], [
354-
'id' => 1
355-
]
340+
$iterator = $DB->request([
341+
'SELECT' => 'value',
342+
'FROM' => Config::getTable(),
343+
'WHERE' => ['name' => 'url_base'],
344+
]);
345+
if ($row = $iterator->next()) {
346+
$DB->update('glpi_plugin_fusioninventory_entities',
347+
['agent_base_url' => rtrim($row['value'], '/')],
348+
['id' => 1]
356349
);
357350
}
358351

phpunit/2_Integration/Deploy/DeploymirrorTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,23 @@ public function testGestList() {
5757
(`id`, `name`, `entities_id`, `completename`, `level`, `tag`)
5858
VALUES (2, 'entity B', 0, 'Root entity > entity B', 2, 'entB')");
5959

60+
$iterator = $DB->request([
61+
'SELECT' => 'value',
62+
'FROM' => Config::getTable(),
63+
'WHERE' => ['name' => 'url_base'],
64+
]);
65+
$row = $iterator->next();
66+
$agent_base_url = rtrim($row['value'], '/');
67+
6068
$DB->query("INSERT INTO `glpi_plugin_fusioninventory_entities`
6169
(`id`, `entities_id`, `transfers_id_auto`, `agent_base_url`)
62-
VALUES (NULL, 0, 0, 'http://localhost:8080/glpi')");
70+
VALUES (NULL, 0, 0, '" . $agent_base_url . "')");
6371
$DB->query("INSERT INTO `glpi_plugin_fusioninventory_entities`
6472
(`id`, `entities_id`, `transfers_id_auto`, `agent_base_url`)
65-
VALUES (NULL, 1, 0, 'http://localhost:8080/glpi')");
73+
VALUES (NULL, 1, 0, '" . $agent_base_url . "')");
6674
$DB->query("INSERT INTO `glpi_plugin_fusioninventory_entities`
6775
(`id`, `entities_id`, `transfers_id_auto`, `agent_base_url`)
68-
VALUES (NULL, 2, 0, 'http://localhost:8080/glpi')");
76+
VALUES (NULL, 2, 0, '" . $agent_base_url . "')");
6977

7078
//Set root entity with child entities
7179
$_SESSION['glpiactive_entity'] = 0;
@@ -141,7 +149,7 @@ public function testGestList() {
141149
'entities_id' => 2
142150
]);
143151

144-
$server_download_url = "http://localhost:8080/glpi/plugins/fusioninventory/b/deploy/?action=getFilePart&file=";
152+
$server_download_url = $agent_base_url . "/plugins/fusioninventory/b/deploy/?action=getFilePart&file=";
145153

146154
//Add the server's url at the end of the mirrors list
147155
$PF_CONFIG['server_as_mirror'] = true;

0 commit comments

Comments
 (0)