Discussion

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 ;-)