Merge pull request #8594 from uberbrady/try_to_fix_ldap_oom

Possible fix to #8563 - unset $ldapUsers to avoid OOM'ing
This commit is contained in:
Brady Wetherington 2020-10-23 14:23:53 -07:00 committed by GitHub
commit d517e2fd61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -117,7 +117,7 @@ class LdapSync extends Command
$this->dryrun = true; $this->dryrun = true;
} }
$this->checkIfLdapIsEnabled(); $this->checkIfLdapIsEnabled();
$this->checkLdapConnetion(); $this->checkLdapConnection();
$this->setBaseDn(); $this->setBaseDn();
$this->getUserDefaultLocation(); $this->getUserDefaultLocation();
/* /*
@ -247,7 +247,9 @@ class LdapSync extends Command
} }
if ($ldapUsers->getCurrentPage() < $ldapUsers->getPages()-1) { if ($ldapUsers->getCurrentPage() < $ldapUsers->getPages()-1) {
$this->processLdapUsers($ldapUsers->getCurrentPage() + 1); $current_page = $ldapUsers->getCurrentPage();
unset($ldapUsers); //deliberately unset the variable so we don't OOM
$this->processLdapUsers($current_page + 1); //this recursive call means that the $ldapUsers variable is not going to get GC'ed until everything returns. Blech.
} }
} }
@ -355,7 +357,7 @@ class LdapSync extends Command
* *
* @since 5.0.0 * @since 5.0.0
*/ */
private function checkLdapConnetion(): void private function checkLdapConnection(): void
{ {
try { try {
$this->ldap->testLdapAdUserConnection(); $this->ldap->testLdapAdUserConnection();