Skip to content

Commit d517e2f

Browse files
authored
Merge pull request #8594 from uberbrady/try_to_fix_ldap_oom
Possible fix to #8563 - unset $ldapUsers to avoid OOM'ing
2 parents 6ee3d0e + 1801227 commit d517e2f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/Console/Commands/LdapSync.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function handle()
117117
$this->dryrun = true;
118118
}
119119
$this->checkIfLdapIsEnabled();
120-
$this->checkLdapConnetion();
120+
$this->checkLdapConnection();
121121
$this->setBaseDn();
122122
$this->getUserDefaultLocation();
123123
/*
@@ -247,7 +247,9 @@ private function processLdapUsers(int $page=0): void
247247
}
248248

249249
if ($ldapUsers->getCurrentPage() < $ldapUsers->getPages()-1) {
250-
$this->processLdapUsers($ldapUsers->getCurrentPage() + 1);
250+
$current_page = $ldapUsers->getCurrentPage();
251+
unset($ldapUsers); //deliberately unset the variable so we don't OOM
252+
$this->processLdapUsers($current_page + 1); //this recursive call means that the $ldapUsers variable is not going to get GC'ed until everything returns. Blech.
251253
}
252254
}
253255

@@ -355,7 +357,7 @@ private function checkIfLdapIsEnabled(): void
355357
*
356358
* @since 5.0.0
357359
*/
358-
private function checkLdapConnetion(): void
360+
private function checkLdapConnection(): void
359361
{
360362
try {
361363
$this->ldap->testLdapAdUserConnection();

0 commit comments

Comments
 (0)