Fix installation failure due to unexpected dbpath under CLI installation
authorRazeSoldier <razesoldier@outlook.com>
Sat, 1 Jun 2019 16:15:34 +0000 (00:15 +0800)
committerRazeSoldier <razesoldier@outlook.com>
Mon, 22 Jul 2019 16:39:18 +0000 (00:39 +0800)
commitf2c220adfc1487c01fffa896be7759c6abfc74b1
tree1a6138b208ff11b4945b7f37355e720f136e6a36
parent7436202ee65b8878664dfc36d731ad767ce2e35f
Fix installation failure due to unexpected dbpath under CLI installation

1. Make sure `wgSQLiteDataDir` is not empty.
2. Fix a logic bug
  In the current logic, in web environment, SqliteInstaller::dataDirOKmaybeCreate()
  will be executed twice, first in the DBConnect page [1] (with $create=true),
  and the second time in Installer::performInstallation() [2] (with $create=false),
  this is a sanity check.
  But in cli environment, SqliteInstaller::dataDirOKmaybeCreate() will
  be only executed once, called by Installer::performInstallation() (with $create=false).
  So the Cli installer will abort because the data directory is checked
  without the behavior of creating the directory.
  In this case, I split dataDirOKmaybeCreate() into checkDataDir() and
  createDataDir() according to its responsibility. And for web installation,
  we just check the directory on DBConnect page instead of creating it and
  then actually creating it in setupDatabase().
3. Add a unit test for SqliteInstaller::dataDirOKmaybeCreate

[1] DBConnect page call SqliteInstaller::submitConnectForm(),
  ::submitConnectForm() call ::dataDirOKmaybeCreate()
[2] Installer::performInstallation() call SqliteInstaller::setupDatabase(),
  ::setupDatabase() call ::dataDirOKmaybeCreate()

Bug: T217855
Change-Id: I139036b265716e9898fb76ba907c194f005ea318
includes/installer/SqliteInstaller.php
tests/phpunit/unit/includes/installer/SqliteInstallerTest.php [new file with mode: 0644]