When creating servers, they now always have a 0 status (having the nasty side effect that they can't be deleted). Weirdly enough, creating indexes works normally.
From some quick debugging I can't really tell the cause. The SQL default value for the column is 1 (and the whole definition is the same as for indexes). Right before the initial call to save(), $server->entity is NULL, as it should be. And I really have no idea where else something could go wrong. In the INSERT statement, the wrong value is already there.

Any ideas?

Comments

fago’s picture

What about is $server->entity ?
Maybe you have the status property defined in your class, such that it already exists and db default is not populated?

drunken monkey’s picture

What about is $server->entity ?

Oh, sorry, I meant $server->status. This is NULL when I call save(), but obviously gets changed to 0 between then and the database statement.

Maybe you have the status property defined in your class, such that it already exists and db default is not populated?

It's defined with public $status;, so it should be NULL if it isn't set explicitly — and, as said above, it is NULL when the method is called.

fago’s picture

Status: Active » Fixed

drupal_write_record() makes use property_exists($object, $field) - so the default won't be applied that way. So either specify the right default value for the class property too, or remove it.

drunken monkey’s picture

Oh, wow. Doesn't seem like the most logical thing to do, but there's probably some reason for this …
Anyways, thanks a lot for finding that out, should be fixed for the Search API now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.