r61319 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61318‎ | r61319 | r61320 >
Date:00:00, 21 January 2010
Author:mah
Status:resolved (Comments)
Tags:
Comment:
Fix up data directory sniffing for sqlite. Touch up description of
data dir. Also, importPost() default values have to match default values in the
HTML form, or they're meaningless.
Modified paths:
  • /trunk/phase3/config/Installer.php (modified) (history)

Diff [purge]

Index: trunk/phase3/config/Installer.php
@@ -628,7 +628,7 @@
629629 $conf->SysopName = importPost( "SysopName", "WikiSysop" );
630630 $conf->SysopPass = importPost( "SysopPass" );
631631 $conf->SysopPass2 = importPost( "SysopPass2" );
632 - $conf->RootUser = importPost( "RootUser", "root" );
 632+ $conf->RootUser = importPost( "RootUser" );
633633 $conf->RootPW = importPost( "RootPW", "" );
634634 $useRoot = importCheck( 'useroot', false );
635635 $conf->LanguageCode = importPost( "LanguageCode", "en" );
@@ -644,7 +644,7 @@
645645 $conf->DBpgschema = importPost( "DBpgschema", "mediawiki" );
646646
647647 ## SQLite specific
648 - $conf->SQLiteDataDir = importPost( "SQLiteDataDir", "" );
 648+ $conf->SQLiteDataDir = importPost( "SQLiteDataDir", '../data' );
649649
650650 ## MSSQL specific
651651 // We need a second field so it doesn't overwrite the MySQL one
@@ -953,9 +953,7 @@
954954 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
955955
956956 } elseif ( $conf->DBtype == 'sqlite' ) {
957 - if ("$wgSQLiteDataDir" == '') {
958 - $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
959 - }
 957+ $wgSQLiteDataDir = $conf->SQLiteDataDir;
960958 echo '<li>Attempting to connect to SQLite database at "' .
961959 htmlspecialchars( $wgSQLiteDataDir ) . '": ';
962960 if ( !is_dir( $wgSQLiteDataDir ) ) {
@@ -1004,7 +1002,9 @@
10051003 } else {
10061004 $myver = $wgDatabase->getServerVersion();
10071005 }
1008 - if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
 1006+ if ( is_callable( array( $wgDatabase, 'initial_setup' ) ) ) {
 1007+ $wgDatabase->initial_setup('', $wgDBname);
 1008+ }
10091009 echo "ok</li>\n";
10101010 } elseif ( $conf->DBtype == 'oracle' ) {
10111011 echo "<li>Attempting to connect to database \"" . htmlspecialchars( $wgDBname ) ."\"</li>";
@@ -1664,9 +1664,9 @@
16651665 aField( $conf, "SQLiteDataDir", "SQLite data directory:" );
16661666 ?></div>
16671667 <div class="config-desc">
1668 - <p>SQLite stores table data into files in the filesystem.
1669 - If you do not provide an explicit path, a "data" directory in
1670 - the parent of your document root will be used.</p>
 1668+ <p>SQLite stores table data into files in the
 1669+ filesystem. By default the path is the "data"
 1670+ directory in your document root.</p>
16711671
16721672 <p>This directory must exist and be writable by the web server.</p>
16731673 </div>
@@ -1789,6 +1789,10 @@
17901790 $convert = ($conf->ImageMagick ? $conf->ImageMagick : "/usr/bin/convert" );
17911791 $rights = ($conf->RightsUrl) ? "" : "# ";
17921792 $hashedUploads = $conf->safeMode ? '' : '# ';
 1793+ $sqliteDataDir = escapePhpString( realpath($conf->SQLiteDataDir) );
 1794+ if ( substr_compare( $conf->IP, $sqliteDataDir, 0 ) ) {
 1795+ $sqliteDataDir = substr_replace( $sqliteDataDir, '$IP', 0, strlen($conf->IP) );
 1796+ }
17931797
17941798 if ( $conf->ShellLocale ) {
17951799 $locale = '';
@@ -1881,7 +1885,7 @@
18821886 } elseif( $conf->DBtype == 'sqlite' ) {
18831887 $dbsettings =
18841888 "# SQLite-specific settings
1885 -\$wgSQLiteDataDir = \"{$slconf['SQLiteDataDir']}\";";
 1889+\$wgSQLiteDataDir = \"{$sqliteDataDir}\";";
18861890 } elseif( $conf->DBtype == 'mssql' ) {
18871891 $dbsettings =
18881892 "# MSSQL specific settings

Follow-up revisions

RevisionCommit summaryAuthorDate
r61656follow up r61319...mah08:13, 29 January 2010
r62751Rv part of r61319 that always sets $wgSQLiteDataDir to "$IP"maxsem19:47, 20 February 2010

Comments

#Comment by 😂 (talk | contribs)   16:50, 21 January 2010

Just as a minor side note, I'm planning to finalize and merge the new-installer branch into 1.17. If you're in installer/upgrade cleanup, I suggest checking out that branch :)

#Comment by MaxSem (talk | contribs)   15:22, 22 January 2010
+	$conf->SQLiteDataDir = importPost( "SQLiteDataDir", '../data' );

Providing a relative directory for SQLite may result in different absolute paths in web and CLI modes. Ideally, that line should look like $conf->SQLiteDataDir = importPost( "SQLiteDataDir", dirname( $_SERVER['DOCUMENT_ROOT'] ) . '/data' );, but that may result in information disclosure vulnerability, albeit minor.

#Comment by Tim Starling (talk | contribs)   06:34, 28 January 2010

Right, you can't depend on the current directory. It could be '$IP/../data', the code is there already to replace the string $IP with the real $IP.

#Comment by MarkAHershberger (talk | contribs)   02:22, 3 February 2010

addressed in r61656

#Comment by MarkAHershberger (talk | contribs)   02:25, 3 February 2010

addressed in r61656

#Comment by MarkAHershberger (talk | contribs)   02:28, 3 February 2010

addressed in r61656

#Comment by MarkAHershberger (talk | contribs)   02:32, 3 February 2010

addressed in r61656

#Comment by MarkAHershberger (talk | contribs)   02:37, 3 February 2010

addressed in r61656

#Comment by MarkAHershberger (talk | contribs)   02:45, 3 February 2010

addressed in r61656

#Comment by MarkAHershberger (talk | contribs)   03:19, 3 February 2010

addressed in r61656

Status & tagging log