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

PHP Notice: Undefined offset: 2 #115

Open
yarosdev opened this issue Jul 26, 2016 · 4 comments
Open

PHP Notice: Undefined offset: 2 #115

yarosdev opened this issue Jul 26, 2016 · 4 comments

Comments

@yarosdev
Copy link

yarosdev commented Jul 26, 2016

When user is member of multiple groups.

After research, I fiund out that $i <= $attributes[$key]['count'] should be rewritten $i < $attributes[$key]['count']

adldap\adldap\src\Objects\Ldap\Entry.php at line 52

        $keys = array_keys($attributes);

        foreach ($keys as $key) {
            if (is_array($attributes[$key]) && array_key_exists(0, $attributes[$key])) {
                // If the entry has multiple attributes, we'll make sure we loop through each one
                if (array_key_exists('count', $attributes[$key]) && $attributes[$key]['count'] > 1) {
                    $data = [];

                    for ($i = 0; $i <= $attributes[$key]['count']; $i++) {
                       $data[] = $attributes[$key][$i]; // LINE 52
                    }

                    $this->setAttribute($key, array_filter($data));
                } else {
                    // Looks like only one attribute exists, let's set it
                    $this->setAttribute($key, $attributes[$key][0]);
                }
            }
        }
@jonathanjuursema
Copy link

I had the same issue, and the fix works for me as well!

@ellej16
Copy link

ellej16 commented Feb 6, 2017

Hi @jonathanjuursema , @Yarisrespect , has this been fixed on the repository or not?

Just so future devs wouldnt encounter this.
The fix works for me as well.

Cheers!

@strebl
Copy link

strebl commented Feb 6, 2017

This repo is dead! Use Adldap2/Adldap2 instead.
Not to hard to migrate 👌🏻

@jonathanjuursema
Copy link

Good to know. It seems we have already migrated away from this repo. :)

blackburn2 added a commit to blackburn2/adLDAP that referenced this issue Sep 4, 2018
Fixing PHP Notice: Undefined offset as explained here: adldap#115
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

4 participants