Many of the settings in the leech fieldset in the node form do not get remembered on hook_nodeapi($op='update'), and thus do not appear to "stick" when a user updates a leech feed. While they are, in fact, saved in the database, there is a problem with the way the #default_value element of many of the form elements is generated.

Rather than checking whether or not a value is set in the $node object, it checks the value, as follows (for example):

'#default_value' => ($node->leech_news->items_delete ? $node->leech_news->items_delete : variable_get('leech_news_items_delete_for#'.$form['type']['#value'], 15724800))

The problem with this is that this code cannot distinguish between a value that is set to FALSE and a value not having been set. Far better for this kind of code to be written as follows:

'#default_value' => (isset($node->leech_news->items_delete) ? $node->leech_news->items_delete : variable_get('leech_news_items_delete_for#'.$form['type']['#value'], 15724800))

The attached patch takes care of all of these within the node form.

It also solves the fact that the update frequence form element value does not stick, althoug this occurs for a slightly different reason. In this situation, the #default_value element of the $form array is hard-wired to "3 hours." I changed this by having it check the $node object for the correct value (it is, in fact, already stored in the $node object) and defaulting to the "3 hours" value if there is no value in the $node object.

Note: All of this development was made possible by the sponsorship of Prometheus Labor.

CommentFileSizeAuthor
leech_0.patch8.58 KBMorris Singer

Comments

alex_b’s picture

Morris,

Thank you very much for your patch.

There is a little problem with it though: It removes all changes that where done recently. When you look at the patch, you see that it changes newer code to older one in _leech_news_pass_on_groups() - I guess you changed an older version of leech.module and patched against the latest (?).

Could you patch again the latest version (check out DRUPAL-4-7) and re submit your patch? I would appreciate it.

Alex

funana’s picture

Is there an actual patch right now? This fix is verx important! Or could I do it manually by changing the actual module?

funana’s picture

I tried the development snapshot 4.7.x-1.x.dev and the field settings are still not remembered. If you chose "Frequency: 1 day" , save it and then edit it again it shows up "Frequency: 3 hours".

Morris Singer’s picture

Didn't realize it was an old version. I'm a little new at using CVS. I'll try checking out a new version and patching again as soon as I have a moment.

alex_b’s picture

Morris,

Be sure to check out with

cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -d leech -r DRUPAL-4-7 contributions/modules/leech

Do you see the -r DRUPAL-4-7 flag? That tells CVS to grab the latest version of the DRUPAL-4-7 branch in leech. In leech there are three branches: DRUPAL-4-7 (current 4.7 development), DRUPAL-5 (reserved for future 5.0 development) and MAIN (currently not used).

Looking forward to your updated patch.

aron novak’s picture

Status: Needs review » Fixed

The patch is used at all branches. Thanks!

aron novak’s picture

Status: Fixed » Closed (fixed)