To replicate: clean D7-dev install. Enable the statistics modules, then navigate to admin/settings/statistics
You should see a form, but that's it - Garland has gone! See attachment.
To see Garland again, simply change $form['content'] to $form['content1'] on lines 253 and 257 of statistics.admin.inc and then view admin/settings/statistics again. Hey, it's back!
The problem is that when drupal renders the page in drupal_get_page() it builds a $page array, and gives it an element called - you guessed it - 'content' - which will hence break any form which has a 'content' element.
Statistics.module contains the only reference to $form['content'] in core, hence tests rolled on the statistics module will break. There are a few other modules which use $form['content'] so the solution is rather to choose a unique namespace.
I suggest 'content_page' and have rolled a patch against common.inc to reflect this. This issue should probably be renamed "drupal_get_page() requires $page['content'] to be a unique namespace" but that will only make sense after reading to this point.
Comment | File | Size | Author |
---|---|---|---|
#15 | statistics_fieldset_test.patch | 2.63 KB | spuky |
#13 | statistics_fieldset_test.patch | 2.58 KB | spuky |
#5 | 463064-statistics_fieldset.patch | 633 bytes | burningdog |
#3 | 463064-drupal_get_page-unique-namespace.patch | 570 bytes | burningdog |
#1 | 463064-drupal_get_page-unique-namespace.patch | 570 bytes | burningdog |
Comments
Comment #1
burningdog CreditAttribution: burningdog commentedComment #3
burningdog CreditAttribution: burningdog commentedTesting server was down: retry.
Comment #4
burningdog CreditAttribution: burningdog commentedDoh! The patch breaks admin/build/modules - not sure why - looking into it.
Comment #5
burningdog CreditAttribution: burningdog commentedChanging $pages['content'] to $pages['content_page'] means the following core files need to be changed too:
user.pages.inc
system.api.php
-> it's not an elegant solution.
This change isn't worth it; it's better to inform those people who are using $form['content'] to instead use something else, like $form['fieldset_name'] if it's a fieldset, where 'fieldset_name' is descriptive of the content inside that fieldset.
I've used the last option for patching statistics.module, which still breaks because it uses $form['content'] - since that form element is referring to a fieldset it's a better idea to call it $form['counter'].
$form['content'] isn't used anywhere else in core.
Comment #6
burningdog CreditAttribution: burningdog commentedMarked the change from a core patch to statistics.module. Marked critical because without this patch, the /admin/settings/statistics page breaks, and any patches for statistics will be rejected by simpletest.
Comment #7
spuky CreditAttribution: spuky commentedI reviewd the patch:
before aplying the patch when visting:
admin/settings/statistics (after enabeling statistics of course)
garland is gone
after aplying the patch and going to
admin/settings/statistics the page looks like one would expect...
so the patch fixes the reported bug !!!
did some playing arround with the settings of statistic module works fine for me...
since only the the form array is changed from "content" to "counter" i don't see any coding style brocken..
but since I this is only my third patchreview I leave that on needs review
(unless sombody tells me that the review was sufficent)
Spuky
Comment #8
spuky CreditAttribution: spuky commentedsince I got no feedback
I am setting this one to rwtbtc still not shure if my review was sufficent
Spuky
Comment #9
catchWorks for me, but I think we need a test for this - test both should have picked up the breakage already.
Comment #10
spuky CreditAttribution: spuky commentedI was thinking about a Test too, but what would you test on. The test for this error would have to be run for every form in core because today it is statistics.module that has the $form['content'] array element defined. But next week maybe sombody in the comment.module or any other module defines a $form['content'] element so statistics.module would be working fine and testing for beeing fine but a totaly different module is broken somewhere... and not testing for that error.
So If we need a test for that case I think It should be a more general Test that is not bound statistics.module.
Maybe it would be more kind of a coder module feature to check for this edgecase since this issue will hit contrib developers even more likely than core developers.
Comment #11
spuky CreditAttribution: spuky commentedmaybe I was thinking in to big context. The test should just test the Fact if config page could be accessed without error. I will try writing that test Tonight.
Spuky
Comment #12
catchYes I meant just a basic test to ensure the statistics settings page works properly.
Comment #13
spuky CreditAttribution: spuky commentedSo here is a version including test for accessing setting page... since that is my first test somebody might want to look closely if I got it all right...
Comment #14
j.somers CreditAttribution: j.somers commentedPatch works OK and fixes broken administration page but code-wise it still needs some work.
Comment #15
spuky CreditAttribution: spuky commentedfixed coding style
Comment #16
burningdog CreditAttribution: burningdog commentedI don't know enough about SimpleTest to review this, sorry.
Comment #17
moshe weitzman CreditAttribution: moshe weitzman commentedThis is fixed more elegantly at #428744: Make the main page content a real block