MediaWiki  1.23.12
sqlite.inc
Go to the documentation of this file.
1 <?php
29 class Sqlite {
30 
35  public static function isPresent() {
36  return extension_loaded( 'pdo_sqlite' );
37  }
38 
47  public static function checkSqlSyntax( $files ) {
48  if ( !Sqlite::isPresent() ) {
49  throw new MWException( "Can't check SQL syntax: SQLite not found" );
50  }
51  if ( !is_array( $files ) ) {
52  $files = array( $files );
53  }
54 
55  $allowedTypes = array_flip( array(
56  'integer',
57  'real',
58  'text',
59  'blob', // NULL type is omitted intentionally
60  ) );
61 
62  $db = new DatabaseSqliteStandalone( ':memory:' );
63  try {
64  foreach ( $files as $file ) {
65  $err = $db->sourceFile( $file );
66  if ( $err != true ) {
67  return $err;
68  }
69  }
70 
71  $tables = $db->query( "SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ );
72  foreach ( $tables as $table ) {
73  if ( strpos( $table->name, 'sqlite_' ) === 0 ) {
74  continue;
75  }
76 
77  $columns = $db->query( "PRAGMA table_info({$table->name})", __METHOD__ );
78  foreach ( $columns as $col ) {
79  if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
80  $db->close();
81  return "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'";
82  }
83  }
84  }
85  } catch ( DBError $e ) {
86  return $e->getMessage();
87  }
88  $db->close();
89  return true;
90  }
91 };
Sqlite
This class contains code common to different SQLite-related maintenance scripts.
Definition: sqlite.inc:29
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$files
$files
Definition: importImages.php:67
$tables
namespace and then decline to actually register it RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist & $tables
Definition: hooks.txt:815
DatabaseSqliteStandalone
This class allows simple acccess to a SQLite database independently from main database settings.
Definition: DatabaseSqlite.php:974
MWException
MediaWiki exception.
Definition: MWException.php:26
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$columns
if(! $in) $columns
Definition: Utf8Test.php:50
DBError
Database error base class.
Definition: DatabaseError.php:28
Sqlite\isPresent
static isPresent()
Checks whether PHP has SQLite support.
Definition: sqlite.inc:35
$file
if(PHP_SAPI !='cli') $file
Definition: UtfNormalTest2.php:30
Sqlite\checkSqlSyntax
static checkSqlSyntax( $files)
Checks given files for correctness of SQL syntax.
Definition: sqlite.inc:47
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:1632