drupal_write_record() not working during hook_install()
It took me a bit of time to figure this out. calling drupal_write_record() during hook_install() or hook_enable didn't work! I was so proud to be using the built in schema write function, but thought afterward I should have just wrote my own insert/update SQL queries! In the end, the problem comes from the fact that the schema is not rebuilt during hook_install(), so any schema you want to use from your module will not available. A quick workaround for hook_enable() is to force a schema rebuild:
drupal_get_schema(NULL, TRUE); It's only after figuring this out that I found the issue: http://drupal.org/node/200931
Add new comment