Page MenuHomePhabricator

MediaWikiAuth extension: "Undefined property stdClass::$clientlogin" error on new user login
Open, Needs TriagePublic

Description

When trying to login with a user only existing in remote wiki, but not in the local one, the extension MediaWikiAuth returns the error

Notice: Undefined property: stdClass::$clientlogin in /path/extensions/MediaWikiAuth/ExternalWikiPrimaryAuthenticationProvider.php on line 157

(where path is the correct path of the Mediawiki installation).
The error does not occur if the user already exist on the local wiki.

This happens because $resp->status needs to be polled for return code of the API, not $resp->clientlogin->status as currently written.
I am proposing a small code change to address this issue

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 18 2020, 10:46 PM

The Gerrit patch was not automatically referenced here, so here's the link https://gerrit.wikimedia.org/r/c/mediawiki/extensions/MediaWikiAuth/+/565738

The Gerrit patch was not automatically referenced here

From memory, Thats caused by the blank line in between the Bug: and ChangeId line.

Change 565738 had a related patch set uploaded (by Luca Mauri; owner: Luca Mauri):
[mediawiki/extensions/MediaWikiAuth@master] Fix Respnse Status check in MediaWikiAuth

https://gerrit.wikimedia.org/r/565738

In T243134#5815072, @Peachey88 wrote:
From memory, Thats caused by the blank line in between the Bug: and ChangeId line.

Indeed that was the reason, I just fixed it, thanks!

Skizzerz added a subscriber: Skizzerz.EditedJan 19 2020, 7:12 PM

The code is fetching the correct properties; all successful API responses have a top-level element equal to the action specified in the request.

Please enable debug logging so that we can better determine exactly what the API is returning for your scenario. I suspect that the remote API is returning an error response, which the code is not currently set up to handle (and would cause the notice you are experiencing).

Once you have the details of what the remote API is returning, post them here and we can diagnose this further. If you're having troubles enabling this logging, I have some work in progress to gracefully handle API errors and display them to the end user, which I should hopefully be able to get out sometime this next week as a point release.

Please enable debug logging so that we can better determine exactly what the API is returning for your scenario. I suspect that the remote API is returning an error response, which the code is not currently set up to handle (and would cause the notice you are experiencing).

I will surely try to figure this out tomorrow and keep you posted.

Once you have the details of what the remote API is returning, post them here and we can diagnose this further. If you're having troubles enabling this logging, I have some work in progress to gracefully handle API errors and display them to the end user, which I should hopefully be able to get out sometime this next week as a point release.

Please let us know of this release anyway, thanks :-)

Please let us know of this release anyway, thanks :-)

Please follow https://lists.wikimedia.org/pipermail/mediawiki-announce/ for release announcements.

I wasn't aware announcements were posted to that list for point releases of non-WMF-deployed extensions, @Aklapper 😛

Argh, sorry for that. You are right! I somehow misread it as referring to a MediaWiki core release...

lucamauri added a comment.EditedJan 20 2020, 10:20 PM

Please enable debug logging so that we can better determine exactly what the API is returning for your scenario. I suspect that the remote API is returning an error response, which the code is not currently set up to handle (and would cause the notice you are experiencing).

As agreed I enabled logging and following please find the result:

[session] SessionBackend "9fn8d3edglgphqa60fkutpcdkrf0ssd6" data dirty due to dirty(): AuthManagerSpecialPage->performAuthenticationStep/MediaWiki\Auth\AuthManager->beginAuthentication/MediaWiki\Auth\AuthManager->removeAuthenticationSessionData/MediaWiki\Session\Session->remove/MediaWiki\Session\SessionBackend->dirty
[session] SessionBackend "9fn8d3edglgphqa60fkutpcdkrf0ssd6" save: dataDirty=1 metaDirty=0 forcePersist=0
[session] SessionBackend "9fn8d3edglgphqa60fkutpcdkrf0ssd6" data dirty due to dirty(): MediaWiki\Auth\ThrottlePreAuthenticationProvider->testForAuthentication/MediaWiki\Auth\AuthManager->setAuthenticationSessionData/MediaWiki\Session\Session->setSecret/MediaWiki\Session\Session->set/MediaWiki\Session\SessionBackend->dirty
[session] SessionBackend "9fn8d3edglgphqa60fkutpcdkrf0ssd6" save: dataDirty=1 metaDirty=0 forcePersist=0
[session] SessionBackend "9fn8d3edglgphqa60fkutpcdkrf0ssd6" data dirty due to dirty(): AuthManagerSpecialPage->performAuthenticationStep/MediaWiki\Auth\AuthManager->beginAuthentication/MediaWiki\Session\Session->setSecret/MediaWiki\Session\Session->set/MediaWiki\Session\SessionBackend->dirty
[session] SessionBackend "9fn8d3edglgphqa60fkutpcdkrf0ssd6" save: dataDirty=1 metaDirty=0 forcePersist=0
[DBQuery] MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProvider::beginPrimaryAuthentication [0s] localhost: SELECT  user_id,user_newpassword,user_newpass_time  FROM `user`    WHERE user_name = 'Lucamauri'  LIMIT 1  
[DBQuery] User::load [0s] localhost: SELECT  actor_id,actor_user,actor_name  FROM `actor`    WHERE actor_name = 'Lucamauri'  LIMIT 1  
[session] SessionBackend "9fn8d3edglgphqa60fkutpcdkrf0ssd6" data dirty due to dirty(): MediaWikiAuth\ExternalWikiPrimaryAuthenticationProvider->beginPrimaryAuthentication/MediaWiki\Auth\AuthManager->setAuthenticationSessionData/MediaWiki\Session\Session->setSecret/MediaWiki\Session\Session->set/MediaWiki\Session\SessionBackend->dirty
[error] [6d5be99442f7b88507e790e2] /datatrek/index.php?title=Speciale:Entra&returnto=Pagina+principale   ErrorException from line 157 of /var/www/html/datatrek/extensions/MediaWikiAuth/ExternalWikiPrimaryAuthenticationProvider.php: PHP Notice: Undefined property: stdClass::$clientlogin
#0 /var/www/html/datatrek/extensions/MediaWikiAuth/ExternalWikiPrimaryAuthenticationProvider.php(157): MWExceptionHandler::handleError(integer, string, string, integer, array)
#1 /var/www/html/datatrek/includes/auth/AuthManager.php(458): MediaWikiAuth\ExternalWikiPrimaryAuthenticationProvider->beginPrimaryAuthentication(array)
#2 /var/www/html/datatrek/includes/auth/AuthManager.php(388): MediaWiki\Auth\AuthManager->continueAuthentication(array)
#3 /var/www/html/datatrek/includes/specialpage/AuthManagerSpecialPage.php(354): MediaWiki\Auth\AuthManager->beginAuthentication(array, string)
#4 /var/www/html/datatrek/includes/specialpage/AuthManagerSpecialPage.php(484): AuthManagerSpecialPage->performAuthenticationStep(string, array)
#5 /var/www/html/datatrek/includes/htmlform/HTMLForm.php(690): AuthManagerSpecialPage->handleFormSubmit(array, VFormHTMLForm)
#6 /var/www/html/datatrek/includes/specialpage/AuthManagerSpecialPage.php(417): HTMLForm->trySubmit()
#7 /var/www/html/datatrek/includes/specialpage/LoginSignupSpecialPage.php(313): AuthManagerSpecialPage->trySubmit()
#8 /var/www/html/datatrek/includes/specialpage/SpecialPage.php(575): LoginSignupSpecialPage->execute(NULL)
#9 /var/www/html/datatrek/includes/specialpage/SpecialPageFactory.php(611): SpecialPage->run(NULL)
#10 /var/www/html/datatrek/includes/MediaWiki.php(296): MediaWiki\Special\SpecialPageFactory->executePath(Title, RequestContext)
#11 /var/www/html/datatrek/includes/MediaWiki.php(900): MediaWiki->performRequest()
#12 /var/www/html/datatrek/includes/MediaWiki.php(527): MediaWiki->main()
#13 /var/www/html/datatrek/index.php(44): MediaWiki->run()
#14 {main}

This the error generated when a non existing user tries to login.

I am not sure this is really providing more information to you. Just let me know if i can provide any more information useful to the investigation.

@Skizzerz may I ask if you have any news on this issue?
Was the log useful? Do you need any other information to further investigate the problem?
Is there anything else I can help with?

@lucamauri Sorry for the delay in response, got sidetracked with a lot of other stuff. That log is unfortunately not useful as it doesn't contain any of the API requests or responses. You can either try enabling the http debug log group, or enable the debug toolbar which also logs those requests/responses. Just be aware that the request will include things like plaintext passwords and auth tokens; you'll want to redact that from the log before posting it anywhere.