From d57777575f37a46f82bdc22c46a086aa0bd5bb97 Mon Sep 17 00:00:00 2001 From: Domingo Oropeza Date: Thu, 13 Sep 2018 16:05:15 -0400 Subject: [PATCH] fix(install): set missing agent base url on cli_install Signed-off-by: Domingo Oropeza --- .travis.yml | 2 +- inc/inventorycomputerlib.class.php | 2 +- install/install.php | 25 +++++++++---------------- phpunit/bootstrap.php | 4 ++++ 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index df886b7379..6774c75b8f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,7 +64,7 @@ before_install: before_script: - phpenv version-name | grep ^5.[34] && echo "extension=apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true - phpenv version-name | grep ^5.[34] && echo "apc.enable_cli=1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini ; true - - php -S localhost:8088 -t glpi > /dev/null 2>&1 & + - php -S localhost:8000 -t glpi > /dev/null 2>&1 & script: - composer install diff --git a/inc/inventorycomputerlib.class.php b/inc/inventorycomputerlib.class.php index 545b3f5cbb..2fb530e596 100644 --- a/inc/inventorycomputerlib.class.php +++ b/inc/inventorycomputerlib.class.php @@ -173,7 +173,7 @@ function updateComputer($a_computerinventory, $computers_id, $no_history, $setdy //OS exists, check for updates $same = true; foreach ($input_os as $key => $value) { - if ($ios->fields[$key] != $value) { + if (isset($ios->fields[$key]) && $ios->fields[$key] != $value) { $same = false; break; } diff --git a/install/install.php b/install/install.php index 75c7b62b1a..89fdae3863 100644 --- a/install/install.php +++ b/install/install.php @@ -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] ); } diff --git a/phpunit/bootstrap.php b/phpunit/bootstrap.php index 66ab3bed62..c0f7ddbbce 100644 --- a/phpunit/bootstrap.php +++ b/phpunit/bootstrap.php @@ -9,6 +9,10 @@ include('./glpi/inc/includes.php'); +Config::setConfigurationValues('core', [ + 'url_base' => 'http://localhost:8000' +]); + if (!defined('FUSINV_ROOT')) { define('FUSINV_ROOT', GLPI_ROOT . DIRECTORY_SEPARATOR . '/plugins/fusioninventory'); set_include_path(