r50328 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50327‎ | r50328 | r50329 >
Date:05:43, 8 May 2009
Author:tstarling
Status:deferred
Tags:
Comment:
(bug 17611) Provide a sensible error message on install when the SQLite data directory is wrong. For backport to 1.15. Achieved by layering another collection of ugly hacks on top of config/index.php, in the hopes that the combined weight of hackishness might convince Brion to allow me to finish the new installer.
Modified paths:
  • /trunk/phase3/HISTORY (modified) (history)
  • /trunk/phase3/config/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/HISTORY
@@ -327,6 +327,8 @@
328328 * (bug 18601) generator=backlinks returns invalid continue parameter
329329 * (bug 18597) Internal error with empty generator= parameter
330330 * (bug 18617) Add xml:space="preserve" attribute to relevant tags in XML output
 331+* (bug 17611) Provide a sensible error message on install when the SQLite data
 332+ directory is wrong.
331333
332334 === Languages updated in 1.15 ===
333335
Index: trunk/phase3/config/index.php
@@ -819,7 +819,9 @@
820820 $wgTitle = Title::newFromText( "Installation script" );
821821 error_reporting( E_ALL );
822822 print "<li>Loading class: " . htmlspecialchars( $dbclass ) . "</li>\n";
823 - $dbc = new $dbclass;
 823+ if ( $conf->DBtype != 'sqlite' ) {
 824+ $dbc = new $dbclass;
 825+ }
824826
825827 if( $conf->DBtype == 'mysql' ) {
826828 $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
@@ -903,7 +905,46 @@
904906 $myver = $wgDatabase->getServerVersion();
905907 }
906908 if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
907 -
 909+
 910+ } elseif ( $conf->DBtype == 'sqlite' ) {
 911+ if ("$wgSQLiteDataDir" == '') {
 912+ $wgSQLiteDataDir = dirname($_SERVER['DOCUMENT_ROOT']).'/data';
 913+ }
 914+ echo "<li>Attempting to connect to SQLite database at \"" .
 915+ htmlspecialchars( $wgSQLiteDataDir ) . "\"";
 916+ if ( !is_dir( $wgSQLiteDataDir ) ) {
 917+ if ( is_writable( dirname( $wgSQLiteDataDir ) ) ) {
 918+ $ok = wfMkdirParents( $wgSQLiteDataDir, $wgSQLiteDataDirMode );
 919+ } else {
 920+ $ok = false;
 921+ }
 922+ if ( !$ok ) {
 923+ echo ": cannot create data directory</li>";
 924+ $errs['SQLiteDataDir'] = 'Enter a valid data directory';
 925+ continue;
 926+ }
 927+ }
 928+ if ( !is_writable( $wgSQLiteDataDir ) ) {
 929+ echo ": data directory not writable</li>";
 930+ $errs['SQLiteDataDir'] = 'Enter a writable data directory';
 931+ continue;
 932+ }
 933+ $dataFile = "$wgSQLiteDataDir/$wgDBname.sqlite";
 934+ if ( file_exists( $dataFile ) && !is_writable( $dataFile ) ) {
 935+ echo ": data file not writable</li>";
 936+ $errs['SQLiteDataDir'] = "$wgDBname.sqlite is not writable";
 937+ continue;
 938+ }
 939+ $wgDatabase = new DatabaseSqlite( false, false, false, $wgDBname, 1 );
 940+ if (!$wgDatabase->isOpen()) {
 941+ print ": error: " . htmlspecialchars( $wgDatabase->lastError() ) . "</li>\n";
 942+ $errs['SQLiteDataDir'] = 'Could not connect to database';
 943+ continue;
 944+ } else {
 945+ $myver = $wgDatabase->getServerVersion();
 946+ }
 947+ if (is_callable(array($wgDatabase, 'initial_setup'))) $wgDatabase->initial_setup('', $wgDBname);
 948+ echo "ok</li>\n";
908949 } else { # not mysql
909950 error_reporting( E_ALL );
910951 $wgSuperUser = '';

Follow-up revisions

RevisionCommit summaryAuthorDate
r50329Backported r50328: bug 17611, SQLite installer user input validation issuetstarling05:51, 8 May 2009

Status & tagging log