Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
XONOSNET opened this issue Jan 25, 2018 · 0 comments

Comments

@XONOSNET
Copy link

XONOSNET commented Jan 25, 2018

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
    );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant