Notice: Undefined index: type in drupal_write_record() (line 6663 of /Users/dave/Sites/drupal-head/includes/
Notice: Undefined index: type in drupal_write_record() (line 6700 of /Users/dave/Sites/drupal-head/includes/

This is because $info['type'] does not exist on these fields.

#7 998632_7_drupal_write_record.diff692 bytesdalin
PASSED: [[SimpleTest]]: [MySQL] 29,935 pass(es). View
#1 998632_1_drupal_write_record.diff1.32 KBdalin
PASSED: [[SimpleTest]]: [MySQL] 29,843 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more


dalin’s picture

Status: Active » Needs review
Issue tags: +Schema API
1.32 KB
PASSED: [[SimpleTest]]: [MySQL] 29,843 pass(es). View

I believe this just needs a few isset($info['type']), but I'm not familiar enough with cross-db data types to know for sure.

Crell’s picture

Status: Needs review » Needs work

IMO we should look into why $info['type'] doesn't exist in the first place. I'd consider that a deeper bug. Really, isset() is a bad way to respond to undefined variables in a definition array. :-) Proper defaults are the right way.

dalin’s picture

@crell most of the time I would agree with you. However I should have elaborated, this happens when you have a field something like this:

      'birthdate' => array(
        'description' => "YYYY-MM-DD formatted birth date.",
        'mysql_type' => 'DATE',
        'pgsql_type' => 'timestamp without time zone',
        'not null' => FALSE,

As I understand it, it isn't possible to come up with a value for 'type' in this case.

Damien Tournoud’s picture

I would just add a NULL 'type' in _drupal_schema_initialize().

jbrown’s picture

The 'type' key is not optional.

Damien Tournoud’s picture

@jbrown: yes, it is.

dalin’s picture

Status: Needs work » Needs review
692 bytes
PASSED: [[SimpleTest]]: [MySQL] 29,935 pass(es). View

Added a NULL 'type' in _drupal_schema_initialize().

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

agree with the fix.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This needs tests.

Vacilando’s picture

Ran into the same problem, found this issue, applied dalin's patch from #7 and the notices disappeared.

j4’s picture

works for me too..


naringas’s picture

Had this problem in 7.10 using my custom module code (which also has a schema like #998632-3: drupal_write_record() throws PHP notices if any fields use DB-specific data types).
I applied patch in my development server and it fixed the issue (after a cache flush).

Vacilando’s picture

Bump. The patch in #7 has worked for me again, on a different system, in D7.14.

cjoy’s picture

patch in #7 worked fine on 7.15, no more notices caused by the following schema field:

'createtime'                 => array(
        'description' => 'timestamp',
        'mysql_type'  => 'timestamp',
        'not null'    => FALSE,
tonylegrone’s picture

Adding a NULL type to hook_schema also fixed this bug for me without applying the patch.

      'valid_from' => array(
        'description' => 'The start date.',
        'type' => NULL,
        'mysql_type' => 'datetime',