This is not a good way to save the values: in the validation callback.

You probably did this, to make sure the block-module (or another) did not already call the drupal_goto(), but this method is error-prone:
* If validation of another value on the block fails, your values are saved nonetheless.
* If your insert/update/delete fails, you may end up with a broken database: your content is not saved, but other block-setting may, or may not be saved. result is unknown and hence "dangerous".

What is your reason for not using a submit callback?

Comments

ngmaloney’s picture

Assigned: Unassigned » ngmaloney

I'll look into this and work on a patch.

neclimdul’s picture

Title: VAlidation saves the values: error prone. » Validation saves the values: error prone.
Status: Active » Needs review
StatusFileSize
new3.74 KB

Here's a patch. Did a little additional cleanup around the validation callback as well to make it more resilient.

ngmaloney’s picture

neclimdul - Thank you for taking the time to do this. I'll roll it into CVS ASAP.

ngmaloney’s picture

Status: Needs review » Needs work

neclimdul - I tested the patch and it is throwing the following errors:

warning: Wrong parameter count for array_search() in drupal-6.16/sites/all/modules/block_titlelink-HEAD/block_titlelink.module on line 36.
warning: Wrong parameter count for array_search() in drupal-6.16/sites/all/modules/block_titlelink-HEAD/block_titlelink.module on line 41.

Running on php 5.2.6

neclimdul’s picture

Version: » 6.x-1.x-dev
Assigned: ngmaloney » neclimdul
Status: Needs work » Active
StatusFileSize
new2.76 KB

Reroll with fix. Built on top of #1072800: Cleanup documentation to be closer to core standards in case patch doesn't apply cleanly.

neclimdul’s picture

Reroll

neclimdul’s picture

Status: Active » Needs review

This has been pretty well tested by users on my site but for the sake of not marking your own patch RTBC I'll mark this NR

adammalone’s picture

Version: 6.x-1.x-dev » 6.x-2.0-beta1
Assigned: neclimdul » adammalone

Altered in the 6.x-2.x version to save values in form_submit.

adammalone’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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