Skip to content

Commit

Permalink
Fix session defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Dec 18, 2024
1 parent 6975a17 commit 3d6150c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/Glpi/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ public function __construct(private Kernel $kernel)
global $CFG_GLPI;
$this->config = &$CFG_GLPI;

// Force the current "username"
$_SESSION['glpiname'] = 'cli';

$this->computeAndLoadOutputLang();

// Load core commands only to check if called command prevent or not usage of plugins
Expand Down
10 changes: 0 additions & 10 deletions src/Glpi/Kernel/Listener/SessionStart.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,5 @@ public function onPostBoot(): void

Session::start();
}

if (isCommandLine()) {
// Default value for use mode
$_SESSION['glpi_use_mode'] = Session::NORMAL_MODE;
$_SESSION['glpiname'] = 'cli';
} else {
// Initialize some session data before everything else so all layers can use it, even if session isn't started
$_SESSION['glpi_use_mode'] = null;
$_SESSION['glpilanguage'] = Session::getPreferredLanguage();
}
}
}
5 changes: 5 additions & 0 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ public static function start()
if (!isset($_SESSION['glpi_use_mode'])) {
$_SESSION['glpi_use_mode'] = Session::NORMAL_MODE;
}

// Define default language
if (!isset($_SESSION['glpilanguage'])) {
$_SESSION['glpilanguage'] = Session::getPreferredLanguage();
}
}


Expand Down

0 comments on commit 3d6150c

Please sign in to comment.