27use InvalidArgumentException;
89 string $validate = self::RIGOR_VALID
92 $canonicalName = $this->userNameUtils->getCanonical( $name, $validate );
93 if ( $canonicalName ===
false ) {
98 $user->mName = $canonicalName;
99 $user->mFrom =
'name';
100 $user->setItemLoaded(
'name' );
114 if ( !$this->userNameUtils->isIP( $ip ) ) {
115 throw new InvalidArgumentException(
'Invalid IP address' );
117 $user = $this->newFromName( $ip, self::RIGOR_NONE );
150 $user->mActorId = $actorId;
151 $user->mFrom =
'actor';
165 if ( $userIdentity instanceof
User ) {
166 return $userIdentity;
169 $id = $userIdentity->
getId();
170 $name = $userIdentity->getName();
176 $this->lastUserFromIdentity
177 && $this->lastUserFromIdentity->getId() === $id
178 && $this->lastUserFromIdentity->getName() === $name
180 return $this->lastUserFromIdentity;
183 $this->lastUserFromIdentity = $this->newFromAnyId(
184 $id === 0 ?
null : $id,
185 $name ===
'' ? null : $name,
189 return $this->lastUserFromIdentity;
210 ?
int $actorId =
null,
216 if ( $dbDomain !== false ) {
222 $user->mFrom =
'defaults';
224 if ( $actorId !==
null ) {
225 $user->mActorId = $actorId;
226 if ( $actorId !== 0 ) {
227 $user->mFrom =
'actor';
232 if ( $userName !==
null && $userName !==
'' ) {
233 $user->mName = $userName;
234 $user->mFrom =
'name';
235 $user->setItemLoaded(
'name' );
238 if ( $userId !==
null ) {
239 $user->mId = $userId;
240 if ( $userId !== 0 ) {
243 $user->setItemLoaded(
'id' );
246 if ( $user->mFrom ===
'defaults' ) {
247 throw new InvalidArgumentException(
248 'Cannot create a user with no name, no ID, and no actor ID'
268 string $confirmationCode,
269 int $flags = self::READ_NORMAL
271 list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
273 $db = $this->loadBalancer->getConnectionRef( $index );
275 $id = $db->selectField(
279 'user_email_token' => md5( $confirmationCode ),
280 'user_email_token_expires > ' . $db->addQuotes( $db->timestamp() ),
290 return $this->newFromId( (
int)$id );
312 if ( $authority instanceof
User ) {
315 return $this->newFromUserIdentity( $authority->getUser() );
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Helper class for DAO classes.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromRow( $row, $data=null)
Create a new user object from a user row.
setItemLoaded( $item)
Set that an item has been loaded.
Interface for database access objects.