Last modified: 2010-05-15 15:56:56 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 6395 - Empty object created by incorrect reference use in SpecialUserlogin.php
Empty object created by incorrect reference use in SpecialUserlogin.php
Status: RESOLVED WORKSFORME
Product: MediaWiki
Classification: Unclassified
User login and signup (Other open bugs)
1.6.x
PC Linux
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-06-21 16:17 UTC by Dave Challis
Modified: 2010-05-15 15:56 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Dave Challis 2006-06-21 16:17:25 UTC
Line 307 in 'includes/SpecialUserlogin.php' is:
$u =& $this->initUser( $u );

The signature of the 'initUser' method on line 268 is:
function &initUser( &$u ) {
    return $u;
}

The combination of this use of references means that after calling '$u =&
$this->initUser( $u );', $u will always be an empty object.

Since 'initUser' is a method that takes a reference to a user object and
modifies it, there's no need for it to return anything at all, and there's no
need to assign its return value to the object it is modifying.

Some trivial php code which demonstrates the problem:
<?php
class user {
    var $name = 'Foo';
}

function &initUser(&$u) {
    $u->name = 'Bar';
    return $u;
}

$u = new User();
print_r($u);
$u =& initUser($u);
print_r($u);
?>

The code above prints:
user Object
(
    [name] => Foo
)
user Object
(
)

Similarly, if you print the value of $u before and after line 307 of
SpecialUserlogin.php, you'll find same thing happens to it.
Comment 1 Brion Vibber 2006-06-21 17:02:36 UTC
Both PHP 4 (tested 4.4.1 and 4.4.3rc1) and PHP 5 (tested 5.1.2) show the expected 
results:

user Object
(
    [name] => Foo
)
user Object
(
    [name] => Bar
)

If you get different results, you have a *buggy* version of PHP. Upgrade it.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links