[bugs] [Bug 1033] New - Quota bug report NO LIMIT when no messages in INBOX

bugs@bugs.horde.org bugs@bugs.horde.org
Wed, 28 Aug 2002 12:09:43 -0300


http://bugs.horde.org/show_bug.cgi?id=1033

*** shadow/1033	Wed Aug 28 12:09:43 2002
--- shadow/1033.tmp.15716	Wed Aug 28 12:09:43 2002
***************
*** 0 ****
--- 1,75 ----
+ Bug#: 1033
+ Product: Horde
+ Version: 2.3 Unstable
+ Platform: Mozilla 5.x
+ OS/Version: Linux
+ Status: NEW   
+ Resolution: 
+ Severity: normal
+ Priority: P2
+ Component: IMP
+ Area: BUILD
+ AssignedTo: chuck@horde.org                            
+ ReportedBy: kevin_myer@iu13.org               
+ URL: 
+ Summary: Quota bug report NO LIMIT when no messages in INBOX
+ 
+ I was testing a new account setup system today and logged into webmail with a
+ new account I had just generated.  The user had no mail in their INBOX (it was a
+ dummy account) and _quotaHTML was returning NO LIMIT, even though this user had
+ a quota of 100Mb.
+ 
+ Further investigation revealed that the cause of the problem was the
+ "!empty($used)" statement on line 113 of imp/lib/Quota.php.   That statement
+ will return false if either $used is empty OR if $used is 0, which is the case
+ when a user has no mail.
+ 
+ To fix it, I changed the !empty($used) to isset($used).  I also had to change
+ imp/lib/Quota/cyrus.php to call _quotaHTML with empty values if the
+ imap_getquota call didn't populate the array (which it won't if there is no
+ quota set).  Unfortunately, there's no way to determine the difference between
+ imap_getquota called on a nonexistent mailbox or a mailbox with no quota - both
+ return the same value on the command line.  The example below shows this -
+ test_j_user is a valid, albeit dummy account with no quota, the other is not an
+ account:
+ 
+ . GETQUOTA user/test_j_user
+ . NO Quota root does not exist
+ . GETQUOTA user/jskjdsk
+ . NO Quota root does not exist
+ 
+ However, my logic is that if we get to the point where we're checking the quota
+ on the mailbox, then we've already established that the mailbox exists, and
+ _quotaHTML should just return empty values, if $quota is an empty array so that
+ NO LIMIT is returned from _quotaHTML.
+ 
+ Patches:
+ 
+ imp/lib/Quota.php:
+ --- Quota.php.bak       Wed Aug 28 10:37:53 2002
+ +++ Quota.php   Wed Aug 28 10:37:15 2002
+ @@ -110,7 +110,7 @@
+       */
+      function _quotaHtml($used, $total)
+      {
+ -        if (!empty($used) && !empty($total)) {
+ +        if (isset($used) && !empty($total)) {
+              $used = $used / (1024 * 1024.0);
+              $total = $total / (1024 * 1024.0);
+              $percent = ($used * 100) / $total;
+ 
+ 
+ imp/lib/Quota/cyrus.php (probably needed for other the IMAP servers quota stuff
+ but I don't have them installed to test against and see what their response is):
+ --- cyrus.php.bak	Wed Aug 28 10:53:36 2002
+ +++ cyrus.php	Wed Aug 28 10:52:41 2002
+ @@ -68,7 +68,7 @@
+                  } elseif ($quota['STORAGE']['limit'] != 0) {
+                      return $this->_quotaHTML($quota['STORAGE']['usage'] * 1024,
+ $quota['STORAGE']['limit'] * 1024);
+                  }
+ -            }
+ +            } else return $this->_quotaHTML();
+          }
+  
+          return $this->_quotaError(_("Unable to retrieve quota"));