Go to the documentation of this file.
45 $comment =
null, $parameters =
null
48 $logEntry->setPerformer(
$user );
50 if ( $comment !==
null ) {
51 $logEntry->setComment( $comment );
53 if ( $parameters !==
null ) {
54 $logEntry->setParameters( $parameters );
57 return $logEntry->insert();
61 $this->tablesUsed[] =
'logging';
62 $this->tablesUsed[] =
'user';
66 $this->userId1 = $user1->getId();
67 if ( $this->userId1 === 0 ) {
68 $user1->addToDatabase();
69 $this->userId1 = $user1->getId();
71 $this->assertGreaterThan( 0, $this->userId1 );
74 $this->userId2 = $user2->getId();
75 if ( $this->userId2 === 0 ) {
76 $user2->addToDatabase();
77 $this->userId2 = $user2->getId();
79 $this->assertGreaterThan( 0, $this->userId2 );
81 $this->logId1 = $this->
addLogEntry(
'type',
'subtype',
83 $this->assertGreaterThan( 0, $this->logId1 );
85 $this->logId2 = $this->
addLogEntry(
'supress',
'delete',
86 $user2,
NS_TALK,
"PageB",
"SomeComment" );
87 $this->assertGreaterThan( 0, $this->logId2 );
89 $this->logId3 = $this->
addLogEntry(
'move',
'delete',
90 $user2,
NS_MAIN,
"PageA",
"SomeOtherComment",
91 [
'key1' => 1, 3 =>
'value3' ] );
92 $this->assertGreaterThan( 0, $this->logId3 );
93 }
catch ( Exception
$e ) {
97 $this->exceptionFromAddDBData =
$e;
115 $subtype,
$title, $parameters = []
130 if ( $comment !==
null ) {
138 $parameters_xml =
unserialize( $this->xml->value );
139 $this->assertEquals( $parameters, $parameters_xml );
140 $this->assertTrue( $this->xml->read(),
"Skipping past processed text of params" );
154 $dumper->endId = $this->logId3 + 1;
155 $dumper->reporting =
false;
156 $dumper->setDB( $this->db );
165 $this->userId1,
null,
"type",
"subtype",
"PageA" );
168 $this->assertNotNull( $contLang,
"Content language object validation" );
169 $namespace = $contLang->getNsText(
NS_TALK );
170 $this->assertInternalType(
'string', $namespace );
171 $this->assertGreaterThan( 0, strlen( $namespace ) );
173 $this->userId2,
"SomeComment",
"supress",
"delete",
174 $namespace .
":PageB" );
177 $this->userId2,
"SomeOtherComment",
"move",
"delete",
178 "PageA", [
'key1' => 1, 3 =>
'value3' ] );
190 $dumper->loadWithArgv( [
'--logs',
'--output=gzip:' .
$fname,
193 $dumper->endId = $this->logId3 + 1;
194 $dumper->setDB( $this->db );
201 $dumper->stderr = fopen(
'php://output',
'a' );
202 if ( $dumper->stderr ===
false ) {
203 $this->fail(
"Could not open stream for stderr" );
209 $this->assertTrue( fclose( $dumper->stderr ),
"Closing stderr handle" );
217 $this->userId1,
null,
"type",
"subtype",
"PageA" );
220 $this->assertNotNull( $contLang,
"Content language object validation" );
221 $namespace = $contLang->getNsText(
NS_TALK );
222 $this->assertInternalType(
'string', $namespace );
223 $this->assertGreaterThan( 0, strlen( $namespace ) );
225 $this->userId2,
"SomeComment",
"supress",
"delete",
226 $namespace .
":PageB" );
229 $this->userId2,
"SomeOtherComment",
"move",
"delete",
230 "PageA", [
'key1' => 1, 3 =>
'value3' ] );
238 $this->expectOutputString(
'' );
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
Tests for log dumps of BackupDumper.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
assertDumpStart( $fname, $skip_siteinfo=true)
Opens an XML file to analyze and optionally skips past siteinfo.
checkHasGzip()
Skip the test if 'gzip' is not in $PATH.
assertLogItem( $id, $user_name, $user_id, $comment, $type, $subtype, $title, $parameters=[])
asserts that the xml reader is at the beginning of a log entry and skips over it while analyzing it.
skipWhitespace()
Steps the xml reader over white space.
assertNodeEnd( $name, $skip=true)
Asserts that the xml reader is at an closing element of given name, and optionally skips past it.
assertDumpEnd( $name="mediawiki")
Asserts that the xml reader is at the final closing tag of an xml file and closes the reader.
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
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
namespace and then decline to actually register it file or subcat img or subcat $title
assertNodeStart( $name, $skip=true)
Asserts that the xml reader is at an element of given name, and optionally skips past it.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
gunzip( $fname)
gunzips the given file and stores the result in the original file name
addLogEntry( $type, $subtype, User $user, $ns, $title, $comment=null, $parameters=null)
adds a log entry to the database.
unserialize( $serialized)
Represents a title within MediaWiki.
testXmlDumpsBackupUseCaseLogging()
Class for creating new log entries and inserting them into the database.
assertTextNode( $name, $text, $skip_ws=true)
Asserts that the xml reader is at an element of given tag that contains a given text,...
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 MediaWikiServices
The User object encapsulates all of the user-specific settings (user_id, name, rights,...