From f3ef4fed93cc45bc310b54810ff0198b4121038c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?=
 <marcosgdf@gmail.com>
Date: Sun, 9 Aug 2015 13:58:03 +0200
Subject: [PATCH] Fix: [ bug #3313 ] Error enabling module with PostgreSQL
 database

Close #3313
---
 ChangeLog                                     | 1 +
 htdocs/core/class/menubase.class.php          | 2 +-
 htdocs/core/modules/DolibarrModules.class.php | 3 ---
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6165077d1ca..d3347fc30f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@ Fix: [ bug #2570 ] [Contacts] Page should not process if ID is invalid
 Fix: [ bug #3268 ] SQL error when accessing thirdparty log page without a socid parameter
 Fix: [ bug #3180 ] formObjectOptions hook when editing thirdparty card does not print result
 Fix: [ bug #1791 ] Margin menu not available if any Finance module is not enabled
+Fix: [ bug #3313 ] Error enabling module with PostgreSQL database
 
 ***** ChangeLog for 3.5.6 compared to 3.5.5 *****
 Fix: Avoid missing class error for fetch_thirdparty method #1973
diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php
index 961cfd5733c..570da8b27fa 100644
--- a/htdocs/core/class/menubase.class.php
+++ b/htdocs/core/class/menubase.class.php
@@ -152,7 +152,7 @@ class Menubase
         $sql.= " '".$this->fk_menu."',";
         $sql.= " ".($this->fk_mainmenu?"'".$this->fk_mainmenu."'":"null").",";
         $sql.= " ".($this->fk_leftmenu?"'".$this->fk_leftmenu."'":"null").",";
-        $sql.= " '".$this->position."',";
+        $sql.= " '".(int) $this->position."',";
         $sql.= " '".$this->db->escape($this->url)."',";
         $sql.= " '".$this->db->escape($this->target)."',";
         $sql.= " '".$this->db->escape($this->titre)."',";
diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php
index be498b04413..a9b80cef13e 100644
--- a/htdocs/core/modules/DolibarrModules.class.php
+++ b/htdocs/core/modules/DolibarrModules.class.php
@@ -1009,7 +1009,6 @@ abstract class DolibarrModules
 
         $this->db->begin();
 
-        //var_dump($this->menu); exit;
         foreach ($this->menu as $key => $value)
         {
             $menu = new Menubase($this->db);
@@ -1018,11 +1017,9 @@ abstract class DolibarrModules
             if (! $this->menu[$key]['fk_menu'])
             {
                 $menu->fk_menu=0;
-                //print 'aaa'.$this->menu[$key]['fk_menu'];
             }
             else
             {
-                //print 'xxx'.$this->menu[$key]['fk_menu'];exit;
                 $foundparent=0;
                 $fk_parent=$this->menu[$key]['fk_menu'];
                 if (preg_match('/^r=/',$fk_parent))	// old deprecated method
-- 
GitLab