27 if (
$wgDBprefix !== MediaWikiTestCase::DB_PREFIX &&
30 throw new MWException(
"Can't create user on real database" );
35 $email =
'sample@example.com', $groups = []
40 $this->password =
'TestUser';
49 if ( !$this->
user->isLoggedIn() ) {
54 "real_name" => $realname
65 $change = $this->
setEmail( $email ) ||
69 $currentGroups = $this->
user->getGroups();
70 foreach ( array_diff( $groups, $currentGroups )
as $group ) {
71 $this->
user->addGroup( $group );
73 foreach ( array_diff( $currentGroups, $groups )
as $group ) {
74 $this->
user->removeGroup( $group );
82 $this->
user->mTouched =
'';
83 $this->
user->saveSettings();
92 if ( $this->
user->getRealName() !== $realname ) {
93 $this->
user->setRealName( $realname );
105 if ( $this->
user->getEmail() !== $email ) {
106 $this->
user->setEmail( $email );
131 throw new MWException(
"Passed User has not been added to the database yet!" );
135 $row = $dbw->selectRow(
142 throw new MWException(
"Passed User has an ID but is not in the database?" );
145 $passwordFactory = MediaWikiServices::getInstance()->getPasswordFactory();
146 if ( !$passwordFactory->newFromCiphertext( $row->user_password )->equals(
$password ) ) {
147 $passwordHash = $passwordFactory->newFromPlaintext(
$password );
150 [
'user_password' => $passwordHash->toString() ],
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
$wgDBprefix
Table name prefix.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Wraps the user object, so we can also retain full access to properties like password if we log in via...
static setPasswordForUser(User $user, $password)
Set the password on a testing user.
__construct( $username, $realname='Real Name', $email='sample @example.com', $groups=[])
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
getId()
Get the user's ID.
static createNew( $name, $params=[])
Add a user to the database, return the user object.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Wikitext formatted, in the key only.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php