From 4727e6c09f88e63f02e6c8f359862d0c0942ed36 Mon Sep 17 00:00:00 2001 From: "terry%netscape.com" <> Date: Wed, 16 Sep 1998 04:49:23 +0000 Subject: Everything has been ported to now run under Perl. --- sanitycheck.cgi | 115 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 58 insertions(+), 57 deletions(-) (limited to 'sanitycheck.cgi') diff --git a/sanitycheck.cgi b/sanitycheck.cgi index 3d8a82a83..814a1f031 100755 --- a/sanitycheck.cgi +++ b/sanitycheck.cgi @@ -1,5 +1,5 @@ -#! /usr/bonsaitools/bin/mysqltcl -# -*- Mode: tcl; indent-tabs-mode: nil -*- +#!/usr/bonsaitools/bin/perl -w +# -*- Mode: perl; indent-tabs-mode: nil -*- # # The contents of this file are subject to the Mozilla Public License # Version 1.0 (the "License"); you may not use this file except in @@ -19,94 +19,95 @@ # # Contributor(s): Terry Weissman -source "CGI.tcl" -puts "Content-type: text/html" -puts "" +use diagnostics; +use strict; -ConnectToDatabase +require "CGI.pl"; +print "Content-type: text/html\n"; +print "\n"; -proc Status {str} { - puts "$str

" - flush stdout +ConnectToDatabase(); + + +sub Status { + my ($str) = (@_); + print "$str

\n"; } -proc Alert {str} { - Status "$str" +sub Alert { + my ($str) = (@_); + Status("$str"); } -proc BugLink {id} { - return "$id" +sub BugLink { + my ($id) = (@_); + return "$id"; } -PutHeader "Bugzilla Sanity Check" "Bugzilla Sanity Check" +PutHeader("Bugzilla Sanity Check"); + +print "OK, now running sanity checks.

\n"; + +Status("Checking profile ids..."); -puts "OK, now running sanity checks.

" +SendSQL("select userid,login_name from profiles"); -Status "Checking profile ids..." +my @row; -SendSQL "select userid,login_name from profiles" +my %profid; -while {[MoreSQLData]} { - lassign [FetchSQLData] id email - if {[regexp {^[^@, ]*@[^@, ]*\.[^@, ]*$} $email]} { - set profid($id) 1 +while (@row = FetchSQLData()) { + my ($id, $email) = (@row); + if ($email =~ /^[^@, ]*@[^@, ]*\.[^@, ]*$/) { + $profid{$id} = 1; } else { - if {$id != ""} { - Alert "Bad profile id $id <$email>." - } + Alert "Bad profile id $id <$email>." } } -catch {[unset profid(0)]} +undef $profid{0}; -Status "Checking reporter/assigned_to ids" -SendSQL "select bug_id,reporter,assigned_to from bugs" +Status("Checking reporter/assigned_to ids"); +SendSQL("select bug_id,reporter,assigned_to from bugs"); -while {[MoreSQLData]} { - lassign [FetchSQLData] id reporter assigned_to - if {$id == ""} { - continue - } - set bugid($id) 1 - if {![info exists profid($reporter)]} { - Alert "Bad reporter $reporter in [BugLink $id]" +my %bugid; + +while (@row = FetchSQLData()) { + my($id, $reporter, $assigned_to) = (@row); + $bugid{$id} = 1; + if (!defined $profid{$reporter}) { + Alert("Bad reporter $reporter in " . BugLink($id)); } - if {![info exists profid($assigned_to)]} { - Alert "Bad assigned_to $assigned_to in [BugLink $id]" + if (!defined $profid{$assigned_to}) { + Alert("Bad assigned_to $assigned_to in" . BugLink($id)); } } -Status "Checking CC table" +Status("Checking CC table"); -SendSQL "select bug_id,who from cc"; -while {[MoreSQLData]} { - lassign [FetchSQLData] id cc - if {$cc == ""} { - continue - } - if {![info exists profid($cc)]} { - Alert "Bad cc $cc in [BugLink $id]" +SendSQL("select bug_id,who from cc"); +while (@row = FetchSQLData()) { + my ($id, $cc) = (@row); + if (!defined $profid{$cc}) { + Alert("Bad cc $cc in " . BugLink($id)); } } -Status "Checking activity table" +Status("Checking activity table"); -SendSQL "select bug_id,who from bugs_activity" +SendSQL("select bug_id,who from bugs_activity"); -while {[MoreSQLData]} { - lassign [FetchSQLData] id who - if {$who == ""} { - continue - } - if {![info exists bugid($id)]} { - Alert "Bad bugid [BugLink $id]" +while (@row = FetchSQLData()) { + my ($id, $who) = (@row); + if (!defined $bugid{$id}) { + Alert("Bad bugid " . BugLink($id)); } - if {![info exists profid($who)]} { - Alert "Bad who $who in [BugLink $id]" + if (!defined $profid{$who}) { + Alert("Bad who $who in " . BugLink($id)); } } -- cgit v1.2.3-24-g4f1b