Go to the documentation of this file.
16 protected function setUp() {
19 'wgLanguageCode' =>
'en',
27 if (
$user->getID() == 0 ) {
28 $user->addToDatabase();
29 $user->setPassword(
'UTBlockeePassword' );
31 $user->saveSettings();
42 'Parce que', 0,
false, time() + 100500
46 $this->
block->insert();
50 $newBlockId = $this->
block->getId();
52 $this->blockId = $newBlockId;
54 throw new MWException(
"Failed to insert block for BlockTest; old leftover block remaining?" );
64 $v = $this->db->select(
'ipblocks',
'*' );
65 print
"Got " . $v->numRows() .
" rows. Full dump follow:\n";
66 foreach ( $v
as $row ) {
75 $this->assertTrue( $this->
block->equals(
Block::newFromTarget(
'UTBlockee' ) ),
"newFromTarget() returns the same block as the one that was made" );
82 $this->assertTrue( $this->
block->equals(
Block::newFromID( $this->blockId ) ),
"newFromID() returns the same block as the one that was made" );
90 $delta = abs( $this->madeAt - $this->
block->mTimestamp );
91 $this->assertLessThan( 2, $delta,
"If no timestamp is specified, the block is recorded as time()" );
104 $this->assertTrue( $this->
block->equals(
$block ),
"newFromTarget() returns the same block as the one that was made when given empty vagueTarget param " . var_export( $vagueTarget,
true ) );
119 $username =
'BlockedUserToCreateAccountWith';
121 $u->setPassword(
'NotRandomPass' );
128 "$username should not be blocked"
134 $u->isBlockedFromCreateAccount(),
135 "Our sandbox user should be able to create account before being blocked"
143 'crosswiki block...',
146 $this->db->getInfinity(),
161 "Block object in DB should prevents 'createaccount'"
164 $this->assertInstanceOf(
167 "'$username' block block object should be existent"
173 (
bool)$u->isBlockedFromCreateAccount(),
174 "Our sandbox user '$username' should NOT be able to create account"
194 'crosswiki block...',
197 $this->db->getInfinity(),
208 $this->assertTrue( (
bool)
$res[
'id'],
'Block succeeded' );
212 $user->addToDatabase();
214 $this->db->update(
'user',
array(
'user_id' => 14146 ),
array(
'user_id' =>
$user->getId() ) );
218 $this->assertEquals(
'UserOnForeignWiki',
$block->
getTarget()->getName(),
'Correct blockee name' );
219 $this->assertEquals(
'14146',
$block->
getTarget()->getId(),
'Correct blockee id' );
220 $this->assertEquals(
'MetaWikiUser',
$block->
getBlocker(),
'Correct blocker name' );
221 $this->assertEquals(
'MetaWikiUser',
$block->
getByName(),
'Correct blocker name' );
222 $this->assertEquals( 0,
$block->
getBy(),
'Correct blocker id' );
226 static $inited =
false;
235 array(
'target' =>
'70.2.0.0/16',
237 'desc' =>
'Range Hardblock',
238 'ACDisable' =>
false,
239 'isHardblock' =>
true,
240 'isAutoBlocking' =>
false,
242 array(
'target' =>
'2001:4860:4001::/48',
244 'desc' =>
'Range6 Hardblock',
245 'ACDisable' =>
false,
246 'isHardblock' =>
true,
247 'isAutoBlocking' =>
false,
249 array(
'target' =>
'60.2.0.0/16',
251 'desc' =>
'Range Softblock with AC Disabled',
253 'isHardblock' =>
false,
254 'isAutoBlocking' =>
false,
256 array(
'target' =>
'50.2.0.0/16',
258 'desc' =>
'Range Softblock',
259 'ACDisable' =>
false,
260 'isHardblock' =>
false,
261 'isAutoBlocking' =>
false,
263 array(
'target' =>
'50.1.1.1',
265 'desc' =>
'Exact Softblock',
266 'ACDisable' =>
false,
267 'isHardblock' =>
false,
268 'isAutoBlocking' =>
false,
272 foreach ( $blockList
as $insBlock ) {
273 $target = $insBlock[
'target'];
284 $block->mReason = $insBlock[
'desc'];
285 $block->mExpiry =
'infinity';
295 array(
'xff' =>
'1.2.3.4, 70.2.1.1, 60.2.1.1, 2.3.4.5',
297 'result' =>
'Range Hardblock'
299 array(
'xff' =>
'1.2.3.4, 50.2.1.1, 60.2.1.1, 2.3.4.5',
301 'result' =>
'Range Softblock with AC Disabled'
303 array(
'xff' =>
'1.2.3.4, 70.2.1.1, 50.1.1.1, 2.3.4.5',
305 'result' =>
'Exact Softblock'
307 array(
'xff' =>
'1.2.3.4, 70.2.1.1, 50.2.1.1, 50.1.1.1, 2.3.4.5',
309 'result' =>
'Exact Softblock'
311 array(
'xff' =>
'1.2.3.4, 70.2.1.1, 50.2.1.1, 2.3.4.5',
313 'result' =>
'Range Hardblock'
315 array(
'xff' =>
'1.2.3.4, 70.2.1.1, 60.2.1.1, 2.3.4.5',
317 'result' =>
'Range Hardblock'
319 array(
'xff' =>
'50.2.1.1, 60.2.1.1, 2.3.4.5',
321 'result' =>
'Range Softblock with AC Disabled'
323 array(
'xff' =>
'1.2.3.4, 50.1.1.1, 60.2.1.1, 2.3.4.5',
325 'result' =>
'Exact Softblock'
327 array(
'xff' =>
'1.2.3.4, <$A_BUNCH-OF{INVALID}TEXT>, 60.2.1.1, 2.3.4.5',
329 'result' =>
'Range Softblock with AC Disabled'
331 array(
'xff' =>
'1.2.3.4, 50.2.1.1, 2001:4860:4001:802::1003, 2.3.4.5',
333 'result' =>
'Range6 Hardblock'
344 $list = array_map(
'trim', explode(
',', $xff ) );
346 $this->assertEquals( $exCount, count( $xffblocks ),
'Number of blocks for ' . $xff );
348 $this->assertEquals( $exResult,
$block->mReason,
'Correct block type for XFF header ' . $xff );
prevents( $action, $x=null)
Get/set whether the Block prevents a given action.
isHardblock( $x=null)
Get/set whether the Block is a hardblock (affects logged-in users on a given IP/range.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static newFromID( $id)
Load a blocked user from their block id.
getBy()
Get the user id of the blocking sysop.
static chooseBlock(array $blocks, array $ipChain)
From a list of multiple blocks, find the most exact and strongest Block.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
static newFromTarget( $specificTarget, $vagueTarget=null, $fromMaster=false)
Given a target and the target's type, get an existing Block object if possible.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
insert( $dbw=null)
Insert a block into the block table.
testINewFromIDReturnsCorrectBlock()
@covers Block::newFromID
@group Database @group Blocking
testBlockedUserCanNotCreateAccount()
@covers Block::prevents
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
testCrappyCrossWikiBlocks()
@covers Block::insert
static getBlocksForIPList(array $ipChain, $isAnon, $fromMaster=false)
Get all blocks that match any IP from an array of IP addresses.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
getBlocker()
Get the user who implemented this block.
setBlocker( $user)
Set the user who implemented (or will implement) this block.
getTarget()
Get the target for this particular Block.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LoginAuthenticateAudit' this hook is for auditing only etc block
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
dumpBlocks()
debug function : dump the ipblocks table
testINewFromTargetReturnsCorrectBlock()
@covers Block::newFromTarget
static sanitizeIP( $ip)
Convert an IP into a verbose, uppercase, normalized form.
testBug26425BlockTimestampDefaultsToTime()
per bug 26425
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
static factory( $code)
Get a cached or new language object for a given language code.
getByName()
Get the username of the blocking sysop.
testBlocksOnXff( $xff, $exCount, $exResult)
@dataProvider providerXff @covers Block::getBlocksForIPList @covers Block::chooseBlock
static sanitizeRange( $range)
Gets rid of unneeded numbers in quad-dotted/octet IP strings For example, 127.111....
setTarget( $target)
Set the target for this block, and update $this->type accordingly.
testBug29116NewFromTargetWithEmptyIp( $vagueTarget)
CheckUser since being changed to use Block::newFromTarget started failing because the new function di...
static provideBug29116Data()