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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

burningdog’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

burningdog’s picture

Testing server was down: retry.

burningdog’s picture

Doh! The patch breaks admin/build/modules - not sure why - looking into it.

burningdog’s picture

Status: Needs work » Needs review
FileSize
633 bytes

Changing $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.

burningdog’s picture

Component: base system » statistics.module
Priority: Normal » Critical

Marked 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.

spuky’s picture

I 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

spuky’s picture

Status: Needs review » Reviewed & tested by the community

since I got no feedback

I am setting this one to rwtbtc still not shure if my review was sufficent

Spuky

catch’s picture

Works for me, but I think we need a test for this - test both should have picked up the breakage already.

spuky’s picture

I 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.

spuky’s picture

Status: Reviewed & tested by the community » Needs work

maybe 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

catch’s picture

Yes I meant just a basic test to ensure the statistics settings page works properly.

spuky’s picture

Status: Needs work » Needs review
FileSize
2.58 KB

So 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...

j.somers’s picture

Status: Needs review » Needs work

Patch works OK and fixes broken administration page but code-wise it still needs some work.

  • The closing brace in the following snippet is not placed correctly and there should be a space between the , sign and 'administer statistics'.
    function setUp() {
      parent::setUp('statistics');
      $this->settingpage_user = $this->drupalCreateUser(array('access statistics','administer statistics'));
      }
    
  • The comments should contain a . at the end of a sentence and so do the assert text messages.
spuky’s picture

Status: Needs work » Needs review
FileSize
2.63 KB

fixed coding style

burningdog’s picture

Assigned: burningdog » Unassigned

I don't know enough about SimpleTest to review this, sorry.

moshe weitzman’s picture

Status: Needs review » Closed (duplicate)

This is fixed more elegantly at #428744: Make the main page content a real block