44 $comment =
null, $parameters =
null
47 $logEntry->setPerformer( $user );
48 $logEntry->setTarget( Title::newFromText( $title, $ns ) );
49 if ( $comment !==
null ) {
50 $logEntry->setComment( $comment );
52 if ( $parameters !==
null ) {
53 $logEntry->setParameters( $parameters );
56 return $logEntry->insert();
60 $this->tablesUsed[] =
'logging';
61 $this->tablesUsed[] =
'user';
65 $this->userId1 = $user1->getId();
66 if ( $this->userId1 === 0 ) {
67 $user1->addToDatabase();
68 $this->userId1 = $user1->getId();
70 $this->assertGreaterThan( 0, $this->userId1 );
73 $this->userId2 = $user2->getId();
74 if ( $this->userId2 === 0 ) {
75 $user2->addToDatabase();
76 $this->userId2 = $user2->getId();
78 $this->assertGreaterThan( 0, $this->userId2 );
80 $this->logId1 = $this->
addLogEntry(
'type',
'subtype',
82 $this->assertGreaterThan( 0, $this->logId1 );
84 $this->logId2 = $this->
addLogEntry(
'supress',
'delete',
85 $user2,
NS_TALK,
"PageB",
"SomeComment" );
86 $this->assertGreaterThan( 0, $this->logId2 );
88 $this->logId3 = $this->
addLogEntry(
'move',
'delete',
89 $user2,
NS_MAIN,
"PageA",
"SomeOtherComment",
90 [
'key1' => 1, 3 =>
'value3' ] );
91 $this->assertGreaterThan( 0, $this->logId3 );
92 }
catch ( Exception
$e ) {
96 $this->exceptionFromAddDBData =
$e;
114 $subtype, $title, $parameters = []
129 if ( $comment !==
null ) {
137 $parameters_xml =
unserialize( $this->xml->value );
138 $this->assertEquals( $parameters, $parameters_xml );
139 $this->assertTrue( $this->xml->read(),
"Skipping past processed text of params" );
155 $dumper->endId = $this->logId3 + 1;
156 $dumper->reporting =
false;
157 $dumper->setDB( $this->db );
160 $dumper->dump( WikiExporter::LOGS, WikiExporter::TEXT );
166 $this->userId1,
null,
"type",
"subtype",
"PageA" );
168 $this->assertNotNull(
$wgContLang,
"Content language object validation" );
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' ] );
192 $dumper->loadWithArgv( [
'--logs',
'--output=gzip:' .
$fname,
195 $dumper->endId = $this->logId3 + 1;
196 $dumper->setDB( $this->db );
203 $dumper->stderr = fopen(
'php://output',
'a' );
204 if ( $dumper->stderr ===
false ) {
205 $this->fail(
"Could not open stream for stderr" );
211 $this->assertTrue( fclose( $dumper->stderr ),
"Closing stderr handle" );
219 $this->userId1,
null,
"type",
"subtype",
"PageA" );
221 $this->assertNotNull(
$wgContLang,
"Content language object validation" );
223 $this->assertInternalType(
'string', $namespace );
224 $this->assertGreaterThan( 0, strlen( $namespace ) );
226 $this->userId2,
"SomeComment",
"supress",
"delete",
227 $namespace .
":PageB" );
230 $this->userId2,
"SomeOtherComment",
"move",
"delete",
231 "PageA", [
'key1' => 1, 3 =>
'value3' ] );
239 $this->expectOutputString(
'' );
unserialize( $serialized)
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Class for creating log entries manually, to inject them into the database.
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.
addLogEntry( $type, $subtype, User $user, $ns, $title, $comment=null, $parameters=null)
adds a log entry to the database.
testXmlDumpsBackupUseCaseLogging()
gunzip( $fname)
gunzips the given file and stores the result in the original file name
assertDumpStart( $fname, $skip_siteinfo=true)
Opens an XML file to analyze and optionally skips past siteinfo.
assertTextNode( $name, $text, $skip_ws=true)
Asserts that the xml reader is at an element of given tag that contains a given text,...
assertDumpEnd( $name="mediawiki")
Asserts that the xml reader is at the final closing tag of an xml file and closes the reader.
checkHasGzip()
Skip the test if 'gzip' is not in $PATH.
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.
assertNodeStart( $name, $skip=true)
Asserts that the xml reader is at an element of given name, and optionally skips past it.
Represents a title within MediaWiki.
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.
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