[dev] Patch to conf.php.dist to fix bug in imp_show_quota example

Joshua E Warchol jwarchol@dsl.net
Thu, 18 Apr 2002 16:10:53 -0400


---------------------- multipart/mixed attachment
Hi all,

In the exmaple of a imp_show_quota function, where you test the results
of the call to imap_get_quota(), the test is invalid. 

imap_get_quota returns either an array, or false. In IMP 3.1rc2 you use
the empty() function to test this. But empty() returns true if a variable 
is set to false. In the HEAD branch you use:

  if (isset($quota) && $quota['limit'] != 0) 

That's better, as it prevents divide by zero errors, if there is a quota. 
The isset() really doesn't need to be there, as it will always be set to
either an array or false. 

The documenation for imap_get_quota() suggests using is_array() to check
the return value. Attached is a patch against 3.1rc2 to add this, as well
as non-zero check.

Thanks.


-- 
Joshua Warchol
UNIX Systems Administrator
DSL.net

---------------------- multipart/mixed attachment
--- conf.php.dist	Thu Apr 18 15:53:01 2002
+++ conf.php.dist.orig	Thu Apr 18 15:52:22 2002
@@ -385,7 +385,7 @@
 //         // $quota = @imap_get_quota($stream, 'ROOT');
 //         imap_close($stream); 
 //
-//         if (is_array($quota) && ($quota['limit'] != 0)) {
+//         if (!empty($quota)) {
 //             $taken   = $quota['usage'] / 1024.0;
 //             $total   = $quota['limit'] / 1024.0;
 //             $percent = $taken * 100 / $total;

---------------------- multipart/mixed attachment--