https://bugzilla.wikimedia.org/show_bug.cgi?id=17425

           Summary: Prtoblem with passing object back from
                    UserLoadFromSession hook
           Product: MediaWiki
           Version: 1.13.0
          Platform: Sun
               URL: http://(internal)
        OS/Version: Solaris
            Status: NEW
          Severity: enhancement
          Priority: Normal
         Component: User login/settings
        AssignedTo: [email protected]
        ReportedBy: [email protected]


I am having a problem with the UserLoadFromSession hook.

In the hook, I use User::newFromName() to obtain the user object and if it's a
new user, I authenticate it with our SSO service and add it to the database;
otherwise I update $user and return, leaving $result as null. I've battled with
this code a fair bit, but have learned from looking at CASAuthentication's use
of this hook and believe that I'm now doing thins "the right way". However,
although $user is set up as expected when I leave the hook, $this in
loadFromSession doesn't contain the values I've set up in the hook. I've even
used the ugliness of var_dump to splat the (empty) User array onto the screen
and everything is null. 

Here's the relevant part of the code and the deugging output. I'll attach my
modified User.php and an anonymised version of the hook as attachments. 

1. Bits of the hook:
        function fnUserAuthTGST($user, &$result) {

        $fname   = "D3UserAuthTGST::fnUserAuthTGST";
        $SSO     =
"https://xxxxxx.com/login/sso/SSOService?app=d3wiki&returnURL=";;
        $errpage = "http://d3wiki.nott.ime.xxxxx.com/d3wikiaccess.php";;
        $allowed = 300; # Five minutes diff is allowed.
        logTGST("Page: " . $_SERVER['REQUEST_URI']);
        ....

        // This returns the user object if it exists:
        $u   = User::newFromName($userName); 
        $uid = $u->getId();

        logTGST("After newFromName, uid is $uid");

        if ( $uid == 0 ) {              
        .....


        $user = $u;     

        $myid   = $user->getId(); // Trap these for debugging purposes ...
        $myfrom = $user->mFrom;
        logTGST("About to exit hook with user->mId = $myid and user->mFrom =
$myfrom");
        return true; // To continue loading the user...

} // fnUserAuthTGST

2. Hacked section of User.php:
        private function loadFromSession() {
          global $wgMemc, $wgCookiePrefix;

          $result = null;
          wfRunHooks( 'UserLoadFromSession', array( $this, &$result ) );
          wfDebugLog('TGST', '  TGST: loadFromSession result is ' . $result .
"\n");
          wfDebugLog('TGST', "  TGST: user id in \$this is $this->mId and name
is $this->mName\n");
          if ( $result !== null ) {

3. Output from logTGST and wfDebugLog (user->mFrom setting is useless and will
be removed) :

2009-02-09 14:17:04 Cookie exploded: 8009449, [email protected], Sam, Sexton
2009-02-09 14:17:04 After newFromName, uid is 3
2009-02-09 14:17:04 DB entry found for employee id nnnnnn with user id 3 and
name Sam.Sexton
2009-02-09 14:17:04 About to exit hook with user->mId = 3 and user->mFrom =
name
2009-02-09 14:17:04 wikidbD3-d3_:   TGST: loadFromSession result is 
2009-02-09 14:17:04 wikidbD3-d3_:   TGST: user id in $this is  and name is 

I really can't see what I'm doing wrong - can anyone else? Or is it a real bug?


-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to