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
Fixed issue #18413: Cannot authenticate with LDAP when using PHP 8.1 #2665
Conversation
After upgrading to PHP 8.1 the login via LDAP isn't possible. Error message: Cannot use object of type LDAP\Connection as array This is a fix for it. BugTracker: https://bugs.limesurvey.org/view.php?id=18413
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are issue here : $ldapconn is an array in case of error.
You just avoid the situation here ?
Maybe : if(is_array()) ?
I don't understand why is_resource didn't work here ?
Can you send the whole report on mantis please ?
@@ -480,7 +480,7 @@ public function newUserSession() | |||
|
|||
// Try to connect | |||
$ldapconn = $this->createConnection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can return array or ressource
https://github.com/Dennis1993/LimeSurvey/blob/91006af1e59f8338726dab68cdb8da2915a6372e/application/core/plugins/AuthLDAP/AuthLDAP.php#L340
https://github.com/Dennis1993/LimeSurvey/blob/91006af1e59f8338726dab68cdb8da2915a6372e/application/core/plugins/AuthLDAP/AuthLDAP.php#L351
https://github.com/Dennis1993/LimeSurvey/blob/91006af1e59f8338726dab68cdb8da2915a6372e/application/core/plugins/AuthLDAP/AuthLDAP.php#L361
I found this on Google: https://php.watch/versions/8.1/LDAP-resource @Shnoulle |
Yes, but LimeSurvey can return array before return an invalid ressource. I currently check with invalid user in my test system to report and fix . |
We return an array if |
PS : see this simple code
if $ldapconn === false then $ldapconn['errorCode'] is not set … |
I checked out the latest version from git but the problem isn't fixed for me with PHP 8.1. I still see the same error message "Cannot use object of type LDAP\Connection as array " The error is in line 482:
EDIT: This error also occurs in other places. I think this needs a much more fundamental fix. The problem is that the type of $ldapconn is not unique, it is "misused" as an array - sometimes but not always. Part of the code expects an array, other parts don't. For example, if I remove the first error by adding is_array($ldapconn), then I see another error in line 233
I think this framework should be used instead: |
I fixed those errors and created a pull request: Now I see the following error message:
|
$ldapconn is array when error. Let me fix it again |
After upgrading to PHP 8.1 the login via LDAP isn't possible.
Error message: Cannot use object of type LDAP\Connection as array
This is a fix for it.
Fixed issue #18413 (https://bugs.limesurvey.org/view.php?id=18413)