Skip to content

[FIX] Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead #138

Description

@XONOSNET

I just wanted to document this fix because I know it can be annoying when testing/debugging. For those of you that are trying to use the older adLDAP library with newer versions of PHP, the following warning will often occur.

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in lib\adLDAP\classes\adLDAPUtils.php on line 105

To fix this, navigate to the adLDAP\classes\adLDAPUtils.php file and modify the following:

Line: 102

public function ldapSlashes($str){
    return preg_replace('/([\x00-\x1F\*\(\)\\\\])/e',
                        '"\\\\\".join("",unpack("H2","$1"))',
                        $str);
}

Change to this:

public function ldapSlashes($str){
    return preg_replace_callback('/([\x00-\x1F\*\(\)\\\\])/',
        function($matches) {
            foreach($matches as $match) {
                return join("", unpack("H2","$1"));
            }
        }, $str
    );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions