Needs work
Project:
Drupal core
Version:
main
Component:
theme system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Aug 2015 at 18:36 UTC
Updated:
30 Jan 2023 at 20:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #3
Aki Tendo commentedOops - got a variable reference wrong by not checking more closely after copypasting. This does prove that runtime assertions are running.
Comment #4
Aki Tendo commentedComment #5
geertvd commentedLooks good, some nitpicks:
typo?
These arguments could use an extra comment line describing them
Comment #6
Aki Tendo commentedTypos fixed. Also, let's see if that construct assertion can be hardened to require a file path.
Comment #7
Aki Tendo commentedComment #8
joelpittetCouple of minor things but this looks great otherwise. Thanks @Aki Tendo
should $options at the end be type hinted as well?
Suggestion: This may be better as 'Argument #1 must be a file path which exists' Because legality doesn't really have a play here. 2¢ Also all the other assertions don't end in periods but this one does. I'm not sure the precedent here but it should be consistent either way.
Comment #9
jhedstromThis should address #8. Regarding periods at the end, all the examples have them, so I added them here.
Comment #10
jhedstromBah, that page was for our test method asserts, not PHP asserts. However, most coding standard for Drupal use periods, so I think it makes sense when using
assert().Comment #14
jhedstromFails seem unrelated:
Output: [PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 13 database or disk is full'Comment #15
joelpittetThat was happening yesterday too.
Comment #16
dawehnerNote: This patch will probably conflict with #2568171: Upgrade to Twig 1.22 and implement our own cache class, so maybe better wait and don't waste time.
Comment #17
joelpittetLet's postpone on that. And reroll after its in.
Comment #18
Aki Tendo commentedThis patch has a sister that likewise should be postponed then.
Comment #19
Aki Tendo commentedRe-roll.
Comment #21
Aki Tendo commentedThat was embarrassing. Missing ).
Comment #22
Aki Tendo commentedComment #24
Aki Tendo commentedRunning the patch against 8.0.0. It has been decided that runtime assertions may be included in incremental updates.
Comment #26
Aki Tendo commentedRequing under new system
Comment #28
wim leers+1.
Only concern: why the "argument #N" stuff instead of specifying the name of the argument?
Comment #29
Aki Tendo commentedI did it that way in mimicry of how PHP handles such an error, but I'm open to suggestions on how else to format the error message. Whatever method is used needs to be consistent across the system.
Comment #32
Aki Tendo commentedComment #35
markhalliwellComment #36
borisson_Fixed #28 and rerolled the patch.
Comment #37
dawehnerI'm curious whether we could evaluate these conditions earlier, aka. on container build time
Comment #38
borisson_I'm not sure about #37, that sounds like a good idea, but I'm not sure how to implement this. Should we do that as a followup to add those additionally?
Comment #39
Aki Tendo commented@dawehner My understanding is the configuration yaml files are immutable once the developer has finished work on their module. Hence checking their validity within the container builder as part of a configuration validation scheme become unnecessary overhead in production where new code isn't (or at least shouldn't) being written. That's why I went with an asser() check.
The purpose of the assert is to ease and speed the diagnosis of coding problems, aid our fellow developers and lower the bar for understanding the code for newcomers to the code. Consider what happens if we do move these asserts to validation in the container interface. A programmer decides to, for whatever reason, instantiate this object without using the DI system (bad practice, but it's the easiest example I can come up with so bear with me). When they hit an error from the TwigEnvironment that's going to be the code file they open first trying to locate their mistake. The assert() where it is makes it obvious the call was done incorrectly (whether or not they should be doing this is a different can of worms).
Comment #49
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.