leenooks / phpLDAPadmin

phpLDAPadmin - Web based LDAP administration tool
www.phpldapadmin.org
GNU General Public License v2.0
548 stars 170 forks source link

Unrecognized error number: 8192: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated #237

Open mvvvmd opened 1 year ago

mvvvmd commented 1 year ago

Describe the bug When changing a user gidNumber I got the following error, the change was not made. This is on php 8.2, fix included in the report, i am not a developer and created the fix using ChatGPT.

Unrecognized error number: 8192: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated

To Reproduce Steps to reproduce the behavior:

  1. Go to a user record
  2. Change the gidNumber
  3. Apply the change
  4. See error

Expected behavior The change should be made.

LDAP Server details (please complete the following information):

Additional context

This error is on php 8.2, I resolved the issue by changing a function in lib/PageRender.php starting on line 920 to:

protected function getAutoPostPasswordAttribute($attribute, $i) {
                // Extract the string data from the PasswordAttribute object
                $attributeString = $attribute->getValue(0);  // Using index 0 as an example

                // If the attribute is null or already encoded, return early
                if ($attributeString === null || preg_match('/^\{.+\}.+/', $attributeString)) {
                return;
        }

        // Otherwise, proceed with password encryption and post
        $attribute->setPostValue(array('function'=>'PasswordEncrypt','args'=>sprintf('%%enc%%;%%%s%%', $attribute->getName())));
        $this->get('Post', $attribute, $i);
}
williamdes commented 1 year ago

What version of phpLDAPadmin are you using ?

mvvvmd commented 1 year ago

The latest from this repo, v1.2.6.6

williamdes commented 1 year ago

Thank you! By the way the phpldapadmin package is available in newer Debian/Ubuntu versions.

Farhanbruh commented 10 months ago

hello, i am new to linux. I was facing the same problem but instead of "parameter #2", my error shows "parameter #1". Should i follow the same solution given here or does anything have to be different?