Merge branch 'integrations/rc5-4-2020-08-31-dev-into-master' into develop

This commit is contained in:
snipe 2020-09-09 12:27:01 -07:00
commit b258f34bce
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC
3 changed files with 39 additions and 28 deletions

View file

@ -57,7 +57,7 @@ class LdapAd extends LdapAdConfiguration
public function init()
{
// Already initialized
if($this->ldap) {
if ($this->ldap) {
return true;
}

View file

@ -52,10 +52,19 @@ class LdapAdConfiguration
* @since 5.0.0
*/
public function init() {
// This try/catch is dumb, but is necessary to run initial migrations, since
// this service provider is booted even during migrations. :( - snipe
try {
$this->ldapSettings = $this->getSnipeItLdapSettings();
if ($this->isLdapEnabled()) {
$this->setSnipeItConfig();
}
} catch (\Exception $e) {
\Log::debug($e);
$this->ldapSettings = null;
}
}
/**
@ -82,6 +91,8 @@ class LdapAdConfiguration
*/
private function getSnipeItLdapSettings(): Collection
{
$ldapSettings = collect();
if(Setting::first()) { // during early migration steps, there may be no settings table entry to start with
$ldapSettings = Setting::getLdapSettings()
->map(function ($item, $key) {
// Trim the items
@ -108,7 +119,7 @@ class LdapAdConfiguration
return $item;
});
}
return $ldapSettings;
}

View file

@ -19,7 +19,7 @@ class AddAdAppendDomainSettings extends Migration
});
$s = Setting::first(); // we are deliberately *not* using the ::getSettings() method, as it caches things, and our Settings table is being migrated right now
if($s->is_ad && $s->ldap_enabled && $s->ad_domain) { //backwards-compatibility setting; < v5 always appended AD Domains
if ($s && $s->is_ad && $s->ldap_enabled && $s->ad_domain) { //backwards-compatibility setting; < v5 always appended AD Domains
$s->ad_append_domain = 1;
$s->save();
}