diff --git a/install/migrations/update_11.0.3_to_11.0.5/entities.php b/install/migrations/update_11.0.3_to_11.0.5/entities.php index 40bd1ffa909..68e479621ea 100644 --- a/install/migrations/update_11.0.3_to_11.0.5/entities.php +++ b/install/migrations/update_11.0.3_to_11.0.5/entities.php @@ -43,8 +43,10 @@ // Fix glpi_entities.id column to use AUTO_INCREMENT instead of DEFAULT 0 // This is required for concurrent entity creation to work properly // see #22625 -// Add NO_AUTO_VALUE_ON_ZERO to allow operations on entities with id=0 (root entity) -$DB->doQuery("SET SESSION sql_mode = CONCAT(@@sql_mode, ',NO_AUTO_VALUE_ON_ZERO')"); +// Add NO_AUTO_VALUE_ON_ZERO to allow operations on entities with id=0 (root entity). +// Use IF() to handle the case where @@sql_mode is empty, as CONCAT would produce a +// malformed string starting with a comma, causing the SET SESSION to fail silently. +$DB->doQuery("SET SESSION sql_mode = IF(@@sql_mode = '', 'NO_AUTO_VALUE_ON_ZERO', CONCAT(@@sql_mode, ',NO_AUTO_VALUE_ON_ZERO'))"); $DB->doQuery( "ALTER TABLE `glpi_entities` MODIFY `id` INT unsigned NOT NULL AUTO_INCREMENT"