After #334024: Use const keyword to define constants instead of define() was applied trying to install Drupal on PHP <5.x results in an E_PARSE error when trying. This isn't a huge issue as Drupal won't run at all, but instead of giving the readable error when trying to install it just hard crashes with a syntax error.
The const in install.php should be reverted to define() so you at least get the proper error message when trying to access core/install.php.
Any page request besides core/install.php will still result in an E_PARSE, but people might expect that as they haven't finished the install yet. Might have to update some docs to at least warn about this, the core INSTALL.txt at least doesn't mention going to core/install.php just the root directory.
Comment | File | Size | Author |
---|---|---|---|
#16 | 1355798-16.patch | 669 bytes | xjm |
Comments
Comment #1
tstoecklerSounds good. That would need a comment in the PHPDoc, though, explaining why we use define here, when we use const everywhere else.
Comment #2
Kjartan CreditAttribution: Kjartan commentedAdded a comment. Rest should be the same.
Comment #3
tstoecklerThere needs to be a blank line before this. Also I think the comment could be more clear. Maybe: "Use define() so that on PHP versions before 5.3 the installer can display a proper warning instead of a blank page because of a fatal error."
That's actually too verbose, I think, so if you could come up with a shorter version, that would be even better. :)
0 days to next Drupal core point release.
Comment #4
Kjartan CreditAttribution: Kjartan commented- Tweaked comment wording.
- Conforming to coding standards.
Comment #6
Kjartan CreditAttribution: Kjartan commentedOpps, apparently I screwed up that patch. Trying again.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedyes, simple and awesome patch. RTBC.
Comment #8
xjmTo clarify, the intent here is to prevent the installer from crashing before it displays the requirements information.
The patch looks good, but I'd suggest one change:
The two lines of inline comments here should be moved to the docblock (after a blank line). I.e.:
Comment #9
xjmOops, xpost.
Comment #10
Kjartan CreditAttribution: Kjartan commentedEither way works for me.
My reasoning was that the docblock should document the constant and the // comment the special implementation detail as it didn't seem important enough to get dragged into API docs.
Comment #11
xjmAh, that's exactly why I thought it should be in the docblock. :) We have additional paragraphs in constant doxygen all over the place, but an inline comment after the docblock isn't a pattern I've seen.
#10 looks good to me.
Comment #12
Anonymous (not verified) CreditAttribution: Anonymous commentedyes, simple and awesome patch. RTBC. ;-)
Comment #13
David_Rothstein CreditAttribution: David_Rothstein commentedI think I understand Kjartan's reasoning here; this documentation is definitely going to look a little odd at http://api.drupal.org/api/drupal/core--install.php/constant/MAINTENANCE_... the way it is now.
If this were a function, the new sentence would definitely be an inline code comment rather than part of the function's API documentation. However, if we don't do that anywhere else there's probably a good chance that api.drupal.org wouldn't parse it right, so maybe it's not worth experimenting.
To make it a little more clear on a page like that, the beginning of the sentence could be changed to something like "This constant is defined using..." That way someone who comes across it in the API docs will not be confused that the "Use define()..." is some kind of instructions for how they are supposed to use the constant in their own code. It might be worth a quick reroll, but I don't care quite enough to un-RTBC it :)
Comment #14
jbrown CreditAttribution: jbrown commentedIf the version check goes at the top of the file, can we still have const instead of define?
Comment #15
Kjartan CreditAttribution: Kjartan commentedNo, the order doesn't matter as it results in a E_PARSE, which happens before anything is run. One way to work around it would be to move the const to an include file, but I am assuming there is a reason the const is being set in install.php instead of install.inc (update.php sets it to a different value).
Comment #16
xjmAs usual, David's suggestion makes way too much sense. :) Here's a reroll with that.
Tentatively leaving at RTBC 'cause, yeah. If you think it shouldn't be, please set it back. ;)
Comment #17
jbrown CreditAttribution: jbrown commentedWhat about moving it to core/includes/install.core.inc ?
Comment #18
David_Rothstein CreditAttribution: David_Rothstein commentedMoving it to install.core.inc would limit the ability of outside code to use the functions in that file. Granted, most of those functions aren't too useful if you're not in the middle of an installation anyway, but I think it would still be better not to limit it.
Comment #19
catchThanks, committed/pushed to 8.x.
Comment #21
andypostFiled follow-up #2906787: Move definition of MAINTENANCE_MODE = install to install_drupal