Skip to content

A free open source IT asset/license management system

Fix PHP 7.4 deprecation warnings in ldap-sync script.

Brady Wetheringtonb721a977c002
diff --git a/app/Console/Commands/LdapSync.php b/app/Console/Commands/LdapSync.php
index 006d407e1d..9b0365f630 100644
--- a/app/Console/Commands/LdapSync.php
+++ b/app/Console/Commands/LdapSync.php
@@ -110,6 +110,8 @@ class LdapSync extends Command
{
ini_set('max_execution_time', '600'); //600 seconds = 10 minutes
ini_set('memory_limit', '500M');
+ $old_error_reporting = error_reporting(); // grab old error_reporting .ini setting, for later re-enablement
+ error_reporting($old_error_reporting & ~E_DEPRECATED); // disable deprecation warnings, for LDAP in PHP 7.4 (and greater)
if ($this->option('dryrun')) {
$this->dryrun = true;
@@ -132,6 +134,7 @@ class LdapSync extends Command
$this->table($headers, $this->summary->toArray());
}
+ error_reporting($old_error_reporting); // re-enable deprecation warnings.
return $this->getSummary();
}