nysus has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I found a bug in Movable Type. Anybody out there familiar with it and successfully hacked it? I'm trying to find the module and line number the error is emanating from but putting
use CGI::Carp qw(fatalsToBrowser);
into the mt.cgi script fails to produce anything.

Am I using Carp wrong?

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop";
$nysus = $PM . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re: Hacking Movable Type
by dws (Chancellor) on Mar 31, 2003 at 01:31 UTC
    Hi, I found a bug in Movable Type. Anybody out there familiar with it and successfully hacked it?

    Yes and yes. And they have a very active support forum. Have you tried there? This sounds like a problem that others might already have run into. There might already be a fix.

      I wouldn't be here if I didn't. No one has a fix.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop";
      $nysus = $PM . $MCF;
      Click here if you love Perl Monks

Re: Hacking Movable Type
by enoch (Chaplain) on Mar 31, 2003 at 00:37 UTC
    What is the bug that you are encountering?

    enoch
      When I try to make a thumbnail, I get a 500 internal server error. Image::magick is installed. Others have encountered the same problem. No one on MT forum has an answer. Someone reported a
      perl: resize.c:1054: ResizeImage: Assertion `image->signature == 0xabacadabUL' failed. 
      
      error. I'm trying to confirm this but I can't get error to print.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop";
      $nysus = $PM . $MCF;
      Click here if you love Perl Monks

        Reading the logs is an obvious suggestion. CGI::Carp misses some 500 stuff. Try adding this which is pretty robust:

        #!/usr/bin/perl BEGIN { $|++; print "Content-type: text/html\n\n"; # this may also help as it will capture STDERR in the browser open STDERR, ">&STDOUT"; use CGI::Carp 'fatalsToBrowser'; } print STDERR "<p>Foo</p>"; print STDOUT "<p>Bar</p>"; # catches almost all errors one way or another # if ( $syntax_error ) { END { print STDERR "Exiting!" }

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Hacking Movable Type
by thpfft (Chaplain) on Mar 31, 2003 at 13:58 UTC

    imagemagick is extremely horrible to get right, and MT only require()s it as needed, so I'd assume that an installation glitch is likely and work at this one from both ends. First test your imagemagick installation from the command line:

    $ convert ./my.jpg my.png

    and then from a minimal script. If this works, for example, you can say with confidence that MT is broken:

    use Image::Magick; my $infile = '/some/image/or/other.jpg'; my $outfile = '/some/image/or/other_thumb.jpg'; my $image = Image::Magick->new; my $check = $image->Read( filename => "$infile" ); die $check if $check; $check = $image->Resize( geometry => "50x50" ); die $check if $check; $check = $image->Write( filename => "$outfile" ); die $check if $check; undef @$image; print "ok\n";

    Meanwhile, and assuming that nothing useful comes out of all that, you need to isolate the thumbnail-shrinking part of MT (which is in ./lib/MT/Image.pm) and, as tachyon suggests, fill it with warn statements and watch the logs. Note the odd way that IM returns errors above, for example, and drop that code into the right bit of MT along with lots of statements that tell you what filename it's trying to open and why it thinks that's a good idea.

    You may even find that MT has a verbose toggle somewhere that will do this for you.

     

    update: I tried to investigate properly but it just works here, which is annoying :).

    I did learn two things, though. FIrstly that MT has some weird stuff going on with paths and it's worth double-checking all that, and secondly that MT consistently signals failure by returning an error object. The quick and dirty way to see what's going on would be to add this to MT::ErrorHandler after line 14:

    warn $msg;

    or for the maximum debug-fountain:

    # at the top use Carp qw/cluck/; # in sub error again: cluck $msg;

    good luck.

      Yeah, I think you are on to something with the configuration of Image::Magick. I keep getting this error:
      perl: constitute.c:2015: ReadImage: Assertion `image_info->signature == 0xabacadab' failed.
      when Image::Magick gets called by Perl.

      $PM = "Perl Monk's";
      $MCF = "Most Clueless Friar Abbot Bishop";
      $nysus = $PM . $MCF;
      Click here if you love Perl Monks

        I've never seen that particular error, but if the command-line tools work and the perl tools don't, it's nearly always because the installations of Imagemagick and Perlmagick don't match.

        If you installed IM from the source, try installing the version of Perlmagick in the same package, with a configuration that corresponds to what you used for IM. If you didn't, then may Allah smile upon your unworthy brow, for you are about to start :)