Commit cd9f51b8 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

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 f4c6e744)

f052e1c9 :ambulance: fix(ldap) Return number of entry imported and avoid PHP errors
Showing with 5 additions and 2 deletions
+5 -2
...@@ -1052,8 +1052,9 @@ class LDAP ...@@ -1052,8 +1052,9 @@ class LDAP
} }
/* Joining lines */ /* Joining lines */
$line = NULL; $line = NULL;
$entry = array(); $entry = array();
$entries = array();
$entryStart = -1; $entryStart = -1;
foreach ($fileLines as $lineNumber => $fileLine) { foreach ($fileLines as $lineNumber => $fileLine) {
if (preg_match('/^ /', $fileLine)) { if (preg_match('/^ /', $fileLine)) {
...@@ -1123,6 +1124,8 @@ class LDAP ...@@ -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)); 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 /*! \brief Function to Imports a single entry
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment