*/
class SqliteInstaller extends DatabaseInstaller {
+ /**
+ * @var DatabaseSqlite
+ */
+ public $db;
+
protected $globalNames = array(
'wgDBname',
'wgSQLiteDataDir',
$this->getTextBox( 'wgDBname', 'config-db-name', array(), $this->parent->getHelpBox( 'config-sqlite-name-help' ) );
}
- /*
+ /**
* Safe wrapper for PHP's realpath() that fails gracefully if it's unable to canonicalize the path.
+ *
+ * @param $path string
+ *
+ * @return string
*/
private static function realpath( $path ) {
$result = realpath( $path );
return $result;
}
+ /**
+ * @return Status
+ */
public function submitConnectForm() {
$this->setVarsFromRequest( array( 'wgSQLiteDataDir', 'wgDBname' ) );
# Try realpath() if the directory already exists
$dir = self::realpath( $this->getVar( 'wgSQLiteDataDir' ) );
$result = self::dataDirOKmaybeCreate( $dir, true /* create? */ );
- if ( $result->isOK() )
- {
+ if ( $result->isOK() ) {
# Try expanding again in case we've just created it
$dir = self::realpath( $dir );
$this->setVar( 'wgSQLiteDataDir', $dir );
return $result;
}
+ /**
+ * @param $dir
+ * @param $create bool
+ * @return Status
+ */
private static function dataDirOKmaybeCreate( $dir, $create = false ) {
if ( !is_dir( $dir ) ) {
if ( !is_writable( dirname( $dir ) ) ) {
# if it's still writable
if ( $create ) {
wfSuppressWarnings();
- $ok = wfMkdirParents( $dir, 0700 );
+ $ok = wfMkdirParents( $dir, 0700, __METHOD__ );
wfRestoreWarnings();
if ( !$ok ) {
return Status::newFatal( 'config-sqlite-mkdir-error', $dir );
return Status::newGood();
}
+ /**
+ * @return Status
+ */
public function openConnection() {
global $wgSQLiteDataDir;
$dir = $this->getVar( 'wgSQLiteDataDir' );
$dbName = $this->getVar( 'wgDBname' );
try {
- # FIXME: need more sensible constructor parameters, e.g. single associative array
+ # @todo FIXME: Need more sensible constructor parameters, e.g. single associative array
# Setting globals kind of sucks
$wgSQLiteDataDir = $dir;
$db = new DatabaseSqlite( false, false, false, $dbName );
return $status;
}
+ /**
+ * @return bool
+ */
public function needsUpgrade() {
$dir = $this->getVar( 'wgSQLiteDataDir' );
$dbName = $this->getVar( 'wgDBname' );
return parent::needsUpgrade();
}
+ /**
+ * @return Status
+ */
public function setupDatabase() {
$dir = $this->getVar( 'wgSQLiteDataDir' );
return $this->getConnection();
}
+ /**
+ * @return Staus
+ */
public function createTables() {
$status = parent::createTables();
return $this->setupSearchIndex( $status );
}
+ /**
+ * @param $status Status
+ * @return Status
+ */
public function setupSearchIndex( &$status ) {
global $IP;
return $status;
}
+ /**
+ * @return string
+ */
public function getLocalSettings() {
$dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgSQLiteDataDir' ) );
return