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

Commit

Permalink
fix(install): set missing agent base url on cli_install
Browse files Browse the repository at this point in the history
Signed-off-by: Domingo Oropeza <[email protected]>
  • Loading branch information
DIOHz0r committed Sep 14, 2018
1 parent 9ab17b5 commit 2735426
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
25 changes: 9 additions & 16 deletions install/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,22 +337,15 @@ function pluginFusioninventoryInstall($version, $migrationname = 'Migration') {
/*
* Define when install agent_base_url in glpi_plugin_fusioninventory_entities
*/
$full_url = filter_input(INPUT_SERVER, "PHP_SELF");
$https = filter_input(INPUT_SERVER, "HTTPS");
$http_host = filter_input(INPUT_SERVER, "HTTP_HOST");
if (!empty($full_url) && !strstr($full_url, 'cli_install.php')) {
if (!empty($https)) {
$agent_base_url = 'https://'.$http_host.$full_url;
} else {
$agent_base_url = 'http://'.$http_host.$full_url;
}
$agent_base_url = str_replace('/front/plugin.form.php', '', $agent_base_url);
$DB->update(
'glpi_plugin_fusioninventory_entities', [
'agent_base_url' => $agent_base_url
], [
'id' => 1
]
$iterator = $DB->request([
'SELECT' => 'value',
'FROM' => Config::getTable(),
'WHERE' => ['name' => 'url_base'],
]);
if ($row = $iterator->next()) {
$DB->update('glpi_plugin_fusioninventory_entities',
['agent_base_url' => rtrim($row['value'], '/')],
['id' => 1]
);
}

Expand Down
16 changes: 12 additions & 4 deletions phpunit/2_Integration/Deploy/DeploymirrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,23 @@ public function testGestList() {
(`id`, `name`, `entities_id`, `completename`, `level`, `tag`)
VALUES (2, 'entity B', 0, 'Root entity > entity B', 2, 'entB')");

$iterator = $DB->request([
'SELECT' => 'value',
'FROM' => Config::getTable(),
'WHERE' => ['name' => 'url_base'],
]);
$row = $iterator->next();
$agent_base_url = rtrim($row['value'], '/');

$DB->query("INSERT INTO `glpi_plugin_fusioninventory_entities`
(`id`, `entities_id`, `transfers_id_auto`, `agent_base_url`)
VALUES (NULL, 0, 0, 'http://localhost:8080/glpi')");
VALUES (NULL, 0, 0, '" . $agent_base_url . "')");
$DB->query("INSERT INTO `glpi_plugin_fusioninventory_entities`
(`id`, `entities_id`, `transfers_id_auto`, `agent_base_url`)
VALUES (NULL, 1, 0, 'http://localhost:8080/glpi')");
VALUES (NULL, 1, 0, '" . $agent_base_url . "')");
$DB->query("INSERT INTO `glpi_plugin_fusioninventory_entities`
(`id`, `entities_id`, `transfers_id_auto`, `agent_base_url`)
VALUES (NULL, 2, 0, 'http://localhost:8080/glpi')");
VALUES (NULL, 2, 0, '" . $agent_base_url . "')");

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

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

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

0 comments on commit 2735426

Please sign in to comment.