MarkAHershberger has submitted this change and it was merged.

Change subject: Web installer: always autoselect some DB type
......................................................................


Web installer: always autoselect some DB type

If the PHP mysql extension were not available, none of the DB type
radio buttons would be selected, and if the form were submitted
without selecting any of them, a PHP fatal error would occur
because of a lack of input validation.

So have the installer autoselect a DB type other than mysql if
necessary, and add a simple check to prevent a fatal error if all
radio buttons nevertheless end up deselected for some unknown reason.

Bug: 47489
Change-Id: Ic456899028c054a761d172df8ec32f6a26dc5b97
---
M RELEASE-NOTES-1.21
M includes/installer/WebInstallerPage.php
2 files changed, 13 insertions(+), 1 deletion(-)

Approvals:
  MarkAHershberger: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.21 b/RELEASE-NOTES-1.21
index bda38f6..28a039d 100644
--- a/RELEASE-NOTES-1.21
+++ b/RELEASE-NOTES-1.21
@@ -215,6 +215,8 @@
 * (bug 45143) jquery.badge: Treat non-Latin variants of zero as zero as well.
 * (bug 46151) mwdocgen.php should not ignore exit code of doxygen command.
 * (bug 41889) Fix $.tablesorter rowspan exploding for complex cases.
+* (bug 47489) Installer now automatically selects the next-best database type 
if
+  the PHP mysql extension is not loaded, preventing fatal errors in some cases.
 
 === API changes in 1.21 ===
 * prop=revisions can now report the contentmodel and contentformat.
diff --git a/includes/installer/WebInstallerPage.php 
b/includes/installer/WebInstallerPage.php
index 085456d..7883029 100644
--- a/includes/installer/WebInstallerPage.php
+++ b/includes/installer/WebInstallerPage.php
@@ -460,7 +460,14 @@
                $this->addHTML( $this->parent->getInfoBox(
                        wfMessage( 'config-support-info', trim( $dbSupport ) 
)->text() ) );
 
-               foreach ( $this->parent->getVar( '_CompiledDBs' ) as $type ) {
+               // It's possible that the library for the default DB type is 
not compiled in.
+               // In that case, instead select the first supported DB type in 
the list.
+               $compiledDBs = $this->parent->getVar( '_CompiledDBs' );
+               if ( !in_array( $defaultType, $compiledDBs ) ) {
+                       $defaultType = $compiledDBs[0];
+               }
+
+               foreach ( $compiledDBs as $type ) {
                        $installer = $this->parent->getDBInstaller( $type );
                        $types .=
                                '<li>' .
@@ -494,6 +501,9 @@
        public function submit() {
                $r = $this->parent->request;
                $type = $r->getVal( 'DBType' );
+               if ( !$type ) {
+                       return Status::newFatal( 'config-invalid-db-type' );
+               }
                $this->setVar( 'wgDBtype', $type );
                $installer = $this->parent->getDBInstaller( $type );
                if ( !$installer ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/61189
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic456899028c054a761d172df8ec32f6a26dc5b97
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_21
Gerrit-Owner: MarkAHershberger <mhershber...@wikimedia.org>
Gerrit-Reviewer: MarkAHershberger <mhershber...@wikimedia.org>
Gerrit-Reviewer: PleaseStand <pleasest...@live.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to