25 $this->
markTestSkipped(
"SQLite at least 3.6 required, {$this->db->getServerVersion()} found" );
31 return preg_replace(
'/\s+/',
' ', $this->db->replaceVars( $sql ) );
37 foreach (
$res as $row ) {
38 foreach ( $expected[$i] as $key =>
$value ) {
44 $this->
assertEquals( count( $expected ), $i,
'Unexpected number of rows' );
53 'foo bar',
"'foo bar'"
56 'foo\'bar',
"'foo''bar'"
80 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
86 $this->
assertTrue( $re !==
false,
'query failed' );
88 $row = $re->fetchRow();
96 $this->fail(
'query returned no result' );
107 "CREATE TABLE /**/foo (foo_key INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "
108 .
"foo_bar TEXT, foo_name TEXT NOT NULL DEFAULT '', foo_int INTEGER, foo_int2 INTEGER );",
110 "CREATE TABLE /**/foo (foo_key int unsigned NOT NULL PRIMARY KEY AUTO_INCREMENT, "
111 .
"foo_bar char(13), foo_name varchar(255) binary NOT NULL DEFAULT '', "
112 .
"foo_int tinyint ( 8 ), foo_int2 int(16) ) ENGINE=MyISAM;"
117 "CREATE TABLE foo ( foo1 REAL, foo2 REAL, foo3 REAL );",
119 "CREATE TABLE foo ( foo1 FLOAT, foo2 DOUBLE( 1,10), foo3 DOUBLE PRECISION );"
123 $this->
assertEquals(
"CREATE TABLE foo ( foo_binary1 BLOB, foo_binary2 BLOB );",
124 $this->
replaceVars(
"CREATE TABLE foo ( foo_binary1 binary(16), foo_binary2 varbinary(32) );" )
127 $this->
assertEquals(
"CREATE TABLE text ( text_foo TEXT );",
128 $this->
replaceVars(
"CREATE TABLE text ( text_foo tinytext );" ),
132 $this->
assertEquals(
"CREATE TABLE foo ( foobar INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL );",
133 $this->
replaceVars(
"CREATE TABLE foo ( foobar INT PRIMARY KEY NOT NULL AUTO_INCREMENT );" )
135 $this->
assertEquals(
"CREATE TABLE foo ( foobar INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL );",
136 $this->
replaceVars(
"CREATE TABLE foo ( foobar INT PRIMARY KEY AUTO_INCREMENT NOT NULL );" )
139 $this->
assertEquals(
"CREATE TABLE enums( enum1 TEXT, myenum TEXT)",
140 $this->
replaceVars(
"CREATE TABLE enums( enum1 ENUM('A', 'B'), myenum ENUM ('X', 'Y'))" )
143 $this->
assertEquals(
"ALTER TABLE foo ADD COLUMN foo_bar INTEGER DEFAULT 42",
144 $this->
replaceVars(
"ALTER TABLE foo\nADD COLUMN foo_bar int(10) unsigned DEFAULT 42" )
148 $this->
replaceVars(
"DROP INDEX /*i*/foo ON /*_*/bar" )
151 $this->
assertEquals(
"DROP INDEX foo -- dropping index",
152 $this->
replaceVars(
"DROP INDEX /*i*/foo ON /*_*/bar -- dropping index" )
154 $this->
assertEquals(
"INSERT OR IGNORE INTO foo VALUES ('bar')",
155 $this->
replaceVars(
"INSERT OR IGNORE INTO foo VALUES ('bar')" )
164 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
176 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
177 $db->
query(
'CREATE TABLE foo(foo, barfoo)' );
178 $db->
query(
'CREATE INDEX index1 ON foo(foo)' );
179 $db->
query(
'CREATE UNIQUE INDEX index2 ON foo(barfoo)' );
184 'Normal table duplication'
186 $indexList =
$db->
query(
'PRAGMA INDEX_LIST("bar")' );
187 $index = $indexList->next();
190 $index = $indexList->next();
196 $db->
selectField(
'sqlite_temp_master',
'sql', [
'name' =>
'baz' ] ),
197 'Creation of temporary duplicate'
199 $indexList =
$db->
query(
'PRAGMA INDEX_LIST("baz")' );
200 $index = $indexList->next();
203 $index = $indexList->next();
207 $db->
selectField(
'sqlite_master',
'COUNT(*)', [
'name' =>
'baz' ] ),
208 'Create a temporary duplicate only'
216 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
218 $this->
markTestSkipped(
'FTS3 not supported, cannot create virtual tables' );
220 $db->
query(
'CREATE VIRTUAL TABLE "foo" USING FTS3(foobar)' );
223 $this->
assertEquals(
'CREATE VIRTUAL TABLE "bar" USING FTS3(foobar)',
225 'Duplication of virtual tables'
229 $this->
assertEquals(
'CREATE VIRTUAL TABLE "baz" USING FTS3(foobar)',
231 "Can't create temporary virtual tables, should fall back to non-temporary duplication"
239 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
240 $db->
query(
'CREATE TABLE a (a_1)', __METHOD__ );
241 $db->
query(
'CREATE TABLE b (b_1, b_2)', __METHOD__ );
250 [
'b_1' => 2,
'b_2' =>
'a' ],
251 [
'b_1' => 3,
'b_2' =>
'b' ],
255 $db->
deleteJoin(
'a',
'b',
'a_1',
'b_1', [
'b_2' =>
'a' ], __METHOD__ );
272 if ( $result !==
true ) {
273 $this->fail( $result );
303 'user_newtalk.user_last_timestamp',
306 $currentDB = DatabaseSqlite::newStandaloneInstance(
':memory:' );
307 $currentDB->sourceFile(
"$IP/maintenance/tables.sql" );
309 $profileToDb =
false;
312 if (
$out ===
'db' ) {
319 if ( $profileToDb ) {
320 $currentDB->sourceFile(
"$IP/maintenance/sqlite/archives/patch-profiling.sql" );
322 $currentTables = $this->
getTables( $currentDB );
323 sort( $currentTables );
325 foreach ( $versions as $version ) {
326 $versions =
"upgrading from $version to $wgVersion";
330 foreach (
$tables as $table ) {
331 $currentCols = $this->
getColumns( $currentDB, $table );
336 "Mismatching columns for table \"$table\" $versions"
338 foreach ( $currentCols as $name => $column ) {
342 (
bool)$cols[$name]->pk,
343 "PRIMARY KEY status does not match for column $fullName $versions"
347 (
bool)$column->notnull,
348 (
bool)$cols[$name]->notnull,
349 "NOT NULL status does not match for column $fullName $versions"
353 $cols[$name]->dflt_value,
354 "Default values does not match for column $fullName $versions"
358 $currentIndexes = $this->
getIndexes( $currentDB, $table );
363 "mismatching indexes for table \"$table\" $versions"
374 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
376 $databaseCreation =
$db->
query(
'CREATE TABLE a ( a_1 )', __METHOD__ );
377 $this->
assertInstanceOf( ResultWrapper::class, $databaseCreation,
"Database creation" );
379 $insertion =
$db->
insert(
'a', [
'a_1' => 10 ], __METHOD__ );
380 $this->
assertTrue( $insertion,
"Insertion worked" );
390 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
391 $db->
query(
'CREATE TABLE testInsertAffectedRows ( foo )', __METHOD__ );
394 'testInsertAffectedRows',
402 $this->
assertTrue( $insertion,
"Insertion worked" );
409 static $maint =
null;
410 if ( $maint ===
null ) {
412 $maint->loadParamsAndArgs(
null, [
'quiet' => 1 ] );
416 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
417 $db->
sourceFile(
"$IP/tests/phpunit/data/db/sqlite/tables-$version.sql" );
431 'searchindex_content',
432 'searchindex_segments',
433 'searchindex_segdir',
435 'searchindex_docsize',
438 foreach ( $excluded as
$t ) {
451 foreach (
$res as $col ) {
452 $cols[$col->name] =
$col;
463 foreach (
$res as $index ) {
464 $res2 =
$db->
query(
"PRAGMA index_info({$index->name})" );
466 $index->columns = [];
467 foreach ( $res2 as $col ) {
468 $index->columns[] =
$col;
470 $indexes[$index->name] = $index;
482 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
484 $row =
$res->fetchRow();
492 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
494 $databaseCreation =
$db->
query(
'CREATE TABLE a ( a_1 )', __METHOD__ );
495 $this->
assertInstanceOf( ResultWrapper::class, $databaseCreation,
"Failed to create table a" );
498 $insertion =
$db->
insert(
'a', [
'a_1' => 10 ], __METHOD__ );
499 $this->
assertTrue( $insertion,
"Insertion failed" );
510 $db = DatabaseSqlite::newStandaloneInstance(
':memory:' );
521 $attributes = Database::attributesFromType(
'sqlite' );
522 $this->
assertTrue( $attributes[Database::ATTR_DB_LEVEL_LOCKING] );
528 $p[
'dbFilePath'] =
':memory:';
529 $p[
'schema'] =
false;
531 return Database::factory(
'SqliteMock', $p );
542 return parent::replaceVars(
$s );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgProfiler
Profiler configuration.
$wgVersion
MediaWiki version number.
if(defined( 'MW_SETUP_CALLBACK')) $fname
Customization point after all loading (constants, functions, classes, DefaultSettings,...
replaceVars( $s)
Override parent visibility to public.
query( $sql, $fname='', $flags=0)
Run an SQL query and return the result.
static newInstance(array $p=[])
testCaseInsensitiveLike()
@coversNothing
testDuplicateTableStructureVirtual()
DatabaseSqlite::duplicateTableStructure.
testInsertIdType()
DatabaseSqlite::insertId.
assertResultIs( $expected, $res)
testAddQuotes( $value, $expected)
provideAddQuotes() DatabaseSqlite::addQuotes
testUpgrades()
Runs upgrades of older databases and compares results with current schema.
static provideAddQuotes()
testInsertAffectedRows()
DatabaseSqlite::insert.
testToString()
\Wikimedia\Rdbms\DatabaseSqlite::__toString
testReplaceVars()
DatabaseSqlite::replaceVars.
testTableName()
DatabaseSqlite::tableName.
testEntireSchema()
@coversNothing
testNumFields()
DatabaseSqlite::numFields.
testDuplicateTableStructure()
DatabaseSqlite::duplicateTableStructure.
testsAttributes()
\Wikimedia\Rdbms\DatabaseSqlite::getAttributes()
testDeleteJoin()
DatabaseSqlite::deleteJoin.
static newForDB(IMaintainableDatabase $db, $shared=false, Maintenance $maintenance=null)
Fake maintenance wrapper, mostly used for the web installer/updater.
static isPresent()
Checks whether PHP has SQLite support.
static checkSqlSyntax( $files)
Checks given files for correctness of SQL syntax.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
this hook is for auditing only RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$page->newPageUpdater($user) $updater