Problem/Motivation
When reinstalling Drupal in the same directory as a previous installation, in previous versions you could just drop all the database tables and run install.php. This no longer works in Drupal 8.x.
The reason is that Drupal 8.x puts some compiled files in:
sites/default/files/php
sites/default/files/config
sites/default/files/styles
What's more, all of these files are owned by the web server user, so they can't even easily be removed in general (on a Linux system, you would need to use sudo to remove them).
If the "php" or "config" files are present and you run install.php, you get errors on-screen, although the installation might actually work. I am not sure if the "styles" files cause any particular trouble or not?
Proposed resolution
The installer, if it figures out that there is no database and it is going to install Drupal, should remove the config, php, and styles directories under sites/default/files.
Remaining tasks
Make a patch. Test it. Perhaps make an automated test if possible?
User interface changes
Drupal will be able to reinstall after just removing the database tables.
API changes
None.
Original report by mgifford
I just got this error in my error log:
PHP Fatal error: Call to a member function get() on a non-object in core/modules/views/lib/Drupal/views/ViewStorageController.php on line 26, referer: core/install.php?langcode=en&profile=standard&op=start&id=1
After getting this AJAX error:
The installation has encountered an error.
Please continue to the error page
An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: http://example.com/core/install.php?langcode=en&profile=standard&id=1&op... StatusText: Internal Server Error ResponseText:
http://example.com/core/install.php?langcode=en&profile=standard&op=star...
This is on a Mac locally, but not using MAMP.
Comment | File | Size | Author |
---|---|---|---|
#5 | vdc-1895100-5.patch | 883 bytes | tim.plunkett |
#4 | Screen Shot 2013-01-23 at 8.16.23 AM.png | 65.26 KB | mgifford |
Comments
Comment #1
tim.plunkettCan you provide some steps to reproduce?
Comment #2
ParisLiakos CreditAttribution: ParisLiakos commentedi had this as well, just
rm -rf
yourfiles/*
Comment #3
tim.plunkettAh, yes, a stale compiled container would do that.
Comment #4
mgiffordI've done that, nixed the DB & tried it again. Twice.
Still I'm not able to install. @tim.plunkett - could this be stored somewhere else? I've got a
git reset --hard
several times now & am pulling the latest release. Puzzled why it's dying.Comment #5
tim.plunkett#1668820-130: Concept, base class, and interface for Configurables (e.g., node types, image styles, vocabularies, views, etc) also found this bug, and wrote a patch!
But it doesn't explain WHAT the $entity is if its not an object.
Can you try this debugging patch and report what it prints out?
I'm still very unable to reproduce.
Comment #6
damiankloip CreditAttribution: damiankloip commentedI think you need to remove your files folder and maybe just rip out your settings.php file, and let drush make a new one. That should work. I think ....
Comment #7
alexrayu CreditAttribution: alexrayu commentedThe entity is
null
if it's not an object, in this case (at least it was for me).Comment #8
tim.plunkettThe array is supposed to be entity objects, keyed by their entity ID.
You can't see the entity ID from within the current loop, so I added a debug one.
I have installed both with drush and through the UI in multiple versions of PHP in both native LAMP and also MAMP. I'm convinced you have something stale causing this, and would not be able to reproduce on a truly clean install, as @damiankloip describes.
Comment #9
webchickDoing this for now until we get more details.
Comment #10
quicksketchI just got this too after attempting to reinstall Drupal 8 over the top of an existing Drupal 8. Clearly dropping the database alone isn't sufficient. After tossing the files directory, Drupal could install normally again for me.
Comment #11
webchickYeah, be warned that the sites/default/files/php directory now needs to be cleared out on site re-install. It contains a compiled version of the container or some such Symfony nonsense I don't totally understand.
So if that fixed it, I'm inclined to mark this a support request and fixed.
Comment #12
mgiffordYou have to remove that directory with force.
In talking to @Lee Rowlands, he said that he's had to use the full path, and that even
sudo rm sites/default/files/php/service_container/service_container_prod_.php/*
does not work. He explained to me that it is so locked down because that is the compiled container and Drupal 8 now writes PHP to the file system.I was able to remove it on my system by
sudo rm -fr sites/default/files
and then by just recreating the files directory.Comment #13
webchickNo, it needs to be sites/default/files/php or, even more ideally, sites/default/files/*
Can you explain why this is a bug?
Comment #14
ParisLiakos CreditAttribution: ParisLiakos commentedThe php folder is not writeable for your user, because it was created by apache...
Doing a simple rm wont kill it due to permissions
you need to use sudo and remove the whole folder..something like
sudo rm -rf sites/default/files/*
or just php folder
sudo rm -rf sites/default/files/php/*
Or, if you dont have sudo access write a php script that does this and call it from your browser, so apache itself will delete it.
This is not a bug. drupal cannot guess if you want to kill it and remove this file for you, you have to do this yourself, like clearing the database step
Comment #15
mgiffordI'd say it's a bug because for most folks they are going to be shocked that they have to have root access in order to re-install their Drupal system. It could be that it just needs to be better documented, but for most of us a "stale compiled container" is a new thing for most of us. If this is going to be a semi-common issue for folks who are starting to play with D8 then errors with ViewStorageController.php might need a bit more explanation.
It's the Symfony stuff that most of us might really grok after using it regularly for a few months that is going to be hard for the translation. That's why I think it's a bug.
Comment #16
mgifford@rootatwc didn't mean to change Categories. I'm also not fixated on this being a bug, but rather making sure it's acknowledged as something that's going to need to be prepared for as folks get ready to take a look at it.
Might be good to offer that sample PHP script (not that it's hard), but we want folks to love D8! We want to bring along the D6 & D7 admins now and get them excited about moving up as soon as they can.
Comment #17
ParisLiakos CreditAttribution: ParisLiakos commentedWell, the way you put it, it is either a documentation task, or a new feature request against installation system, for it to be able to catch whether a container is broken and if yes, then remove it..
But anyway i wont play status wars anymore
Comment #18
ParisLiakos CreditAttribution: ParisLiakos commentedugh..x-post..refactoring as task for now
Comment #19
webchickSwitching components, removing a comma.
Comment #20
mgiffordThanks all. I just want a nice experience for folks who start with D8. I'm looking back now on our D7 sites and just finding them very clunky now. So much great stuff has gotten into D8, I want folks to be excited about it.
Comment #21
jhodgdonOK... So where should we put this documentation?
IMO, it would be nice if in the install.php script, in the requirements phase, it would check to see if there are compiled generated containers (whatever they are) and either tell you how to remove them or just remove them if it can? I mean, it does this now for creating the files directory and other things... right?
If for some reason this isn't acceptable, then I guess we would need a patch to the install readme files (maybe both?), but it sure seems like rather than crashing, a polite message during the requirements phase of installation would be preferable. :)
Comment #22
sunI agree. The installer should be capable of doing so. It only needs to ensure that this only happens after the check whether there is a Drupal installation already. Retitling this issue.
Comment #23
jhodgdonI just created an issue summary for this issue, partly because I noticed that the "config" directory under sites/default/files can (I think?) cause problems too.
Comment #24
DamienMcKennaRelated: #1908310: Drupal without DB but with site config throws uninformative error
Comment #24.0
DamienMcKennaAdded issue summary
Comment #25
sunFWIW, I'm using this reinstall.php script in my D8 document root, in order to quickly and easily destroy and re-install my dev site.
Meanwhile, I'm no longer sure whether doing the proposed change here is a sane thing to do — the installer exists to create things, not to delete your data... ;)
At minimum, I guess we'd need a confirmation screen on which you'd explicitly have to confirm that your existing data is going to be deleted.
Comment #26
BerdirI think this has been resolved?
Comment #27
jhodgdonAre you saying it's now possible to reinstall without removing sites/default/files?
Comment #29
valthebaldPerforming the triage of this issue as part of the DrupalCon New Orleans.
This issue was definitely reproducable with earlier versions of 8.x core. However, the following steps:
went smoothly without deleting sites/default/files/*
Also, I don't see a reason why this could be a major issue, changing priority
Comment #30
xjmThanks @valthebald! (Untagging since we decided it was not current nor major.)