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

Fixes for cli_install script #2654

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/inventorycomputerlib.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (key_exists($key, $ios->fields) && $ios->fields[$key] != $value) {
$same = false;
break;
}
Expand Down
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
4 changes: 2 additions & 2 deletions phpunit/0_Install/FusinvInstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public function testForceInstall() {
function install($force = false) {
$output = [];
$returncode = 0;
$command = "php -f ".FUSINV_ROOT. "/scripts/cli_install.php -- --as-user 'glpi'";
$command = "php -f ".FUSINV_ROOT. "/scripts/cli_install.php";
if ($force) {
$command.= " --force-install";
$command.= " -- --as-user 'glpi' --force-install";
}
exec($command, $output, $returncode);
$this->assertEquals(0, $returncode,
Expand Down
4 changes: 4 additions & 0 deletions phpunit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

include('./glpi/inc/includes.php');

Config::setConfigurationValues('core', [
'url_base' => 'http://localhost:8088'
]);

if (!defined('FUSINV_ROOT')) {
define('FUSINV_ROOT', GLPI_ROOT . DIRECTORY_SEPARATOR . '/plugins/fusioninventory');
set_include_path(
Expand Down
7 changes: 6 additions & 1 deletion scripts/cli_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,14 @@
die("GLPI not installed\n");
}

$user = new User();
if (!is_null($args['--as-user'])) {
$user = new User();
$user->getFromDBbyName($args['--as-user']);
} else {
$user->getFromDBbyName('glpi');
}

if (!$user->isNewItem()) {
$auth = new Auth();
$auth->auth_succeded = true;
$auth->user = $user;
Expand Down