Item1151: statistics script is broken in release 1.0.2 and on trunk.foswiki.org

pencil
Priority: Urgent
Current State: Closed
Released In: 1.0.3
Target Release: patch
Applies To: Engine
Component:
Branches:
Reported By: ChYang
Waiting For:
Last Change By: KennethLavrsen
I have the same problem in my site after upgrading to release 1.0.2.

You can test it with http://trunk.foswiki.org/bin/statistics/Tasks

Software error:

Global symbol "$line" requires explicit package name at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/Statistics.pm line 288.
Compilation failed in require at (eval 12) line 2.
 at (eval 12) line 2
	Foswiki::UI::BEGIN() called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/Statistics.pm line 2
	eval {...} called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI/Statistics.pm line 2
	eval 'use Foswiki::UI::Statistics
;' called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 107
	Foswiki::UI::handleRequest('Foswiki::Request=HASH(0xb41748)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Engine/CGI.pm line 26
	Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x9a5388)') called at /home/trunk.foswiki.org/core/bin/statistics line 45
BEGIN failed--compilation aborted at (eval 12) line 2.
 at (eval 12) line 2
	eval 'use Foswiki::UI::Statistics
;' called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/UI.pm line 107
	Foswiki::UI::handleRequest('Foswiki::Request=HASH(0xb41748)') called at /usr/home/trunk.foswiki.org/core/lib/Foswiki/Engine/CGI.pm line 26
	Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x9a5388)') called at /home/trunk.foswiki.org/core/bin/statistics line 45

For help, please send mail to the webmaster (webmaster@sonologic.nl), giving this error message and the time and date of the error. 

-- ChYang - 26 Feb 2009

OlivierRaginel pointed out on IRC that the problem is deeper than that. The following patch should cure the problem, though I am not in a position to test it at the moment.
Index: Statistics.pm
===================================================================
--- Statistics.pm   (revision 2714)
+++ Statistics.pm   (working copy)
@@ -206,18 +206,18 @@
 
     my $it = $session->logger->eachEventSince($start, 'info');
     while ( $it->hasNext() ) {
-        my $data = $it->next();
-        my $date = shift(@$data);
+        my $line = $it->next();
+        my $date = shift(@$line);
 
         my ( $logFileUserName );
 
-        while ( !$logFileUserName && scalar(@$data) ) {
-            $logFileUserName = shift @$data;
+        while ( !$logFileUserName && scalar(@$line) ) {
+            $logFileUserName = shift @$line;
             $logFileUserName =
               Foswiki::Func::getCanonicalUserID($logFileUserName);
         }
 
-        my ( $opName, $webTopic, $notes, $ip ) = @$data;
+        my ( $opName, $webTopic, $notes, $ip ) = @$line;
 
         # ignore minor changes - not statistically helpful
         next if ( $notes && $notes =~ /(minor|dontNotify)/ );
@@ -285,7 +285,9 @@
             }
         }
         else {
-            $session->writeDebug( 'WebStatistics: Bad logfile line ' . $line );
+            $session->logger->log(
+                'debug', 'WebStatistics: Bad logfile line ' .
+                  join('|', @$line) );
         }
     }
-- CrawfordCurrie - 26 Feb 2009

I think we plain and simply need to revert the logging changes. They should never have been in a patch release in the first place.

Just sad that noone took up the task to create the Release01x00 branch after I had built 1.0.1. It was 5 AM in the morning when I finished 1.0.1 and I would have collapsed if I had continued.

Revert please

-- KennethLavrsen - 26 Feb 2009

The patch will bypass the error, but the statistics are wrong now ...

"My Topic views" of 2009 Feb decreased from 1332 to 144 ...

Besides, I got the following error if I run the script in linux shell.
[Thu Feb 26 21:54:41 2009] statistics: Argument "1 Feb 2009" isn't numeric in localtime at /var/www/foswiki/lib/Foswiki/Time.pm line 257.
[Thu Feb 26 21:54:41 2009] statistics: Argument "1 Feb 2009" isn't numeric in localtime at /var/www/foswiki/lib/Foswiki/Time.pm line 257.
[Thu Feb 26 21:54:42 2009] statistics: Argument "1 Feb 2009" isn't numeric in numeric ge (>=) at /var/www/foswiki/lib/Foswiki/Logger/PlainFile.pm line 95, <$fh> line 2820.

-- ChYang - 26 Feb 2009

There was a further fix required in distro:656f071a952d not reflected in the patch. I have tested with my old logfiles, and it works.

Should be good for release now.

-- CrawfordCurrie - 26 Feb 2009

ItemTemplate edit

Summary statistics script is broken in release 1.0.2 and on trunk.foswiki.org
ReportedBy ChYang
Codebase trunk
SVN Range SVN 2714: Foswiki-1.0.2, Wed, 25 Feb 2009, build 2711
AppliesTo Engine
Component
Priority Urgent
CurrentState Closed
WaitingFor
Checkins distro:8261bc2787d3 distro:656f071a952d
TargetRelease patch
ReleasedIn 1.0.3
Topic revision: r9 - 01 Mar 2009, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy