Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On some (fatal?) errors, I get another fatal error when trying to display the first fatal error...
Catchable fatal error: Argument 1 passed to Drupal\Core\Theme\ThemeManager::setActiveTheme() must be an instance of Drupal\Core\Theme\ActiveTheme, null given, called in /[...]/core/includes/errors.inc on line 128 and defined in /[...]/core/lib/Drupal/Core/Theme/ThemeManager.php on line 119
Making the parameter optional fixes it.
Comment | File | Size | Author |
---|---|---|---|
#25 | 2451085-25-test-only.patch | 5.6 KB | Arla |
#25 | 2451085-25.interdiff.txt | 1.72 KB | Arla |
#25 | 2451085-25.patch | 6.16 KB | Arla |
#22 | test-only.patch | 2.58 KB | dawehner |
#21 | test-only.patch | 0 bytes | dawehner |
Comments
Comment #1
eshta CreditAttribution: eshta commentedI experienced the same problem with the latest build and this resolved it so that I saw the standard error message again.
Comment #2
tancConfirming that this patch allowed the standard error message to show.
Comment #3
TR CreditAttribution: TR commentedI've been experiencing this error for more than a week while developing D8 code, and it's frustrating because whenever I make a mistake this error is thrown from error.inc, hiding the actual problem. As an example, I once added a field in my db_insert() which didn't exist in the table. Whoops, but the error was this "ActiveTheme" error which wasn't helpful at all. Since I had made many code additions, it took me a good while to figure out which one caused the error, and what the error realy was.
I tested the patch and yes, I can now see the original error, not the bogus "ActiveTheme" error. This will save me a LOT of time. Thanks.
Comment #4
BerdirThe obvious question of course is if we can test this and how. I really don't know why this doesn't show up in our existing tests.
Comment #5
webchickIndeed. Let's put our thinking caps on here. Does anyone here have more info on how you've triggered this in the past?
Comment #6
BerdirLooks like we only have tests for exceptions but not php errors, which are, for some reason running through a different code path.
Exceptions are DefaultExceptionSubscriber, errors go through _drupal_log_error(), only the second one calls the theme stuff.
Comment #7
TR CreditAttribution: TR commentedAnother way I triggered it is when porting a hook_theme() from D7 to D8. D7 defaults to 'function' while D8 defaults to 'template'. So those cases where I had used a theme function in D7 without a 'function' key ended up causing this error in D8, but of course only at the point where Drupal tried to load what it assumed was a template.
I don't think that what I describe here or above in #3 are PHP errors, although a PHP error may eventually result somewhere down the line. Here, it's just a missing template (I would think that's already tested for somewhere?). In #3, it boils down to an error in the SQL statement which is eventually constructed from my bad instructions.
Comment #8
dawehnerLet's write indeed a test for it.
Comment #9
BerdirGiven that this happens for all errors and not just some rare special case, I think this is at least major.
Test looks good to me, RTBC if bot agrees.
Comment #12
dawehnerThings aren't that easy always.
Comment #13
BerdirOk, now testbot is happy :)
Comment #14
ArlaLet's check that this fails without the fix.
Comment #16
ArlaPerfect. Back to RTBC.
Comment #17
dawehnerTestbot is not happy
Comment #18
dawehnerdawehner is stupid.
Comment #19
alexpottI don't understand how this works? How can we have files at
/Users/dawehner/www/
? Something feels wrong.Comment #20
dawehnerHa, that was fun :)
Comment #21
dawehnerHere is a test only patch.
Comment #22
dawehnerThis time, less empty.
Comment #23
GrimreaperHello,
Thanks you very much. I have applied the patch from comment 20 and it works perfectly.
Comment #25
ArlaActually, why don't we use the existing resetActiveTheme() instead :)
Comment #27
ArlaTest-only patch failed, so ready for review.
Comment #28
neclimdulWorks for me. Back to RTBC
Comment #29
BerdirNice, that looks better.
I guess a partial patch of the error message would have been OK too, because this will break if the line number changes, but that won't happen often (ever?), as it is inside a test controller that won't change much.
Comment #30
alexpottThis issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 8b98854 and pushed to 8.0.x. Thanks!