From ad5dd8e70f559205a80e5cb5fbb6131011ec89da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 20 Apr 2015 01:36:48 +0200 Subject: [PATCH] [ bug #1897 ] PHP Fatal error when editing Margin module settings with USER_UPDATE_SESSION trigger turned on --- ChangeLog | 1 + htdocs/main.inc.php | 22 +++++++++------------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e2babf155f..10796fa9f34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -178,6 +178,7 @@ Dolibarr better: - A lot of pages called liste.php were renamed into list.php - If you used warehouse/stock module, recheck setup of stock increase/decrease rules of the warehouse module and your Point Of Sale module if you use one. +- Replaced USER_UPDATE_SESSION trigger with an updateSession hook ***** ChangeLog for 3.6.3 compared to 3.6.2 ***** - Fix: ref_ext was not saved when recording a customer order from web service diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index a85959cb935..17395fd3de9 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -9,7 +9,7 @@ * Copyright (C) 2008 Matteli * Copyright (C) 2011-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2014 Marcos García + * Copyright (C) 2014-2015 Marcos García * * 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 @@ -575,18 +575,14 @@ if (! defined('NOLOGIN')) } else { - if (! empty($conf->global->MAIN_ACTIVATE_UPDATESESSIONTRIGGER)) // We do not execute such trigger at each page load by default (triggers are time consuming) - { - // TODO We should use a hook here, not a trigger. - // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('USER_UPDATE_SESSION',$user,$user,$langs,$conf); - if ($result < 0) { - $error++; - } - // End call triggers - } + // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array + $hookmanager->initHooks(array('main')); + + $action = ''; + $reshook = $hookmanager->executeHooks('updateSession', array(), $user, $action); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } } }