I created a content type called "Theme" and gave it a machine readable name of "theme". When I clicked on Create Content -> Theme I got this error:

Fatal error: Cannot unset string offsets in .../public_html/includes/form.inc on line 319

Luckily this was a brand new install so I disabled and uninstalled every module that didn't come installed by default. I still got the error. I found out that when I changed the machine readable name of the content type to anything but "theme", the error went away. It's a pretty minor issue, but I thought it was worth fixing.

My system stats:

Linux OS
Drupal 5.5
PHP 5.2.4
MySQLi 4.1.22

CommentFileSizeAuthor
#4 204119-1.patch1.57 KBtraxer

Comments

archard’s picture

Priority: Normal » Minor
chx’s picture

Status: Active » Closed (won't fix)

I am fairly sure you can screw up with even more interesting content type names.

pancho’s picture

Version: 5.5 » 6.x-dev
Priority: Minor » Normal
Status: Closed (won't fix) » Active

chx: That makes it worse not better.
Should imho be generically fixed at least for D6, so we don't get code-data conflicts like this again and again in subsequent API changes.

traxer’s picture

Priority: Critical » Normal
StatusFileSize
new1.57 KB

The fault is with the node system. The documentation for drupal_get_form() says

If a function with that name exists, it is called to build the form array.

The node system cannot ignore that.

The patch changes the form_ids of node forms to 'node_' . $type . '_node_form'. This is only a temporary solution. Potentially conflicting functions do not exist in core, they can only come from contrib modules (which is an improvement).

chx’s picture

Component: forms system » node system
Status: Active » Needs work

No way this can happen for Drupal 6...

traxer’s picture

Where do you see problems with the patch?

"Theme" is not that far fetched a name for a node type; think of theme gallaries. This issue is even on the edge of being critical; it should definitly be fixed. Do you know of any contrib modules that get broken by the patch?

traxer’s picture

Status: Needs work » Needs review
pwolanin’s picture

seems to be more or less the same issue as: http://drupal.org/node/204415

traxer’s picture

It is not.

  • #204415 is caused by the node system using the menu system in a wrong way.
  • #204119 is caused by the node system using the forms system in a wrong way.
traxer’s picture

Priority: Normal » Critical

I marked this as critical. Reasons are

  1. The user gets an empty page or a raw PHP message upon an error.
  2. The error is not obvious when creating the type, but rather when creating content of that type. Creating content is done by possibly inexperienced users.
  3. I see hook_form_alter() as the main reason for my patch to be regarded as an API change. However
    • the documentation of hook_form_alter() suggests $form['#node']->type to check the type of the node
    • the documentation of node_forms() does not guarantee a specific value of the $form_id parameter,
    • $form['#id'] == 'node-form' in any case.
moshe weitzman’s picture

Critical is when many people's sites are broken. This affects few people and the site is site is still operational.

pwolanin’s picture

Priority: Normal » Critical

An earlier patch proposed at http://drupal.org/node/204415 (wisely by chx) would blacklist "theme" as a content-type.

That's why I linked ot it.

gábor hojtsy’s picture

Version: 6.x-dev » 7.x-dev
Priority: Critical » Normal

Indeed, we can blacklist some types for now, and postpone any API changes to Drupal 7.
Moving the discussion to http://drupal.org/node/204415

lilou’s picture