35 $comment =
null, $parameters =
null
38 $logEntry->setPerformer( $user );
39 $logEntry->setTarget( Title::newFromText( $title, $ns ) );
40 if ( $comment !==
null ) {
41 $logEntry->setComment( $comment );
43 if ( $parameters !==
null ) {
44 $logEntry->setParameters( $parameters );
47 return $logEntry->insert();
51 $this->tablesUsed[] =
'logging';
52 $this->tablesUsed[] =
'user';
55 $user1 = User::newFromName(
'BackupDumperLogUserA' );
56 $this->userId1 = $user1->getId();
57 if ( $this->userId1 === 0 ) {
58 $user1->addToDatabase();
59 $this->userId1 = $user1->getId();
61 $this->assertGreaterThan( 0, $this->userId1 );
63 $user2 = User::newFromName(
'BackupDumperLogUserB' );
64 $this->userId2 = $user2->getId();
65 if ( $this->userId2 === 0 ) {
66 $user2->addToDatabase();
67 $this->userId2 = $user2->getId();
69 $this->assertGreaterThan( 0, $this->userId2 );
71 $this->logId1 = $this->
addLogEntry(
'type',
'subtype',
73 $this->assertGreaterThan( 0, $this->logId1 );
75 $this->logId2 = $this->
addLogEntry(
'supress',
'delete',
76 $user2,
NS_TALK,
"PageB",
"SomeComment" );
77 $this->assertGreaterThan( 0, $this->logId2 );
79 $this->logId3 = $this->
addLogEntry(
'move',
'delete',
80 $user2,
NS_MAIN,
"PageA",
"SomeOtherComment",
81 [
'key1' => 1, 3 =>
'value3' ] );
82 $this->assertGreaterThan( 0, $this->logId3 );
83 }
catch ( Exception
$e ) {
87 $this->exceptionFromAddDBData =
$e;
105 $subtype, $title, $parameters = []
120 if ( $comment !==
null ) {
128 $parameters_xml =
unserialize( $this->xml->value );
129 $this->assertEquals( $parameters, $parameters_xml );
130 $this->assertTrue( $this->xml->read(),
"Skipping past processed text of params" );
146 $dumper->endId = $this->logId3 + 1;
147 $dumper->reporting =
false;
148 $dumper->setDB( $this->db );
157 $this->userId1,
null,
"type",
"subtype",
"PageA" );
159 $this->assertNotNull(
$wgContLang,
"Content language object validation" );
161 $this->assertInternalType(
'string', $namespace );
162 $this->assertGreaterThan( 0, strlen( $namespace ) );
164 $this->userId2,
"SomeComment",
"supress",
"delete",
165 $namespace .
":PageB" );
168 $this->userId2,
"SomeOtherComment",
"move",
"delete",
169 "PageA", [
'key1' => 1, 3 =>
'value3' ] );
183 $dumper->loadWithArgv( [
'--logs',
'--output=gzip:' .
$fname,
186 $dumper->endId = $this->logId3 + 1;
187 $dumper->setDB( $this->db );
194 $dumper->stderr = fopen(
'php://output',
'a' );
195 if ( $dumper->stderr ===
false ) {
196 $this->fail(
"Could not open stream for stderr" );
202 $this->assertTrue( fclose( $dumper->stderr ),
"Closing stderr handle" );
210 $this->userId1,
null,
"type",
"subtype",
"PageA" );
212 $this->assertNotNull(
$wgContLang,
"Content language object validation" );
214 $this->assertInternalType(
'string', $namespace );
215 $this->assertGreaterThan( 0, strlen( $namespace ) );
217 $this->userId2,
"SomeComment",
"supress",
"delete",
218 $namespace .
":PageB" );
221 $this->userId2,
"SomeOtherComment",
"move",
"delete",
222 "PageA", [
'key1' => 1, 3 =>
'value3' ] );
230 $this->expectOutputString(
'' );
unserialize( $serialized)
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
Tests for log dumps of BackupDumper.
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.
testXmlDumpsBackupUseCaseLogging()
addLogEntry( $type, $subtype, User $user, $ns, $title, $comment=null, $parameters=null)
adds a log entry to the database.
assertNodeStart( $name, $skip=true)
Asserts that the xml reader is at an element of given name, and optionally skips past it.
assertDumpStart( $fname, $skip_siteinfo=true)
Opens an XML file to analyze and optionally skips past siteinfo.
assertDumpEnd( $name="mediawiki")
Asserts that the xml reader is at the final closing tag of an xml file and closes the reader.
assertNodeEnd( $name, $skip=true)
Asserts that the xml reader is at an closing element of given name, and optionally skips past it.
gunzip( $fname)
gunzips the given file and stores the result in the original file name
checkHasGzip()
Skip the test if 'gzip' is not in $PATH.
assertTextNode( $name, $text, $skip_ws=true)
Asserts that the xml reader is at an element of given tag that contains a given text,...
skipWhitespace()
Steps the xml reader over white space.
Class for creating log entries manually, to inject them into the database.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
returning false will NOT prevent logging $e