From cd9f51b83067756d3abeeacae1b68d5c7409f886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come@opensides.be> Date: Tue, 13 Mar 2018 14:42:17 +0100 Subject: [PATCH] Merge branch '5789-ldif-import-can-trigger-php-errors-on-empty-file' into '1.3-dev' Resolve "LDIF import can trigger PHP errors on empty file" Closes #5789 See merge request fusiondirectory/fd!160 (cherry picked from commit f4c6e74478113b2ebcd7c68a1b05becba43ad6e0) f052e1c9 :ambulance: fix(ldap) Return number of entry imported and avoid PHP errors --- include/class_ldap.inc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/class_ldap.inc b/include/class_ldap.inc index 2a55657e1..e5a11108c 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -1052,8 +1052,9 @@ class LDAP } /* Joining lines */ - $line = NULL; - $entry = array(); + $line = NULL; + $entry = array(); + $entries = array(); $entryStart = -1; foreach ($fileLines as $lineNumber => $fileLine) { if (preg_match('/^ /', $fileLine)) { @@ -1123,6 +1124,8 @@ class LDAP throw new LDIFImportException(sprintf(_('Error while importing dn: "%s", please check your LDIF from line %s on!'), $entry['dn'][0], $startLine)); } } + + return count($entries); } /*! \brief Function to Imports a single entry -- GitLab