[MKDoc-dev] Newsletters broken in MKDoc 1.6?

Sam Tregar sam at tregar.com
Mon Nov 1 03:44:13 GMT 2004


Hello all.  I'm working on adding event support to Newsletters and I'm
running into what looks like broken code.  Is it possible that
newsletters aren't working on the 1-6 branch?  If so, what is the
latest version of MKDoc 1.6.x with known-working newsletter code?

Here's what I'm seeing in the newsletter output:

    The following documents added in the last month may be of interest
    to you:


	<>

	(Created by   on )

I believe this is being caused by this code, from results() in
020..newsletter.pl:

     $h->{Full_Path} =~ s/^\//$::PUBLIC_DOMAIN/;
     $h->{Date_Created} =~ s/\s+.*//;
     $h->{Description} = join '', fill ('    ', '    ', $h->{Description});
     push @res, $h;

This code treats $h as though it points to a hash containing all the
Document table fields.  However the hash was created with an SQL
statement which begins:

  SELECT Document.ID AS ID, SUM(Preference_Audience.Value) AS Pref_Score
  FROM ...

As a result $h points to a hash with just 'ID' and 'Pref_Score' set.
It looks like $doc, which contains the document object, should be used
to get the document data instead of $h.  If I change the code to this:

      $doc->{Full_Path} =~ s/^\//$::PUBLIC_DOMAIN/;
      (my $date = $doc->date_created) =~ s/\s+.*//;
      $doc->set_date_created($date);
      $doc->set_description(join '',fill ('    ', '    ',$doc->description));
      push @res, $doc;

Now I get this result in the newsletter:

    Child Doc 3
	<http://www.example.com/child-doc-3/>
    doc 3
	(Created by   on 2004-10-23)

That's better, but it's missing the name of the creator of the
document.  The template (templates/newsletter/en.xml) has:

  (Created by ${result/Creator_First_Name} ${result/Creator_Family_Name}

Those are neither keys in %$doc nor valid method calls for
flo::Record::Document.  They also don't appear anywhere else in the
MKDoc source.  I suspect they may have been present in a previous
version of the SQL query which computed them by joining
Editor_Created_ID to Editor.

I'msure I can fix this bug but I'm wondering what other problems might
be lurking in this code.  Adding new features to code that's not
working in the first place is a risky activity!  I think it would help
to look at a known-working version of the code, if one exists.

-sam



More information about the MKDoc-dev mailing list