Download & Extend

Creating a new user produces a SQL error

Project:Advanced Blog
Version:6.x-1.0-beta2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hey,

Just installed the module and ran into an error. What I did was to create a new user at /admin/user/user/create and submit the form. The user was created successfully, but I got a SQL error in the process:

user warning: Field 'title' doesn't have a default value query: INSERT INTO advanced_blog (uid, format) VALUES (3, 0) in C:\inetpub\wwwroot\fanshawe\includes\common.inc on line 3477.

Briefly looking over the code, it looks like this is because the columns on advanced_blog table are all set as not null with no default set. Also, since your not providing fields for the blog info at /admin/user/user/create, why even save a row to the DB there?

Thanks,
~Matt

Comments

#1

I had the same issue and with your directions I was able to solve the problem on my system by changing the fields "title" and "description" in the table advanced_blog to allow NULL and setting the default value of those fields to NULL.

Thanks.

#2

The attached patch removes the NOT NULL restriction on the title and description fields. You must run a DB update for the patch to take effect. (https://example.org/update.php or drush updatedb.)

As Matt mentioned, this is not the right answer, but it at least removes the errors.

AttachmentSize
advanced_blog-null_fields.patch 806 bytes

#3

Do you need to change your hook_schema implementation as well so that those installing for the first time will get the updates?

Matt

#4

It isn't clear in the API docs that updating hook_schema is required, but an email in the Drupal Support mailing list archives clarifies it is required.

Patch rerolled to include hook_schema() update.

AttachmentSize
advanced_blog-null_fields.patch 1.16 KB

#5

Nice, good to see that clarified.

nobody click here