Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Oct 2009 at 16:05 UTC
Updated:
6 Dec 2010 at 04:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
damien tournoud commentedIn the spirit of #592008: Don't save theme registry before modules are included, I suggest we check if Drupal reached DRUPAL_BOOTSTRAP_FULL, or simply call
theme_placeholder()directly.Comment #2
moshe weitzman commentedDoes this ever need to be themeable? Anyway, this is an improvement.
Comment #3
webchickHm. I'm not sure if this adequately covers all of our bases. For example, I had an awful lot of fun debugging this problem in #424486-6: Errors when adding external table with unknown column types, which was caused by db_set_active()ing to another database that did not have a system table from which to find the current theme, and then causing watchdog() error with a % placeholder in it.
I'm not suggesting this is the "fix everything that was ever wrong with t() and theme()" issue, but I wonder if there's a way to generalize the fix more than merely checking if we're at full bootstrap, since that wouldn't cover this case, at least afaik.
The fix itself is rather 'meh', though I don't see what other choice we have... but it'll cause inconsistent results if the theme is overriding theme_placeholder to be blinking marquee tags, for example (and whose isn't?)
Comment #4
David_Rothstein commentedAlso, as per #592008: Don't save theme registry before modules are included, the theme system now works much earlier in the page request than a full bootstrap, so the patch is a bit out of date...
Comment #5
moshe weitzman commented#3 - I do think that messing with t() is beyond the scope we can afford right now.
#4 - That patch is unfortunately broken and at best we will be building a partial theme registry and tossing it in that issue for early theme calls. It is just not worth it here.
Comment #6
dries commentedLet me throw something out: do we really want a theme_placeholder? Life would be easier (and faster) if we just had a non-themable drupal_placeholder() function (i.e. check_plain()). When I take a critic look at theme_placeholder() it feels a bit silly to me.
Comment #7
joachim commentedGive the em element generated by drupal_placeholder a class, and then themers can still make it do pretty much whatever they like.
Comment #8
moshe weitzman commentedImplemented suggestions from #6 and #7. Thanks guys. I'm happy to see this themeable function go. I put the new drupal_placeholder() in bootstrap.inc since some early code might want it and it is only 3 lines of php.
Comment #9
dries commentedThis looks RTBC to me. Marking it as such so people can review it if they want to.
Comment #10
dries commentedCommitted to CVS HEAD. Thanks.
Comment #11
moshe weitzman commentedAdded to upgrade docs at http://drupal.org/update/modules/6/7#placeholder
Comment #12
cburschkaI'm afraid this patch has introduced 16 failures in DBLogTestCase.
#666266: HEAD is broken - various test failures
Comment #13
cburschkaIt's a funny story. Here's what happens.
See, when we look at admin/reports/events, the messages are truncated. The test case compensates for this by only checking for a certain portion of the message.
This message contains a placeholder.
The markup for placeholders just got longer by the length of
class="placeholder".This causes it to be truncated earlier.
This causes the test case's hard-coded string portion not to match the page any longer.
=> Fail.
Comment #14
cburschkaThis should be fixed by
1.) adding a truncate_utf8($message, 56, TRUE, TRUE) to the test case.
2.) making truncate_utf8 ignore HTML markup (at least when $wordsafe is set).The former will fix the test, but I believe the latter will make the events overview more useful.
Edit: Though the latter really goes beyond the scope of this bug. Let's just fix the test failure.
Comment #15
cburschkaThis patch lets dblog.test pass. All is well. :)
Comment #16
catchThat's an evil, evil test we've got there. Nice sleuthing.
Comment #17
catchComment #18
dave reidCan we put that logic into its own private assertMessageFound() function so we don't have to maintain 10 different lines of truncate_ut8() and when this changes in the future we only have to modify it in one place?
Comment #19
webchickThat sounds like a good idea.
Comment #20
webchickAnd let's call it assertLogMessage().. we don't call it assertTextFound(), just assertText().
Comment #21
dave reidYeah, I just typed what came to mind. :)
Comment #22
chx commentedComment #23
chx commentedComment #24
chx commentednot easy patching with a wailing baby
Comment #25
webchickI'm not able to run the tests here locally, cos they hang forever.
When I kill execution I get an AJAX error, and then the results page says 352 passes, 5 fails, and 0 exceptions
The worst seems to be:
The test did not complete due to a fatal error. Completion check dblog.test 404 DBLogTestCase->testFilter()
Comment #26
cburschkaI get those all the time, which is why I only ever run tests via the scripts/run_tests.sh script now. I'll check if the same thing happens for me in the console script...
Comment #27
cburschkaI'm afraid I can't reproduce the breakage you're getting, webchick... the tests run through in 1:24 minutes for me both in console and in web mode; 414 passes, no fails. Can you run any of the other test cases, and do you get the same problems when running run_tests.sh?
(/me goes to irc to ask for more people with working test environments to give this a try.)
Comment #28
Anonymous (not verified) commentedtried the patch on a fresh head install, got these fails in dblog test.
Comment #29
int commentedI confirm the (#28) fails of dblog-truncate-messages-test-601548-22_1.patch (#24)
Comment #30
cburschkaLooks like more sleuthing. :)
Comment #31
Anonymous (not verified) commentedchecking for strings in html is evil. many goats were sacrificed in the making of this patch. that is all.
Comment #32
webchickThanks for the team work on this. Committed to HEAD, with a comment above that weird-ass truncate_utf8() line and a todo to fix it properly by checking the database rather than HTML output.
Let's see if we can turn testing bot back on now.
Comment #33
int commentedworking again
http://qa.drupal.org/pifr/status
Comment #34
David_Rothstein commentedBack to the original issue.
I don't think I understand what bug this patch actually fixed? During the bootstrap, we load includes/common.inc and includes/theme.inc one right after the other, which means that as soon as the t() function is available to be used, the theme system is as well.
Can anyone point to a specific scenario that didn't work before this patch but now works after it? (In Drupal 7, I mean - I know there were tons of problems with this in Drupal 6, but the code changed significantly.)
If there isn't in fact a bug, I think we should reconsider this. It breaks the common pattern where theme() functions are used for HTML output, and therefore makes the surrounding code harder to understand.
Also, I found two problems with the patch:
Comment #37
moshe weitzman commentedThose 2 inconsistencies should be fixed. I can take that next week if noone else does. Having me fiddle with javascript is not so advisable though.
We want the error handler to be moved earlier in the bootstrap. This is a step toward that goal. See #325169: Move error/exception handler higher up in the bootstrap process.
Lastly, at least a few of us agreed that hardly anyone ever wanted to theme this so invoking the theme system is useless overhead.
Comment #38
quicksketchThis patch also introduced a bit of ridiculousness. WHY, why why, would you want to pass in an array of variables if we're not passing through the theme layer? The whole mess of passing in variable arrays into theme functions was so they could be preprocessed. If we're not using the theme layer, there's no place to change/extend these variables. And even if you could, you can't override drupal_placeholder(), so these variables would never be used anyway. This should be executed as
drupal_placeholder($text)notdrupal_placeholder(array('text' => $text)).Comment #39
moshe weitzman commentedagreed. patches welcome. the signature of drupal_placeholder was not really the point of the patch so it was done in a fast way.
Comment #40
hass commented+
Comment #41
David_Rothstein commentedI think this is all we need for the remaining cleanup. It seems that drupal_placeholder() was changed from taking an array to a string a long time ago, so this just contains the other cleanups mentioned above.
I left Drupal.theme('placeholder') as a "theme function" in the JavaScript since it seems too late in the game to change that, but I did make its output have the placeholder class so it now matches the HTML you get when you call drupal_placeholder() in PHP.
Comment #42
moshe weitzman commentedmakes sense.
Comment #43
tom_o_t commented#41: drupal-placeholder-cleanup-601548-41.patch queued for re-testing.
Comment #44
webchickCommitted to HEAD. Thanks!
Lest someone else see those - signs next to theme_placeholder in drupal_common_theme() and freak out like I did ;), the original patch removed this function long ago, and so this is just cleaning up the fact that it doesn't exist.
Comment #45
webchick