Closed (fixed)
Project:
Drupal core
Version:
9.1.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
12 Jun 2020 at 09:10 UTC
Updated:
17 Nov 2020 at 11:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
alexpottSomething like this...
After applying the patch you need to rebuild your autoloader... removing vendor and running composer install should be enough.
Comment #3
andypostThis way we can load/define requirement constants too!
Nice idea and easy to get rid of when bootstrap.inc will be purged
Comment #4
alexpott@andypost if it is purged. functions are okay. Application wide constants are too.
Comment #5
jungleOne thing out of scope here. Should blackhat.com be changed?
Comment #6
alexpottFixing a test.
Comment #9
alexpottThis is amusing in a way. We really should have made this change ages ago. Would have saved ourselves quite a bit of work which does not add a tonne of value. Note in some places where we cache extension objects we're changing approach - see #3116858: Don't cache whole extension objects in FileCache
Comment #10
heddnTagging. I also ponder what this means for contrib testing. Does this break anything for contrib unit tests, if they wrote them poorly?
Comment #11
alexpott@heddn potentially... but if you do it properly then no... for example:
This wouldn't cause a break. If contrib did that.
Comment #12
heddnre #11: that's my concern. If someone does it poorly, which isn't all that hard to do. But if we write up a good CR and do this in a new minor, the benefit from this change is really, really high.
Comment #13
alexpottI had a crack at the CR - https://www.drupal.org/node/3151229
Comment #14
heddnThis is looking really nice. Leaving in NR to get some more feedback from others.
Comment #15
jungleBTW, updated CR that added "After" (section) to pair with "Before", or looks incomplete at the first glimpse. See
https://www.drupal.org/node/3151229/revisions/view/11942291/11942414
Comment #16
alexpottWe need to resolve #9. I think we can do this by removing the check and improving the test to show that a different app root is used after serialising and unserialising.
Comment #17
mile23+2 on removing all the
require 'bootstrap.inc';type lines from everywhere in the codebase.-1 on leaving bootstrap.inc the way it is, because the constants should be moved out from it, and the functions need to be rolled somewhere else, as per some issues in #3097045: [META] Provide modern replacements for and deprecate the legacy include files.
So that's a net positive. :-)
For other include files that have lots of
requirestatements like this, maybe we should do the same thing with them. I can't think of which ones those would be offhand, though.Tempted to add the 'Kill includes' tag, but this doesn't really do that.
Comment #18
alexpottI think we should consider whether this is true. Functions and constants are not bad. We now only have two usages of \Drupal in bootstrap.inc - I agree those should be refactored but somethings feel like change for changes sake.
Comment #19
mile23It's out of scope here but I've always maintained that the constants should be in a different file from the functions in bootstrap.inc, so that we can use constants without the overhead of the functions.
The big problem has been tests that need those constants but which also shouldn't load the functions in bootstrap.inc for whatever reason. Like more strict unit tests. I haven't been neck-deep in that code for a while, so if that's not an issue any more then, uh, it's not an issue. :-)
Anyway, +1 on using composer to autoload this file and removing a bunch of extraneous
requirestuff. It just feels a little hacky rather than architected, and we'll probably eventually circle back to undoing this as things progress.Comment #20
alexpottYeah that's the thing - there really is not a good reason to not have a function like t()... yes DRUPAL_ROOT is a bit of an issue because it makes it tricky to test... but we have a service to replace that so we're most of the way there. And just because we autoload bootstrap.inc doesn't mean we can't deprecate DRUPAL_ROOT. It probably would have been great to put all the constants in a constants.php a long long time ago and not do the refactors we've done. But what's done is done. But tldr; none of this is not a reason to not go forward here.
Comment #21
voleger+1 for this issue
That would be great if we have only two files for load by Composer in Drupal 10:
constants.phpandfunctions.php.No more *.inc files. No more include files handled by the Kernel. Maybe fill a followup to address that before drupal:10.0.0-alpha1? Until then there would be the only bootstrap.inc file loaded by the Composer. So good so far.
#18 +1 for moving or deprecating of
drupal_get_filenameandwatchdog_exceptionfunctions. I'm not sure that some code will use those function before Kernel initialization but small chance exist that situation may happen.For reference, there are some issues to address the replacement of some functions in
bootstrap.incfile:Comment #22
daffie commentedThe patch adds the autoloading of
includes/bootstrap.incAll occurrences of requiring the loading of
includes/bootstrap.incby "hand" are removed.All code changes look good to me.
For me it is RTBC.
I am for continue to deprecated the contents of the file
includes/bootstrap.inc. Hopefully someday we can remove the autoloading of the file fromcomposer.json.Comment #23
jungleBTW, tested:
composer dump-autoloadorcomposer dumpautoloadis not enoughcomposer installworks without removingvendor.Comment #24
andypostNice to see remains of
st()are gone)It makes
t()to work properly in testsComment #25
alexpottRerolled as #2908079: Move some of the bootstrap.inc PHP-related constants to \Drupal and deprecate the old versions landed. I still think this is worth doing to make t() available and to not need to require bootstrap.inc when build a script to boot drupal.
Comment #27
alexpottJS random fails..
Comment #28
xjmComment #30
alexpottJS random fails..
Comment #31
beakerboyPatch no longer applies. I removed the section from the patch that has already been removed in core.
Comment #32
beakerboyForgot the interdiff...
Comment #33
jungleChecked with
$ git grep 'bootstrap.inc'and$ COMPOSER_ROOT_VERSION=9.1.x-dev composer update --lock -vvv, #31 looks good.But the inter-diff file attached in #32 is incorrect. attaching a raw-interdiff file.
Comment #35
alexpottRandom JS test fail
Comment #36
mondrakeComment #37
kapilv commentedre-roll patch.
Comment #38
kapilv commentedComment #41
anmolgoyal74 commentedUpdated the hash.
Comment #42
daffie commentedThe patch adds the autoloading of includes/bootstrap.inc
All occurrences of requiring the loading of includes/bootstrap.inc by "hand" are removed.
All code changes look good to me.
Reroll looks good to me.
For me it is RTBC.
Comment #43
alexpottRerolled and found one more small thing we can remove in a test...
Comment #46
catchOnly thing that makes me hesitant here is we should have done it pre-8.0.0, but better late than never. Committed/pushed to 9.2.x and 9.1.x, thanks!