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

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

Files: 
CommentFileSizeAuthor
#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 ]

Comments

Status:Active» Needs review
Issue tags:+Schema API
StatusFileSize
new1.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.

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.

@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:

<?php
     
'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.

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

The 'type' key is not optional.

@jbrown: yes, it is.

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

Added a NULL 'type' in _drupal_schema_initialize().

Status:Needs review» Reviewed & tested by the community

agree with the fix.

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

This needs tests.

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

works for me too..

Jaya

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

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

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

<?php
'createtime'                 => array(
       
'description' => 'timestamp',
       
'mysql_type'  => 'timestamp',
       
'not null'    => FALSE,
      )
?>

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

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