Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#250 check_quota function fails to handle unlimited quota

closed-fixed
nobody
Core (82)
5
2013-12-01
2011-05-24
Keith Dunnett
No

(found in SVN 1061)

When a domain's quota is set to "0", meaning "unlimited quota" according to the web interface, all edits to a user's quota are rejected as too high.

The problem is in the function "check_quota", which checks

if ($quota > $limit['maxquota'])
{
$rval = false;
}

AFTER it checks

if ($limit['maxquota'] == 0)
{
$rval = true;
}

and therefore declines any quota for being greater than the "maximum" of 0. Reversing these two checks fixes the problem and causes a quota of 0 to return a successful quota_check as expected.

Discussion

    • status: open --> closed-fixed
     
  • I prefer code that does not depend on the execution order too much ;-)

    check_quota() was more or less rewritten to support domain-level total quota. On the positive side this means that 2.3.x is not affected by this bug.

    I just changed some parts of the function back to the 2.3.x state - it now uses "return true/false" again instead of settiong $rval if the result is final (as in "can't be changed by domain quota check"). I also added several comments that explain what the function is doing after it took me a while to understand it ;-)

    The bug you reported is fixed by this change:

    - if ($quota > $limit['maxquota']) {
    + if ($limit['maxquota'] != 0 && $quota > $limit['maxquota']) {

    This excludes the "unlimited" maxquota from the check and should therefore solve the problem.

    Commited to SVN trunk r1065. Thanks for the bugreport!