Projet

Général

Profil

Anomalie #14477

Requête en erreur sur la recherche avancée (utilisateur sans entité)

Ajouté par Henri QUENEAU il y a presque 4 ans. Mis à jour il y a presque 3 ans.

Statut:
Clôturé
Priorité:
2-Sérieux
Version cible:
Début:
20/07/2020
Echéance:
Version applicable MC:
Tags Courrier:

Description

Lorsqu'on recherche un courrier en superadmin, on obtient l'erreur :

Fatal error: Uncaught PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "." LINE 3: resources_folders.res_id = res_letterbox.res_id AND status ... ^ in /var/www/html/MaarchCourrier/core/class/class_db_pdo.php:452 Stack trace: #0 /var/www/html/MaarchCourrier/core/class/class_db_pdo.php(452): PDOStatement->execute(Array) #1 /var/www/html/MaarchCourrier/core/class/class_request.php(169): Database->query('SELECT res_vie...', Array, false) #2 /var/www/html/MaarchCourrier/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php(380): request->PDOselect(Array, '(status not in ...', Array, 'order by res_id...', 'POSTGRESQL', '10', false, '', '', '', false, false, false, 0) #3 /var/www/html/MaarchCourrier/core/class/class_core_tools.php(1258): require('/var/www/html/M...') #4 /var/www/html/MaarchCourrier/apps/maarch_entreprise/index.php(210): core_tools->insert_page() #5 {main} thrown in /var/www/html/MaarchCourrier/core/class/class_db_pdo.php on line 452

En regardant dans le code, on voit qu'on rentre dans le fichier : /var/www/html/MaarchCourrier/apps/maarch_entreprise/indexing_searching/documents_list_mlb_search_adv.php à la ligne 302

        if (\Group\controllers\PrivilegeController::hasPrivilege(['privilegeId' => 'include_folders_and_followed_resources_perimeter', 'userId' => $user['id']])) {
            $whereFollowed = 'res_id in (select res_id from users_followed_resources where user_id = :userSerialId)';

            $whereFolders = 'res_id in (select res_id from resources_folders, folders, entities_folders ';
            $whereFolders .= 'where folders.id = entities_folders.folder_id AND folders.id = resources_folders.folder_id AND (user_id = :userSerialId OR entity_id in (:userEntitiesId)))';
            $entities = \User\models\UserModel::getEntitiesByLogin(['login' => $_SESSION['user']['UserId']]);
            $entities = array_column($entities, 'id');

            $arrayPDO[':userSerialId'] = $user['id'];
            $arrayPDO[':userEntitiesId'] = $entities;
        }

En passant cette condition, on va chercher les entités de superadmin sauf qu'il ne possède pas d'entité. Dans la clause sql qui est appelé, il y a une malformation de la requete:
AND (user_id = :userSerialId OR entity_id in (:userEntitiesId)))
qui génère l'erreur sql ci-dessous (dans les logs de postgresql):

2020-07-20 11:10:28.997 CEST [15809] maarch@garance ERROR:  syntax error at or near "." at character 1332
2020-07-20 11:10:28.997 CEST [15809] maarch@garance STATEMENT:  SELECT  res_view_letterbox.res_id,res_view_letterbox.res_id as is_labeled,res_view_letterbox.alt_identifier,order_alphanum(alt_identifier),res_view_letterbox.priority,res_view_letterbox.status,res_view_letterbox.subject,res_view_letterbox.category_id as category_img,res_view_letterbox.category_id,res_view_letterbox.dest_user,res_view_letterbox.type_label,res_view_letterbox.creation_date,res_view_letterbox.entity_label,res_view_letterbox.res_id as count_attachment,res_view_letterbox.filename,res_view_letterbox.res_id as real_dest, count(1) OVER() AS __full_count FROM res_view_letterbox  WHERE (status not in ($1,$2,$3,$4)) and (( (1=1) ) or ( (  status in ('INIT') and destination in ('') ) or (  destination in ('', 'GARANCE', 'DG', 'DPP', 'DPP_Tout_le_monde', 'DPP_Achat', 'DPP_Compta', 'DAQ', 'DJ', 'DD', 'DRH_RRH', 'DRH_RRH_CRH_CDRH', 'DRH_RRH_CDRH', 'DRH_Formateurs', 'DRH_RRH_CRH', 'DSI', 'DSO', 'DDMC', 'DR', 'SC') and status = 'WAIT') or (  status = 'END' and (DESTINATION in ('') or DESTINATION in ('GARANCE', 'DG', 'DPP', 'DPP_Tout_le_monde', 'DPP_Achat', 'DPP_Compta', 'DAQ', 'DJ', 'DD', 'DRH_RRH', 'DRH_RRH_CRH_CDRH', 'DRH_RRH_CDRH', 'DRH_Formateurs', 'DRH_RRH_CRH', 'DSI', 'DSO', 'DDMC', 'DR', 'SC'))  and (res_id not in (select resources_folders.res_id 
    from resources_folders, res_letterbox 
     resources_folders.res_id = res_letterbox.res_id AND status = 'END')))) OR (res_id in (select res_id from resources_folders, folders, entities_folders where folders.id = entities_folders.folder_id AND folders.id = resources_folders.folder_id AND (user_id = $5 OR entity_id in ()))) OR (res_id in (select res_id from users_followed_resources where user_id = $5))) order by res_id desc  OFFSET 0 LIMIT 500

Historique

#2 Mis à jour par Support Maarch il y a presque 4 ans

  • Statut changé de A qualifier à A traiter

#3 Mis à jour par Emmanuel DILLARD il y a presque 4 ans

  • Sujet changé de erreur sur la recherche avancée à Requête en erreur sur la recherche avancée (utilisateur sans entité)
  • Statut changé de A traiter à R&D - A planifier
  • Assigné à changé de EDI PO à Maarch Courrier DEV TEAM

#4 Mis à jour par Florian AZIZIAN il y a plus de 3 ans

  • Statut changé de R&D - A planifier à Clôturé

Non reproductible sur la démo 20.03.13 avec superadmin.
Et le ticket lié a été mis en résolu chez le client il y a 2 mois. Surement un problème de clause.

#5 Mis à jour par Emmanuel DILLARD il y a presque 3 ans

  • Projet changé de Backlog à Backlog Courrier
  • Version cible changé de 20.03 (Fin de vie) à 20.03 (Sécurité)

Formats disponibles : Atom PDF