46 $comment =
null, $parameters =
null
49 $logEntry->setPerformer(
$user );
50 $logEntry->setTarget( Title::newFromText(
$title, $ns ) );
51 if ( $comment !==
null ) {
52 $logEntry->setComment( $comment );
54 if ( $parameters !==
null ) {
55 $logEntry->setParameters( $parameters );
58 return $logEntry->insert();
62 $this->tablesUsed[] =
'logging';
63 $this->tablesUsed[] =
'user';
67 $this->userId1 = $user1->getId();
68 if ( $this->userId1 === 0 ) {
69 $user1->addToDatabase();
70 $this->userId1 = $user1->getId();
72 $this->assertGreaterThan( 0, $this->userId1 );
75 $this->userId2 = $user2->getId();
76 if ( $this->userId2 === 0 ) {
77 $user2->addToDatabase();
78 $this->userId2 = $user2->getId();
80 $this->assertGreaterThan( 0, $this->userId2 );
82 $this->logId1 = $this->
addLogEntry(
'type',
'subtype',
84 $this->assertGreaterThan( 0, $this->logId1 );
86 $this->logId2 = $this->
addLogEntry(
'supress',
'delete',
87 $user2,
NS_TALK,
"PageB",
"SomeComment" );
88 $this->assertGreaterThan( 0, $this->logId2 );
90 $this->logId3 = $this->
addLogEntry(
'move',
'delete',
91 $user2,
NS_MAIN,
"PageA",
"SomeOtherComment",
92 [
'key1' => 1, 3 =>
'value3' ] );
93 $this->assertGreaterThan( 0, $this->logId3 );
94 }
catch ( Exception
$e ) {
98 $this->exceptionFromAddDBData =
$e;
108 $dumper->endId = $this->logId3 + 1;
109 $dumper->reporting =
false;
110 $dumper->setDB( $this->db );
113 $dumper->dump( WikiExporter::LOGS, WikiExporter::TEXT );
119 $asserter->assertDumpStart(
$fname );
121 $asserter->assertLogItem( $this->logId1,
"BackupDumperLogUserA",
122 $this->userId1,
null,
"type",
"subtype",
"PageA" );
125 $this->assertNotNull( $contLang,
"Content language object validation" );
126 $namespace = $contLang->getNsText(
NS_TALK );
127 $this->assertInternalType(
'string', $namespace );
128 $this->assertGreaterThan( 0, strlen( $namespace ) );
129 $asserter->assertLogItem( $this->logId2,
"BackupDumperLogUserB",
130 $this->userId2,
"SomeComment",
"supress",
"delete",
131 $namespace .
":PageB" );
133 $asserter->assertLogItem( $this->logId3,
"BackupDumperLogUserB",
134 $this->userId2,
"SomeOtherComment",
"move",
"delete",
135 "PageA", [
'key1' => 1, 3 =>
'value3' ] );
137 $asserter->assertDumpEnd();
147 $dumper->loadWithArgv( [
'--logs',
'--output=gzip:' .
$fname,
150 $dumper->endId = $this->logId3 + 1;
151 $dumper->setDB( $this->db );
158 $dumper->stderr = fopen(
'php://output',
'a' );
159 if ( $dumper->stderr ===
false ) {
160 $this->fail(
"Could not open stream for stderr" );
166 $this->assertTrue( fclose( $dumper->stderr ),
"Closing stderr handle" );
174 $asserter->assertDumpStart(
$fname );
176 $asserter->assertLogItem( $this->logId1,
"BackupDumperLogUserA",
177 $this->userId1,
null,
"type",
"subtype",
"PageA" );
180 $this->assertNotNull( $contLang,
"Content language object validation" );
181 $namespace = $contLang->getNsText(
NS_TALK );
182 $this->assertInternalType(
'string', $namespace );
183 $this->assertGreaterThan( 0, strlen( $namespace ) );
184 $asserter->assertLogItem( $this->logId2,
"BackupDumperLogUserB",
185 $this->userId2,
"SomeComment",
"supress",
"delete",
186 $namespace .
":PageB" );
188 $asserter->assertLogItem( $this->logId3,
"BackupDumperLogUserB",
189 $this->userId2,
"SomeOtherComment",
"move",
"delete",
190 "PageA", [
'key1' => 1, 3 =>
'value3' ] );
192 $asserter->assertDumpEnd();
198 $this->expectOutputString(
'' );
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
Class for creating new log entries and inserting them into the database.
Tests for log dumps of BackupDumper.
addLogEntry( $type, $subtype, User $user, $ns, $title, $comment=null, $parameters=null)
adds a log entry to the database.
testXmlDumpsBackupUseCaseLogging()
getDumpAsserter( $schemaVersion=null)
gunzip( $fname)
gunzips the given file and stores the result in the original file name
assertDumpSchema( $fname, $schemaFile)
Checks an XML file against an XSD schema.
checkHasGzip()
Skip the test if 'gzip' is not in $PATH.
getXmlSchemaPath( $schemaVersion=null)
Returns the path to the XML schema file for the given schema version.
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.
namespace and then decline to actually register it file or subcat img or subcat $title
return true to allow those checks to and false if checking is done & $user
returning false will NOT prevent logging $e
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