As many of you I'm sure have encountered, if a field definition changes on an existing field that has data, a FieldUpdateForbiddenException will be thrown, which kills the entire reverting process, and fails to give you any meaningful information about which feature and field are causing the issue. This leaves the developer to either bisect through features and fields, or to hack up Features module to print it out in features.field.inc. I propose we instead log these to the watchdog log.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

q0rban’s picture

Title: Provide more graceful handling of exceptions during field updates » Use watchdog_exception() in features.field.inc when encountering update exceptions.

Ah, nevermind, I see this is already fixed in the dev version of Features, however, we should switch to using watchdog_exception(). Updating title.

q0rban’s picture

Title: Use watchdog_exception() in features.field.inc when encountering update exceptions. » Provide more graceful handling of exceptions during field base updates

I take it back again, looks like this is only happening for instances, not for the fields themselves.

q0rban’s picture

And, also, doesn't show the name of the feature module that has the exported field.

q0rban’s picture

Status: Active » Needs review
FileSize
4.13 KB
deviantintegral’s picture

I really like getting a bit more detail into the error messages. I'm not sure about discarding exceptions we don't handle. Especially since watchdog messages don't show up by default in drush, it seems like it's really easy to miss.

What about adding more detail into the exception itself, but we still throw it? That way calling code can choose to handle it if it really can. Exceptions are final so we can't just change the message, but we could catch the existing exception and then throw a new one with the updated message.

q0rban’s picture

Especially since watchdog messages don't show up by default in drush, it seems like it's really easy to miss.

Watchdog messages do indeed show up in drush. Screenshot of what drush output looks like with this patch.

I considered still throwing the exception as well, but seeing as how an exception is not thrown when field_instance update/create fails, I opted to follow that pattern. I am open to throwing the exception if that is deemed best.

deviantintegral’s picture

Doh, the level is error, not warning.

IMO we should throw the exception in update and create as well, given that it's implying that something is horrifically wrong. I usually find that once one field starts failing that everything else does too due to dependencies.

q0rban’s picture

I'm okay with making that change, but for the sake of playing devil's advocate, and assuming you are a developer that pays attention to errors in the deployment process, can you describe a situation where having the process continue could be catastrophic? The reason I ask is because in my experience when this occurs, something is NOT horrifically wrong—it's just that the field length has changed. Everything will work perfectly fine as is, but you should either get the field definition to match the database, or write an update hook to clean up your data and alter the field schema by hand.

Gik000’s picture

I had a huge problem because of a field corruption after the feature.
Anyway #4 worked like a charme!
Thank you so much