Make User::newFromName set the user object's ID attribute, so it can
be used for other methods and lazy loading. Previously, you had to use the class method idForName and assign its value using setId(). Since all the code that was using newFromName was doing this, it seems like client programs want a "real" User returned from newFromName. Replaced client code that was doing newFromName, idForName, setId with just newFromName. This doesn't seem to break newFromName's semantics; it seems intuitive (to me) that the user object returned from newFromName should be usable as returned.
This commit is contained in:
parent
bcc5c346ad
commit
2d2d5805bc
5 changed files with 10 additions and 16 deletions
|
|
@ -1877,7 +1877,6 @@ class Article {
|
|||
$shortTitle != $wgUser->getName())
|
||||
{
|
||||
$other = User::newFromName($shortTitle);
|
||||
$other->setID(User::idFromName($shortTitle));
|
||||
$other->setNewtalk(1);
|
||||
$other->saveNewtalk();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,12 @@ function wfSpecialEmailuser( $par ) {
|
|||
return;
|
||||
}
|
||||
$nu = User::newFromName( $nt->getText() );
|
||||
$id = $nu->idForName();
|
||||
|
||||
if ( 0 == $id ) {
|
||||
if ( 0 == $nu->getID() ) {
|
||||
$wgOut->errorpage( "noemailtitle", "noemailtext" );
|
||||
return;
|
||||
}
|
||||
$nu->setID( $id );
|
||||
|
||||
$address = $nu->getEmail();
|
||||
|
||||
if ( ( false === strpos( $address, "@" ) ) ||
|
||||
|
|
|
|||
|
|
@ -115,12 +115,11 @@ class UserlevelsForm extends HTMLForm {
|
|||
$wgOut->addHTML('<p>'.wfMsg('nosuchusershort',$username).'</p>');
|
||||
return;
|
||||
}
|
||||
$id = $u->idForName();
|
||||
if($id == 0) {
|
||||
|
||||
if($u->getID() == 0) {
|
||||
$wgOut->addHTML('<p>'.wfMsg('nosuchusershort',$username).'</p>');
|
||||
return;
|
||||
}
|
||||
$u->setID( $id );
|
||||
|
||||
$groups = $u->getGroups();
|
||||
$logcomment = ' ';
|
||||
|
|
@ -214,12 +213,11 @@ class UserlevelsForm extends HTMLForm {
|
|||
$wgOut->addHTML('<p>'.wfMsg('nosuchusershort',$username).'</p>');
|
||||
return;
|
||||
}
|
||||
$id = $user->idForName();
|
||||
if($id == 0) {
|
||||
|
||||
if($user->getID() == 0) {
|
||||
$wgOut->addHTML('<p>'.wfMsg('nosuchusershort',$username).'</p>');
|
||||
return;
|
||||
}
|
||||
$user->setID( $id );
|
||||
|
||||
$groups = $user->getGroups();
|
||||
|
||||
|
|
|
|||
|
|
@ -240,8 +240,7 @@ class LoginForm {
|
|||
$this->mainLoginForm( wfMsg( 'noname' ) );
|
||||
return;
|
||||
}
|
||||
$id = $u->idForName();
|
||||
if ( 0 == $id ) {
|
||||
if ( 0 == $u->getID() ) {
|
||||
global $wgAuth;
|
||||
/**
|
||||
* If the external authentication plugin allows it,
|
||||
|
|
@ -257,7 +256,6 @@ class LoginForm {
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
$u->setId( $id );
|
||||
$u->loadFromDatabase();
|
||||
}
|
||||
if (!$u->checkPassword( $this->mPassword )) {
|
||||
|
|
@ -302,12 +300,11 @@ class LoginForm {
|
|||
$this->mainLoginForm( wfMsg( 'noname' ) );
|
||||
return;
|
||||
}
|
||||
$id = $u->idForName();
|
||||
if ( 0 == $id ) {
|
||||
if ( 0 == $u->getID() ) {
|
||||
$this->mainLoginForm( wfMsg( 'nosuchuser', $u->getName() ) );
|
||||
return;
|
||||
}
|
||||
$u->setId( $id );
|
||||
|
||||
$u->loadFromDatabase();
|
||||
|
||||
$error = $this->mailPasswordInternal( $u );
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ class User {
|
|||
return NULL;
|
||||
} else {
|
||||
$u->setName( $t->getText() );
|
||||
$u->setId( $u->idFromName( $t->getText() ) );
|
||||
return $u;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue