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

Problem with a fully numeric username. #26

Open
ghost opened this issue Aug 24, 2016 · 2 comments
Open

Problem with a fully numeric username. #26

ghost opened this issue Aug 24, 2016 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 24, 2016

Hello,

We are working to use Shibboleth plugin in our project and while testing mapping I noticed that numeric only username is not working correctly : The account get created the first time but the pluggin cannot get the user account on the second access.

               $username = $_SERVER[$shib_headers['username']['name']];
               $user = new WP_User($username);

By exemple, $username is '020201', the account exist (as seen through Wordpress admin) but new WP_User return a user 0 (not existing).

I investigated a bit and I think the problem is that new WP_User($username); and it's implementation is conflictual.

Usually the id (record id if I'm right) is the first parameter ( WP_User( $id [, $name [, $blog_id ] ] ); ) but there is a chunk of code in class-wp-user.php that redirect $id to $name if the parameter is not fully numeric (which make the call in Shibboleth works most of the time from what I understand). In our case, that means that Worpress try to find a user having the $id corresponding to the same value as $username.

                if ( ! empty( $id ) && ! is_numeric( $id ) ) {
                        $name = $id;
                        $id = 0;
                }

Is there a voluntary scenario where Shibboleth Pluggin would have to work with worpress table user id? Maybe it should always work with username? If it's the case, maybe the code should be changed to (the documentation talk about empty, not sure if it's null or string empty that should be used).:

$user = new WP_User('', $username);

We can patch the problem by prefixing our id with a non-numeric part (or similar solutions) or handle our own local patch but I would think that the Shibboleth plugin could be corrected for this relatively minor issue.

Someone has a take on this?

Thanks for the plugin!

@ghost
Copy link
Author

ghost commented Aug 24, 2016

Oups! Sorry, I just noticed that there is actually a pull request for this exact same problem (#9).

@michaelryanmcneill
Copy link

Hello, thank you for reporting this issue. I released version 1.8 today to resolve this and other issues. I am the new maintainer of the plugin and all further work on the plugin will be done in a new GitHub repository. If you have any further issues, please don't hesitate to report them in the new repository.

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