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

auth/ldap: add commandline script #315

Merged
merged 22 commits into from
Oct 17, 2017
Merged

Conversation

glensc
Copy link
Member

@glensc glensc commented Oct 10, 2017

No description provided.

@glensc glensc self-assigned this Oct 10, 2017
@glensc
Copy link
Member Author

glensc commented Oct 10, 2017

here's interesting problem i encountered.

appears Zend\Config approach of merging array's key integer values means append whatever is merged into: src/Config.php:334-335

this resulted each time when ldap preferences were saved default_role to grow:

  'default_role' =>                                                                                                      
  array (                                                                                                                
    1 => '2',                                                                                                            
    2 => '2',                                                                                                            
    3 => '2',                                                                                                            
    4 => '2',                                                                                                            
    5 => '2',                                                                                                            
    6 => '2',                                                                                                            
  ),

src/Controller/Manage/LdapController.php:79

even if data what was actually saved was just two entries.

so i came up with this method, to have string type of array keys. unfortunately that only did not solve the problem, so the method not committed, but saving here for future times.

    /**
     * ensure keys are type string,
     * as Zend\Config would otherwise append values when merging
     *
     * @param array $array
     * @return array
     * @link https://stackoverflow.com/a/35180513/2314626
     */
    private function stringifyKeys($array)
    {
        $obj = (object)[];
        foreach ($array as $key => $value) {
            $obj->{(string)$key} = $value;
        }

        return (array)$obj;
    }

@glensc glensc changed the title WIP: Auth ldap changes auth/ldap: add commandline script Oct 17, 2017
@glensc glensc added this to the 3.3.3 milestone Oct 17, 2017
@glensc glensc merged commit 1bdc655 into eventum:master Oct 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant