Problem/Motivation
Currently we are able to re-install over an existing database. Core modules are re-installed and we can change site settings. The task state is set to "install_base_system". (This was made possible by solving the routing error thrown when trying to reinstall over an existing database, see parent issue)
We do not want to support this.
In install.core.inc we got the function install_verify_database_settings() that should check if the database connection is valid, but when breaking at this point, I can see that the core tables are already created in the database by the Drupal service.
Proposed resolution
Add a check during the install task "database_verified" to ensure the database is empty, throw an AlreadyInstalledException if not.
This must be done before the core tables creation that occurs before install_verify_database_settings() check.
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | reinstall-error-2352081-18.patch | 4.25 KB | devin carlson |
| #18 | reinstall-error-2352081-18-tests-only.patch | 1.42 KB | devin carlson |
| #16 | reinstall-error-2352081-16.patch | 2.83 KB | devin carlson |
| #16 | interdiff-2352081-14-16.txt | 2.96 KB | devin carlson |
| #14 | interdiff-13-14.txt | 1.63 KB | martin107 |
Comments
Comment #1
myforgedoteu commentedComment #2
myforgedoteu commentedAdding a task to check if the database already have the default schema installed (assuming that a Drupal core is already installed on it).
Throwing the AlreadyInstalledException error in this case.
Comment #4
myforgedoteu commentedComment #5
myforgedoteu commentedyes my bad sending the wrong file :/
Comment #6
lokapujyaComment #7
myforgedoteu commentedComment #8
harvlep commentedComment #9
fabianx commentedNot verified the actual functionality, but here is a code review:
This line is doubled?
nit - whitespace
nit - commented out code
Is this really necessary?
Is this due to the moduleHandler setting the needsRebuild flag is not enough?
nit - whitespace change
Comment #10
fabianx commentedComment #11
berdirThis should not be required anymore.
The issue summary is not very clear nor the issue title.
The purpose of this issue is to *prevent* installation over an existing installation, correct?
Comment #12
myforgedoteu commented@berdir yes, actually if you try to install over an existing database drupal is not checking it properly and install every tables over the existing ones.
Comment #13
martin107 commentedReroll. No conflicts just merging.
Comment #14
martin107 commentedFixes from #9 except (4)
Comment #15
ianthomas_ukRewrote the title/summary to clarify that we want to prevent installation into a populated database, rather than add support for it (see #11/12).
Comment #16
devin carlson commentedI verified that this is an issue and that #14 fixes the problem but needs a reroll.
Attached is an updated patch with the following changes:
Comment should end in a full stop. I also changed the function name to
install_verify_database_ready()to be more inline with the other verification steps (though I'm not set on any name in particular).This seems to have been an accidental change.
The extra line isn't needed.
This has since been removed and is no longer necessary.
This could be worded a bit better and should end in a full stop.
I don't believe that the $install_state argument is necessary.
Comment #17
berdirit should be possible to test this in a pretty easy way? Pick one of the installer tests that we have, then go to core/install.php and assert that you get an already installed message.
Comment #18
devin carlson commentedAdded a test to verify that Drupal can't be reinstalled immediately after installation or when settings.php is removed and the user attempts to reinstalled while an existing installation is available.
Comment #20
swentel commentedExtreme nitpick, should probably be 'verify' ?
I'd be fine with RTBC though and see what the committers think and maybe change this during commit ?
Comment #21
swentel commentedActually let's see what Alex thinks re #20 :)
Comment #22
catchI don't love end($foo); key($foo) as a pattern, but alternatives with array_slice()/array_keys() are worse.
Fixed Verified/Verify on commit.
Looks great otherwise, so committed/pushed to 8.0.x, thanks!