From ae18178d5641abf01f10ae80334143e8dfdd920a Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 21 Jul 2016 18:21:09 +0200 Subject: [PATCH 1/5] Fix Performance improvement with many extrafields --- htdocs/societe/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e9b98ad7164..7c44d8a9e29 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2015 Florian Henry + * Copyright (C) 2016 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -352,16 +353,17 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays) "; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent) "; $sql.= " ,".MAIN_DB_PREFIX."c_stcomm as st"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " , ".MAIN_DB_PREFIX."societe_extrafields as ef "; // We'll need this table joined to the select in order to filter by sale if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_".($type=='f'?"fournisseur":"societe")." as cs"; $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " AND s.rowid = ef.fk_object"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale From 5bbd8eded902724d6ef939a1bb4a44de58bace63 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Jul 2016 18:32:45 +0200 Subject: [PATCH 2/5] Code comment --- htdocs/compta/facture/class/facture.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 33d6e23c6b3..5c0a5f22391 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -387,8 +387,8 @@ class Facture extends CommonInvoice { $newinvoiceline=$this->lines[$i]; $newinvoiceline->fk_facture=$this->id; - $newinvoiceline->origin = $this->element; - $newinvoiceline->origin_id = $this->lines[$i]->id; + $newinvoiceline->origin = $this->element; // TODO This seems not used. Here we but origin 'facture' but after + $newinvoiceline->origin_id = $this->lines[$i]->id; // we put an id of object ! if ($result >= 0 && ($newinvoiceline->info_bits & 0x01) == 0) // We keep only lines with first bit = 0 { // Reset fk_parent_line for no child products and special product From a9d75b2c9142cb1c0ffbc264e2133898d1ad021f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 25 Jul 2016 11:49:04 +0200 Subject: [PATCH 3/5] FIX #5537 AJAX project search does not work properly --- htdocs/core/class/html.formprojet.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 01b22d3b514..d93e6c657b9 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -140,8 +140,8 @@ class FormProjets if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc IS NULL)"; if (!empty($filterkey)) { - $sql .= ' AND p.title LIKE "%'.$this->db->escape($filterkey).'%"'; - $sql .= ' OR p.ref LIKE "%'.$this->db->escape($filterkey).'%"'; + $sql .= " AND p.title LIKE '%".$this->db->escape($filterkey)."%'"; + $sql .= " OR p.ref LIKE '%".$this->db->escape($filterkey)."%'"; } $sql.= " ORDER BY p.ref ASC"; From 3029fd0fe134887e38d28e970d8a8de614f5be7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 25 Jul 2016 13:18:41 +0200 Subject: [PATCH 4/5] FIX #5540 getFormMail is not registered as addReplace hook --- htdocs/core/class/hookmanager.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index e2de6e61c86..3f3fbb4f409 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -167,7 +167,8 @@ class HookManager 'printObjectLine', 'printObjectSubLine', 'createDictionaryFieldList', - 'editDictionaryFieldlist' + 'editDictionaryFieldlist', + 'getFormMail' ) )) $hooktype='addreplace'; // Deprecated hook types ('returnvalue') From fc1c38420cb79adecc529bd191d97bcf8c9e210c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 25 Jul 2016 19:47:07 +0200 Subject: [PATCH 5/5] Revert "Fix Performance improvement with many extrafields" This reverts commit ae18178d5641abf01f10ae80334143e8dfdd920a. --- htdocs/societe/list.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 7c44d8a9e29..e9b98ad7164 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -5,7 +5,6 @@ * Copyright (C) 2012 Marcos García * Copyright (C) 2013-2015 Raphaël Doursenaud * Copyright (C) 2015 Florian Henry - * Copyright (C) 2016 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -353,17 +352,16 @@ $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef on (s.rowid = ef.fk_object)"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays) "; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent) "; $sql.= " ,".MAIN_DB_PREFIX."c_stcomm as st"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " , ".MAIN_DB_PREFIX."societe_extrafields as ef "; // We'll need this table joined to the select in order to filter by sale if ($search_sale || (!$user->rights->societe->client->voir && !$socid)) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_".($type=='f'?"fournisseur":"societe")." as cs"; $sql.= " WHERE s.fk_stcomm = st.id"; $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; -if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " AND s.rowid = ef.fk_object"; if (! $user->rights->societe->client->voir && ! $socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND s.rowid = ".$socid; if ($search_sale) $sql.= " AND s.rowid = sc.fk_soc"; // Join for the needed table to filter by sale