Commit 5e0c0e88 authored by Cédric Anne's avatar Cédric Anne

Merge branch '9.5/bugfixes'

parents 8970eacf c3b757df
......@@ -855,8 +855,9 @@ class Auth extends CommonGLPI {
if (!empty($login_auth)) {
$search_params['auths_id'] = $this->user->fields["auths_id"];
}
$this->user->getFromDBByCrit($search_params);
$user_deleted_ldap = true;
if ($this->user->getFromDBByCrit($search_params)) {
$user_deleted_ldap = true;
};
}
}
}
......
......@@ -63,12 +63,19 @@ abstract class AbstractCommand extends Command implements GlpiCommandInterface {
protected $output;
/**
* Flag to indicate if command requires a BD connection.
* Flag to indicate if command requires a DB connection.
*
* @var boolean
*/
protected $requires_db = true;
/**
* Flag to indicate if command requires an up-to-date DB.
*
* @var boolean
*/
protected $requires_db_up_to_date = true;
protected function initialize(InputInterface $input, OutputInterface $output) {
$this->input = $input;
......@@ -198,4 +205,9 @@ abstract class AbstractCommand extends Command implements GlpiCommandInterface {
return true;
}
public function requiresUpToDateDb(): bool {
return $this->requires_db && $this->requires_db_up_to_date;
}
}
......@@ -66,6 +66,13 @@ class Application extends BaseApplication {
*/
const ERROR_MISSING_REQUIREMENTS = 128; // start application codes at 128 be sure to be different from commands codes
/**
* Error code returned when DB is not up-to-date.
*
* @var integer
*/
const ERROR_DB_OUTDATED = 129;
/**
* Pointer to $CFG_GLPI.
* @var array
......@@ -222,6 +229,16 @@ class Application extends BaseApplication {
$begin_time = microtime(true);
if ($command instanceof GlpiCommandInterface && $command->requiresUpToDateDb()
&& (!array_key_exists('dbversion', $this->config) || (trim($this->config['dbversion']) != GLPI_SCHEMA_VERSION))) {
$output->writeln(
'<error>'
. __('The version of the database is not compatible with the version of the installed files. An update is necessary.')
. '</error>'
);
return self::ERROR_DB_OUTDATED;
}
if ($command instanceof GlpiCommandInterface && $command->mustCheckMandatoryRequirements()
&& !$this->checkCoreMandatoryRequirements()) {
return self::ERROR_MISSING_REQUIREMENTS;
......
......@@ -39,9 +39,16 @@ if (!defined('GLPI_ROOT')) {
interface GlpiCommandInterface {
/**
* Defines whether or mandatory requirements must be checked before running command.
* Defines whether or not mandatory requirements must be checked before running command.
*
* @return boolean
*/
public function mustCheckMandatoryRequirements(): bool;
/**
* Defines whether or not command requires an up-to-date database to be executed.
*
* @return boolean
*/
public function requiresUpToDateDb(): bool;
}
......@@ -92,6 +92,8 @@ abstract class AbstractConfigureCommand extends AbstractCommand implements Force
*/
const ERROR_DB_CONFIG_FILE_NOT_SAVED = 4;
protected $requires_db_up_to_date = false;
protected function configure() {
parent::configure();
......
......@@ -63,6 +63,8 @@ class UpdateCommand extends AbstractCommand implements ForceNoPluginsOptionComma
*/
const ERROR_MISSING_SECURITY_KEY_FILE = 2;
protected $requires_db_up_to_date = false;
protected function configure() {
parent::configure();
......
......@@ -43,6 +43,8 @@ use Symfony\Component\Console\Output\OutputInterface;
class DisableMaintenanceModeCommand extends AbstractCommand {
protected $requires_db_up_to_date = false;
protected function configure() {
parent::configure();
......
......@@ -44,6 +44,8 @@ use Symfony\Component\Console\Output\OutputInterface;
class EnableMaintenanceModeCommand extends AbstractCommand {
protected $requires_db_up_to_date = false;
protected function configure() {
parent::configure();
......
......@@ -42,6 +42,8 @@ use Symfony\Component\Console\Output\OutputInterface;
class ClearCacheCommand extends Command {
protected $requires_db_up_to_date = false;
protected function configure() {
parent::configure();
......
......@@ -2061,18 +2061,18 @@ class MailCollector extends CommonDBTM {
if (!$part->getHeaders()->has('content-type')
|| !(($content_type = $part->getHeader('content-type')) instanceof ContentType)
| preg_match('/^text\//', $content_type->getType()) !== 1) {
|| preg_match('/^text\//', $content_type->getType()) !== 1) {
return $contents; // No charset conversion content type header is not set or content is not text/*
}
$charset = $content_type->getParameter('charset');
if (strtoupper($charset) != 'UTF-8') {
if (in_array($charset, array_map('strtoupper', mb_list_encodings()))) {
if ($charset !== null && strtoupper($charset) != 'UTF-8') {
if (in_array(strtoupper($charset), array_map('strtoupper', mb_list_encodings()))) {
$contents = mb_convert_encoding($contents, 'UTF-8', $charset);
} else {
// Convert Windows charsets names
if (preg_match('/^WINDOWS-\d{4}$/', $charset)) {
$charset = preg_replace('/^WINDOWS-(\d{4})$/', 'CP$1', $charset);
if (preg_match('/^WINDOWS-\d{4}$/i', $charset)) {
$charset = preg_replace('/^WINDOWS-(\d{4})$/i', 'CP$1', $charset);
}
if ($converted = iconv($charset, 'UTF-8//TRANSLIT', $contents)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment