Updated: Comment #32
Problem/Motivation
Since there are many circumstances under which users may need to do this, we should make it super easy to do.
My experience today was:
1) I got Fatal error: Call to a member function get() on a non-object in /Users/webchick/Sites/8.x/core/lib/Drupal.php on line 241 when git pulling.
2) I thought to myself "Hm. I wonder if that newfangeldy rebuild.php script can fix that?"
3) I found the script in core/rebuild.php (this took awhile... I expected it in the root directory along with index.php and update.php)
4) I went to http://8x.localhost/core/rebuild.php.
5) I was redirected back to index.php (I only caught this because I was being extra observant) and still got the same error.
6) I did it again to make sure I wasn't nuts.
7) I checked README.txt for "rebuild" and found nothing.
8) I pinged chx on IRC who said it's a settings.php thing I need to set to TRUE. No idea how I would've discovered that otherwise, and "ping chx on IRC" is not a scalable solution to this issue. :D
Compare this with hitting update.php as an anonymous user:

It tells me what went wrong and exactly what I need to do to fix it.
Proposed resolution
Can we please make rebuild.php work in a similar way?
Remaining tasks
- (novice) change maintenance_access_denied_page() to be a theme function or a twig template. See #28
- open issue to refactor Kernel things. See #26
- open issue to refactor the minimal environment in install_begin_request() into a stand-alone function. See #31
- open issue for cleaning up default.settings.php
User interface changes
API changes
?
| Comment | File | Size | Author |
|---|---|---|---|
| #52 | drupal8.rebuild-access-ux.52.patch | 481 bytes | sun |
| #51 | 2160057-51.patch | 9.07 KB | star-szr |
Comments
Comment #1
chx commented> "ping chx on IRC" is not a scalable solution to this issue. :D
We can, however, add a factoid to the bot there. Would that be better? :P
Comment #2
chx commentedSurely we can get to the maintenance page -- likely we will need to replace a couple services but update.php (and install.php) already does this.
Comment #3
webchickActually, apparently I wasn't observing carefully enough, because there is a redirect from /rebuild.php to /core/rebuild.php, which is consistent with install and update. So ignore that. :)
Tagging w/ DX.
Comment #4
chx commentedNR so the bot tests this; it's a stepping stone not a complete script. I know I could possibly pass in and check config_verified in $install_state but just let's not do that. Let's make it explicit that config_verified gets set in here.
Comment #5
chx commentedNever write code when you can reuse.
install_begin_requestsets up Drupal without a database, so I reuse that. To generate an update.php access denied screen, guess what? I reuse theupdate_access_denied_page.Comment #6
jibrandouble ;
Please use heredoc.
I want to add screen shot but I don't know how to access this page
Comment #7
jibranreviewed code has code tags that is why last post is messy.
Comment #8
chx commentedI edited your comment and replaced the opening less-than signs with an angle ∠ character looks funny but it doesn't break so badly.
To reach this page just go to rebuild.php instead of index.php much like install.php or update.php.
The original wasn't using heredoc so why would I...?
The reason I didn't attach a screenshot because the screen looks the exact same as the update.php screen.

Comment #9
jibranThank you for the fix and screenshot. I am unable to find anything in this so RTBC. Let's see what @webchick thinks about it.
Comment #10
xjm8: 2160057_5.patch queued for re-testing.
Comment #12
webchickDoing testbot's job for it...
Comment #13
herom commented8: 2160057_5.patch queued for re-testing.
"Warning: mkdir(): No space left on device". hmm... let's test this again.
Comment #14
herom commentedand rtbc per #9.
Comment #15
tstoecklerI'm not sure this is intended. If it is we should change it for both requires not only for one of two. That is just weird.
In theory it would be cooler if this weren't called update_... but $something_generic_that_encompasses_update_and_rebuild_... but I really couldn't find anything better, so just noting here for reference.
It *feels* like it might make sense to move more of that into update_access_denied_page() but I'm not sure, do you have thoughts on that?
Marking needs work for 1.
Comment #16
tstoecklerI just realized that DRUPAL_ROOT is defined in bootstrap.inc these days. I still think it looks a bit weird (because inconsistent) as it is, but it makes sense technically.
Back to RTBC. Sorry for holding this up.
Comment #17
webchickThis patch works great, thanks!
One nit:
Calling "update_access_denied_page" on "rebuild.php" is goofy. :) Let's rename that function to something more general like maintenance_access_denied_page().
But then, it really no longer makes sense in update.inc. I notice there's a includes/theme.maintenance.inc and this is outputting markup. So maybe in there?
Comment #18
chx commentedComment #19
benjy commentedThis isn't really accurate?
This should use $script_name
Comment #20
chx commentedComment #21
chx commentedRe #15, 1. was retracted in #16, 2. was requested by webchick too and addressed 3. if you are not sure and it is update.php then my rule is "do not touch unless there's a pressing need" because it's update.php and it breaks.
Comment #22
xjmTruer words. :)
Attached just fixes an ungrammatical comment.
Comment #24
benjy commentedI'm presuming t() isn't available in
maintenance_access_denied_page()?Patch looks goods.
Comment #25
tstoecklerRe #24: Hmm... interesting question. Here the function is just being moved, though, the code is pre-existing.
Comment #26
sunHm. I really do not like the idea of piggy-backing on the
install_begin_request()function.Yes, re-using existing code is a good idea, but
install_begin_request()in its current form is a total abomination, a dumping ground of pre-kernel era code that completely went out of control.In addition,
install_begin_request()has to account for much more — a completely empty Drupal environment.→ But both the
rebuild.phpandupdate.phpscripts can and should safely assume that e.g.settings.php& Co exists already...→ Hence, there's no need to perform a dozen of full filesystem scans to discover available installation profiles and translation files, nor any other of the (very) expensive operations.
Instead, this issue and change proposal tells us that we really should have properly defined variants of DrupalKernel/CoreServiceProvider for very discrete use-cases; i.e.:
Whereas (1)
MaintenanceKernelwould be used byrebuild.php,update.php, andauthorize.php, and (2)InstallerKernelwould be used byinstall_begin_request()in the first 2-3 installer screens untilbase_system_verifiedis TRUE (as in HEAD, but not inlined into that horrible function).Comment #27
jibranI agree with #26 but this issue is about usability of rebuild.php not about the architecture so I think we can discuss all the above valid points in follow up issue because tbh the fix provided in this issue has nothing to do with the things already in core.
Or we can postpone this on follow up issue so that we can fix the architecture problems first.
Comment #28
webchickYeah, I agree that Kernelizing All The Things™ is ultimately the right solution to this, and we should definitely open up a follow-up for that... but I don't want to hold this one up over that since it sounds like a major undertaking and the UX of this script is going to be fairly critical, given how often people are going to need to do this.
Crap, sorry, my bad. I wasn't clear in my previous review. I meant that this function should be made into a theme function since it outputs markup. That would also make it unified with the other things in this file.
Since this is fairly straight-forward to do, I'm tentatively tagging DrupalWorkParty so that some enterprising contributor who wishes to work on D8 issues for Drupal's birthday might come across it. :D
Comment #29
star-szrPlease don't shoot me but it would probably be nicer if the themeable output could be made into a Twig template.
Comment #30
webchickI agree that would be nicer, but in this case all of the other functions in that file are theme functions. Therefore, that feels out of scope here, at least to me. I'm happy to hear arguments that I'm on crack and we should not be introducing any more theme functions to convert, though. :)
Comment #31
sunI can understand the reservations regarding the larger suggestion I made in #26.
However, this aspect still stands:
Performing these expensive operations for the rebuild/update scripts would be nuts.
We know that we have a settings.php, we know that we have $databases, $config_directories, and so on, and we know the installation profile to use. No need to assume less where more is a given.
The resolution path is simple: Just do the reverse:
Of course, @Crell will arguably and reasonably kill us for just moving this pre-kernel era code around.
Lastly, I do not see a reason for why this change needs to be rushed into core? — It's a nice-to-have DX improvement, but developers are easily able to figure it out and the new UI does not really help DX. → A much better way to address the root cause would be to clean up default.settings.php to not have a 1:99 code to comment ratio...
I actually find it very icky that every Drupal site on this planet outputs these scary pages:
https://drupal.org/update.php
https://drupal.org/install.php
https://drupal.org/authorize.php
(Only the last one shows appropriate output [nothing], but alas, wrong theme.)
Comment #32
chx commented> Performing these expensive operations for the rebuild/update scripts would be nuts.
This patch deliberately tries to make the minimal changes. Performance considerations on the rebuild script are absolutely irrelevant.
Comment #33
yesct commentedupdated issue summary with remaining tasks
seems like what we have left to do is in part to decide what we need to do here and what should be done somewhere else, what can we do without making things worse.
Comment #34
sun@webchick: Could you explain why you think that rebuild.php needs to be a UX-fancy page?
Let me try to formulate some expectations (please state whether/where you disagree):
Can we agree on these or do you see it differently? The intended audience matters a lot for my argumentation.
I guess the main points I disagree with are these:
Why does rebuild.php need this big wall of (un)helpful text?
Why does the output have to be a fully themed page?
Why is a one-line
print-ed message not sufficient?→ For the intended developer audience, this should be more than sufficient:
English only, because Drupal developers need to understand basic English anyway.
That's two lines of
printstatements to resolve this issue and the root cause: the lack of a simple hint.Comment #35
chx commentedComment #36
chx commentedComment #37
chx commented> Content publishers will never ever see or have to access this script.
False. They might hit a bug and there's not always a developer around.
> Site builders will not access this script (because they do not change code).
False. For example, do you have any idea what happens when the module enable page times out? I absolutely have no idea but I am relatively certain it will be nasty.
> Themers will not access this script (because they do not change kernel/DI code).
False. Themers mess with PHP and again who knows what their broken PHP might corrupt.
> Developers may need to run this script (but that should be an edge-case).
False. It's not edge case-y at all. Developers will need to run this all the bloody time. Don't forget that we have stepped outside of the database transaction realm by using files in the active config -- actually that's a great argument in favor of the "let's put the active storage in the db".
Comment #38
chx commentedComment #39
chx commentedComment #40
chx commented> what can we do without making things worse.
There's nothing this issue makes worse. It is an improvement, plain and simple irregardless of the false distractions brought up.
Comment #41
sun@chx: It appears clear that you have different expectations for the final Drupal 8.0 release. Wherever you said "False", I would not accept a "False" in terms of my expectations:
If rebuild.php will (1) have to be used by anyone else than developers hacking on code and (2) be needed too frequently, then we haven't delivered a product.
Disagreement is fine.
Regardless of that difference in expectations, I still do not see why we (1) need a fully themed page and (2) any more output other than the simple hint that has been suggested in #34?
Comment #42
chx commented> If rebuild.php will (1) have to be used by anyone else than developers hacking on code and (2) be needed too frequently, then we haven't delivered a product.
Then, apparently we haven't delivered D7 either because https://drupal.org/project/registry_rebuild became necessary. This time we rather anticipate the worst and be prepared. We had a WSOD handbook page for seven years now. Then, we haven't delivered a product in seven years? Come now.
> I still do not see why we (1) need a fully themed page and (2) any more output other than the simple hint that has been suggested in #34?
Because it costs practically nothing in developer time to create a nice page unless someone wastes a ton of time debating a trivial change.
Comment #44
star-szrFWIW I think this is an important improvement.
@webchick/#30:
Yes theme.maintenance.inc only contains theme functions but all the maintenance related theme functions are defined in drupal_common_theme(), here is a subset which does include two Twig templates:
My main motivation to suggest Twig for this output isn't necessarily that I want one less thing to convert later but that I think it would be easier to create and maintain as a Twig template. Working on it.
Comment #45
star-szrHere we go. Theme function version included as well for fun, but I kept the string concatenation bug that disappears immediately when we change the output to Twig :)
Theme function:

Twig template:

Edit: Ignore
2160057-42-theme.patch, I uploaded that then hid it after updating the comment #, not sure why it's even showing up.Comment #46
sunThanks for the twig changes. However, the main problem I see with the proposed patch is still that it introduces new code paths that should not exist.
interactive must be true. Otherwise, the installer prepares everything for a command line installation.
conf_path() will return an unsafe value.
This kind of new technical debt is the last thing we need right now. We're working very hard and very actively to clean up all of this code in many other issues, and we're making very good progress. Committing a weird change like this will only cause serious problems for other critical/major issues that are trying to make real progress.
But yeah, please do whatever you want. I'm not going to comment further here, because @chx creates an environment that is not productive, not collaborative, and not fun to be in. Apparently, that stream of constant negativity even starts to affect my own comments, which is the very last thing I need after taking a very long break from Drupal for exactly that reason, so (1) architectural concerns have been clearly expressed (including a potential resolution path), and thus, (2) I can go back to issues with a positive, friendly, and collaborative climate.
Comment #47
webchickYeah, I unpublished #43 since that was particularly unproductive. https://drupal.org/dcoc, chx. :\
sun: I do think though that chx adequately covered the reasons why I think while we intend this to only be needed by developers actively working on code, reality may not support that. Anything we can do to take aggravation out of recovering from a hosed site is a good thing to do, especially from those users least able to take care of themselves.
I also raised this as a major UX problem because even though I am a developer-type working on code, this functionality was totally undiscoverable to me, as I itemized in the issue summary. A slimmed down settings.php wouldn't really help, IMO; I don't turn to settings.php more than once a blue moon when I'm hard-coding a configuration value, moving a site from one hosting company to another, etc.
Do you have a recommendation on which specific patch(es) we should postpone this on? I'm not necessarily opposed to doing that, but I also want to balance other refactoring with site builder/developer angst.
Comment #48
webchickBtw, #34 or something like it might work. It seemed odd though to introduce a brand new UX pattern for this though when we already have an existing one for exactly this purpose. While the wall of text might not be helpful, if it's not, we should fix it in both places. (As a separate issue, of course.)
Comment #49
jibran45: 2160057-45.patch queued for re-testing.
Comment #51
star-szrRerolled, small conflict with #2176151: rebuild.php does not include /core/vendor/autoload.php.
Comment #52
sunAttached patch implements #34.
Comment #56
valthebaldTriaging this as part of NOLA major issue triage sprint.
The issue is still reproducible (in the meaning, rebuild.php still doesn't have any helpful messages)
Steps to reproduce: @todo find 2 a development revision prior to the current HEAD that needs but not fixed by rebuild.php
Comment #57
xjmThanks @valthebald for triaging the issue. Updating the issue credit for triaging.
Comment #58
webchickThe core committers discussed this issue a couple of triage meetings ago, and given the changes to the container, the need to do this comes up a lot less often than before, so downgrading to normal.
Comment #73
smustgrave commentedThis one still relevant ?
Comment #75
andypostI bet it is as chicken-egg