From 18012279f993733752d84cd311acbba1626eb084 Mon Sep 17 00:00:00 2001 From: Brady Wetherington Date: Thu, 22 Oct 2020 21:51:23 -0700 Subject: [PATCH] Possible fix to #8563 - unset $ldapUsers to avoid OOM'ing --- app/Console/Commands/LdapSync.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php index 16f04f16be..57baaa83b0 100644 --- a/app/Console/Commands/LdapSync.php +++ b/app/Console/Commands/LdapSync.php @@ -117,7 +117,7 @@ class LdapSync extends Command $this->dryrun = true; } $this->checkIfLdapIsEnabled(); - $this->checkLdapConnetion(); + $this->checkLdapConnection(); $this->setBaseDn(); $this->getUserDefaultLocation(); /* @@ -247,7 +247,9 @@ class LdapSync extends Command } 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 */ - private function checkLdapConnetion(): void + private function checkLdapConnection(): void { try { $this->ldap->testLdapAdUserConnection();