When an invalid value is set in 'throttle_anonymous(_user)' once, the change of the value becomes impossible.

One method of the fix is as follows.

// $Id: throttle.module,v 1.68 2006/10/22 08:28:46 unconed Exp $

function throttle_admin_settings() {
  if (isset($_POST['throttle_anonymous'])) {
    variable_set('throttle_anonymous', $_POST['throttle_anonymous']);
  }
  if (isset($_POST['throttle_user'])) {
    variable_set('throttle_user', $_POST['throttle_user']);
  }
  _throttle_validate(variable_get('throttle_anonymous', ''), 'throttle_anonymous');
  _throttle_validate(variable_get('throttle_user', ''), 'throttle_user');

Comments

greggles’s picture

How would I get an invalid value into that? How do I repeat this problem to be able to confirm it?

greggles’s picture

And in the future please provide actual patches, not just pasted code:
http://drupal.org/diffandpatch

chx’s picture

Priority: Critical » Normal

soon to be won't fixed but i hold it for a little while.

Takafumi’s picture

Version: 5.0-beta1 » 5.x-dev
StatusFileSize
new1020 bytes

1. go to admin/settings/throttle
2. enter '-1' at 'Auto-throttle on anonymous users' field
3. click 'save configuration'
4. afterwards, you try the change of the value
5. however, it's impossible to change the value.

confirm it according to the above-mentioned procedure.

greggles’s picture

Yes, I can confirm this issue and I confirm that your patch fixes it. I can't comment about whether or not your fix is the right way to fix it.

Takafumi’s picture

StatusFileSize
new1.05 KB

I have improved the patch.
This patch will not save an invalid value.

chx’s picture

Status: Active » Needs work

using $_POST is wrong in 5.0 . If you need , I can dug into the issue but this fix is not aceptable.

Takafumi’s picture

StatusFileSize
new684 bytes

Another way is to restore the default value.

edmund.kwok’s picture

Status: Needs work » Needs review
StatusFileSize
new1.94 KB

Throttle settings should be validated in the _validate callback, not after the settings have been saved. Also removed _throttle_validate as it's not used anywhere else.

Takafumi’s picture

Status: Needs review » Reviewed & tested by the community

Confirmed it, and this patch works fine.
thanks.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Good code, simple fix. Committed to CVS HEAD.

Takafumi’s picture

Status: Fixed » Closed (fixed)

thanks.