Problem/Motivation
Now that all of core is consolidated to a single subdirectory /core, upgrading would be easier if we simply had index.php include the entirety of its functionality from /core so that the dir could just be replaced instead of both the dir and index.php (with the exception of changes to .htaccess, robots.txt and example.gitignore).
Proposed resolution
Aside from defining DRUPAL_ROOT, the remainder of functionality from index.php is moved into ./includes/index.inc
Remaining tasks
Patch needs review :)
User interface changes
None
API changes
No direct DX changes, but index.php will essentially become an example of how to bootstrap Drupal on the fly, and a function drupal_handle_request() added to demonstrate how incoming requests are delegated.
Original report by c4rl
Now that all of core is consolidated to a single subdirectory /core, upgrading would be easier if we simply had index.php include the entirety of its functionality from /core so that the dir could just be replaced instead of both the dir and index.php
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | drupal-1831998-42.patch | 6.09 KB | effulgentsia |
| #40 | drupal-1831998-40.patch | 6.1 KB | c4rl |
| #40 | drupal-1831998-40.patch-interdiff.txt | 1.22 KB | c4rl |
| #35 | drupal-1831998-35.patch | 6.13 KB | effulgentsia |
| #31 | drupal-1831998-31.patch | 2.22 KB | c4rl |
Comments
Comment #1
c4rl commentedLike
Or require.
Comment #2
c4rl commentedSee attached
Comment #3
c4rl commentedFolks to whom I've explained this at BADCamp (including quicksketch, webchick, & eclipsegc) have agreed it is a good idea, so marking as major to indicate consensus.
Comment #4
c4rl commentedI suppose for consistency sake, this should be in /core/includes
Comment #5
c4rl commentedOkay, moved this to /core/includes/index.inc
Comment #6
berdirTh patch now contains both core/includes/index.inc and core/index.inc.
Comment #7
c4rl commentedOops, forgot to remove that from the git index. This one should work.
Comment #8
c4rl commentedForgot to update status :)
Comment #10
lilou commented#7: drupal-1831998-7.patch queued for re-testing.
Comment #12
c4rl commentedHm, I'm not familiar with that error. I suppose it just means we should keep trying to update the status to NR?
Comment #13
c4rl commented#7: drupal-1831998-7.patch queued for re-testing.
Comment #14
rbayliss commentedDo we really want to add one more include statement into the critical path? If it's that important that we have all the core PHP code in /core, is there a way we can do this with the .htaccess?
Comment #15
c4rl commentedBenchmarking will answer this question.
People may not have mod_rewrite for clean URLs, so I don't think that works. Also, people who write PHP are familiar with looking for index.php, so it seems worthwhile to keep so that we don't do anything too unconventional.
Comment #16
attiks commented#14 Regarding .htaccess both nginx and IIS don't have such a thing.
Comment #17
David_Rothstein commentedThis is an important issue, but I don't believe it's a major task (see http://drupal.org/node/45111 and http://drupal.org/node/1181250). Specifically, this was marked "major" to indicate that several long-time Drupal contributors agree it's a good idea, but that's not really related to issue priority... I mean, you could probably also get them to agree that fixing spelling mistakes in Drupal's code comments is a good idea (which it is!) but that's not the same thing as saying that spelling mistakes in code comments have a significant effect on Drupal's functionality :)
If you disagree and feel this must still be marked major, please provide a very specific justification and keep in mind that every major issue prevents other features that people are working hard on from getting into Drupal core, due to the issue queue threshold policy (until/unless #1810428: [Policy, no patch] Adjust major and critical task thresholds during code thaw is addressed, at any rate). Note that I am not singling out this issue for particular attention but rather (slowly) trying to go through the issue queue and do this in many places so that other features still have a chance to get into Drupal core soon without the thresholds getting in the way. I am trying my best to be impartial, and of course, just because an issue isn't marked "major" certainly doesn't mean it's unimportant to work on. You can follow my progress via the tag I've just added to this issue :)
Comment #18
c4rl commented@David_Rothstein Thanks for your feedback. I see what you mean by usage of the "Major" tag as potentially problematic to indicate preference by certain members of the community.
I am hoping that I can get some reviews here soon from others who see the value of this issue regardless of the priority tag. We'll proceed with the status as normal.
Comment #19
effulgentsia commentedI think this might almost qualify as major on security grounds, but I'm not sure, so using the "Security improvements" tag instead. If the plan is that once 8.0 is released, that the way a site updates to 8.1 is by just copying the "core" directory, then us not being able to fix bugs in index.php after 8.0 is released could conceivably end up creating security problems. Though the same is as true (or maybe even more true) with .htaccess and web.config.
Comment #20
gregglesAgreed with effulgentsia that this could be an upgrade-WTF that would leave a lot of sites vulnerable. Whenever we have "special note: X" in security advisories there are a large number of people who don't notice that special note.
Granted it is uncommon to need to update index.php for any reason, but this would help reduce it.
.htaccess and web.config (and sites.php, settings.php) are already somewhat special cases since folks often customize them meaning that they purposefully don't replace them during an upgrade.
Comment #21
gregglesI think tags with forward slashes break the taxonomy autocomplete. Fun.
Comment #22
effulgentsia commentedFixed in D8 and D7. Backport to D6 not yet committed: #93854: Allow autocompletion requests to include slashes.
Comment #23
David_Rothstein commentedI think the basic idea of moving more code into core/ makes sense, but having an included file automatically run code seems counter to the way Drupal normally does things (and also makes it a little harder to follow).
What about doing this more like Drupal 7, reducing the code as much as possible but not removing it? So for example (ignoring the code comments) index.php could look like:
where drupal_handle_request() is a new function that lives in boostrap.inc and contains all the other things.
This might also help make it easier for someone trying to write their own script which bootstraps Drupal to understand how to do it using index.php as an example.
Since this does leave a few lines of code in index.php, in theory it could mean there's a Drupal 8 point release that requires changing it, but given what that code looks like I would say the chances are pretty much zero that it would ever happen.
Comment #24
effulgentsia commented#23 sounds good to me. The only part of it that seems potentially volatile is the DRUPAL_BOOTSTRAP_CODE constant, but #1784312: Stop doing so much pre-kernel bootstrapping is working on changing that to DRUPAL_BOOTSTRAP_CONFIGURATION, and my hope is that once page cache and session handling have moved to the Symfony architecture, that DRUPAL_BOOTSTRAP_CONFIGURATION is the only bootstrap phase left, at which point, we can drop the constant entirely.
I also wouldn't be opposed to removing the
drupal_bootstrap(WHATEVER_CONSTANT)from index.php entirely, and moving it into drupal_handle_request().Comment #25
c4rl commentedIt seems effulgentsia's concerns about DRUPAL_BOOTSTRAP_CODE have been resolved in the issue he mentioned.
David_Rothstein makes an interesting point about having index.php be self-evident on how to boostrap Drupal. The attached patch thus leaves the call to drupal_bootstrap in index.php and delegates remaining functionality to new function drupal_handle_request().
Would appreciate feedback on whether this seems sufficient to fulfill this issue's original intent.
Comment #26
c4rl commentedRetitling for clarity sake given #23
Comment #27
c4rl commentedTestbot seems to be acting up. Re-attaching.
Comment #28
effulgentsia commentedLooks good to me. Small nit:
Per http://drupal.org/coding-standards/docs#functions, I think the comment could be shortened to just "Handles an incoming request." The second sentence is a leftover from D7, but isn't all that meaningful for the new Symfony-based code. Possibly, some Symfony-oriented docs/links would be appropriate here, but that can be done in another issue.
Comment #29
c4rl commentedRe-rolled against HEAD, and incorporated effulgentsia's remarks from #28.
Comment #30.0
(not verified) commentedIssue summary template
Comment #31
c4rl commentedFixed syntax error.
Comment #33
effulgentsia commented#31: drupal-1831998-31.patch queued for re-testing.
Comment #34
c4rl commentedTests pass. Any other feedback at present?
Comment #35
effulgentsia commentedI renamed
drupal_handle_request()todrupal_handle_entire_php_request(),moved
drupal_bootstrap(DRUPAL_BOOTSTRAP_CONFIGURATION)into it, added more documentation to it, and updated http.php and https.php to use it. I'm willing to call this RTBC if c4rl approves of my changes.Comment #36
c4rl commentedThose changes seem fine to me.
I guess I don't quite understand renaming the function from
drupal_handle_request()todrupal_handle_entire_php_request()as "entire" and "php" seem redundant, but that's a bit of a bikeshed imho. :)Comment #37
tim.plunkettI think it helps indicate that it's taking over the entirety of PHP's responsibility for handling the request, as opposed to Kernel::handle(), which has other stuff before and after it.
I think this is a great improvement, and it's even more clear than D7's index.php
Comment #38
effulgentsia commented"Entire" and "PHP" might be somewhat redundant, but I wanted to convey two things:
1) That we don't mean request in the Symfony use of the word (i.e., handling a $request object), but rather in the PHP sense of the word (the thing that caused PHP to be running a script).
2) That we handle everything, from bootstrapping at the beginning to exiting at the end.
Comment #39
webchickReally? This seems like it comes from the redundant department of redundancy to me. :) Am I missing something?
Why would I assume it were handling a JavaScript or Node.js request? I wouldn't. So why is "php" necessary?
Why would I assume it wasn't the entire request? It's the only function in that file. It must therefore be handling the entire request.
It's true we're using Symfony Request objects as part of the overall PHP request, but that's a detail that doesn't become apparent until you're already inside the function, which is a lovely place to note (as the PHPDoc of that function currently does in #35) that you're talking about the entire PHP request, and not Symfony's. There isn't even mention of Symfony at all anymore in index.php (namespaces, etc.), so I find the extra details in the function name there just confusing.
So I'd rather commit #31, with the PHPDoc of #35. What say you?
Comment #40
c4rl commentedPer webchick's suggestions in #39, I reworked #35 to use the less-redundant function name.
RTBC worthy? :)
Comment #42
effulgentsia commentedYep, #39 helps make the case for the shorter name.
Missed this one. This fixes it. Wait for green before commit, but otherwise, this is RTBC.
Comment #43
catchLooks good to me. Committed/pushed to 8.x.
Comment #44
c4rl commentedWord. :) Thanks, all.
Comment #45
David_Rothstein commentedSorry for the noise; I'm told that slashes in tags can break the autocomplete on drupal.org.
Comment #46.0
(not verified) commentedSome API-ish remarks.