Declare $statistics to prevent warning

scoates - December 10, 2007 - 02:30
Project:Mailing List Archive
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed
Description

The stock mailarchive_stats.module complains when there are no subscriptions set up:

warning: Invalid argument supplied for foreach() in /Users/sean/svn/mailarchive/mailarchive_stats/mailarchive_stats.module on line 168.

To fix this, $statistics must be declared. Here's a patch:

Index: mailarchive_stats.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mailarchive/mailarchive_stats/mailarchive_stats.module,v
retrieving revision 1.6
diff -u -r1.6 mailarchive_stats.module
--- mailarchive_stats.module 16 Nov 2007 02:36:36 -0000 1.6
+++ mailarchive_stats.module 10 Dec 2007 02:24:45 -0000
@@ -119,6 +119,7 @@
   $hour = date('YmdH', $now);
   $lasthour = date('YmdH', $now - 3600);

+  $statistics = array();
   $result = db_query('SELECT sid, nid, urlname, subscription_status, message_count, last_message FROM {mailarchive_subscriptions}');
   while ($subscription = db_fetch_object($result)) {
     // All time statistics.

#1

Jeremy@kerneltr... - December 10, 2007 - 16:38
Status:patch (code needs review)» fixed

Thanks for the bug report. Fix committed. I added a friendly message if no subscriptions are created.

#2

Anonymous - December 24, 2007 - 16:41
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.