Gossamer Forum
Home : Products : Gossamer Links : Discussions :

page.cgi Bug Report - Fix Anyone?

Quote Reply
page.cgi Bug Report - Fix Anyone?
hiya,

if you call page.cgi with:

page.cgi?p=template-that-doesnt-exist

it causes a fatal error.

can anyone supply a fix (posted here) that will stop the error happening? What I imagine is that if it's called with a p templtate name that doesn't exist it defaults to the error page.

Just so you know, what I'm doing is calling some additional information pages (templates) through the page.cgi script, so to get them I'm doing page.cgi?p=infopage - as an example. So it would need to default to the error page rather than just present the home page.

cheers,

regan.

Last edited by:

ryel01: Jul 25, 2002, 2:57 AM
Quote Reply
Re: [ryel01] page.cgi Bug Report - Fix Anyone? In reply to
<shameless self-promotion>

If you use my PageBuilder plugin, you can create as many dynamic and static pages as you like. In dynamic mode, you call them by page.cgi?page=infopage
If the template doesn't exist, a custom error page is shown by default.

</shameless self-promition>

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] page.cgi Bug Report - Fix Anyone? In reply to
Did you release the page builder plugin?

I know you were trying to override the Links::Fatal call.



A quick and dirty work around is found at the top of the Site_Html.pm

Code:
sub display {
# -----------------------------------------------------------------
# Returns a specified template parsed.
#
my ($template, $vars, $opts) = @_;
my $code = exists $Links::SiteHTML::{"site_html_$template"} ? $Links::SiteHTML::{"site_html_$template"} : _compile ("site_html_$template");
defined $code or die "Invalid method: site_html_$template called.";

GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', "site_html_$template", $code, $vars, $opts);
}


replace the "or die...." with function call to

sub site_html_error

Where you can do things like check if the fail was with link data, or category data, or for personal pages, and display an error page.

Just make sure to check that you do not get into a recursive call. You might want to set a counter variable, to check that.

You could make the "or die..." a function call to another module, even, so on upgrades all you'd need to do is change that one phrase to the new function call.

That is the pre-fail condition if there is no hard-coded template routine, or a template on-disk.

It would be nice if Links had an error handler that allowed overriding specific error conditions, but all errors do not go through the Links::Error handler, such as the "die" condition, which is trapped, but not really handled.

Anyway, this specific "override" condition seems easy enough... it won't generalize to other error conditions, only the "template not found" condition.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] page.cgi Bug Report - Fix Anyone? In reply to
No, not released yet, but ready. I'm waiting for GT's new plugin download system...

Quote:
I know you were trying to override the Links::Fatal call.

?

I did not overwrite Links::Fatal. I just have a pre hook on handle_page, and everything with a key page is handled by the plugin, the rest goes through.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [pugdog] page.cgi Bug Report - Fix Anyone? In reply to
>>
A quick and dirty work around is found at the top of the Site_Html.pm
<<

All you have to do to override it is set your own or reset it.

local $SIG{__DIE__} = '';

local $SIG{__DIE__} = \&MyPlugin::fatal;
Quote Reply
Re: [Paul] page.cgi Bug Report - Fix Anyone? In reply to
That would override all 'die' calls in that scope, right?

All we want to catch is the specific case of the "template not found", and change the die to some sort of error handler.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] page.cgi Bug Report - Fix Anyone? In reply to
Yep it would override all fatals within the "local" block { }

It means you could make nice custom errors for your plugins though :)
Quote Reply
Re: [yogi] page.cgi Bug Report - Fix Anyone? In reply to
my version of the pagebuilder plugin



use LWP::Simple;
my $content = get("http://lsql/page.cgi?p=thepageuwant");
open (FILE, "public_html/thepageuwant.html");
print FILE $content;
close (FILE);
print "woo";

Last edited by:

TLA: Jul 25, 2002, 5:33 AM
Quote Reply
Re: [TLA] page.cgi Bug Report - Fix Anyone? In reply to
Yeah but thats rubbish Angelic
Quote Reply
Re: [TLA] page.cgi Bug Report - Fix Anyone? In reply to
you actually use that?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] page.cgi Bug Report - Fix Anyone? In reply to
works for me :)

If you want a static version of a dynamic page to reduce server load, why would you need anything more?



Of coursework you could do something like

my @file = readdir(DIR);

foreach $file (@files){

if ($file =~ /^custom/){

blarg

}

}



???

Last edited by:

TLA: Jul 25, 2002, 6:21 AM
Quote Reply
Re: [Paul] page.cgi Bug Report - Fix Anyone? In reply to
In Reply To:
Yeah but thats rubbish Angelic
lol
Quote Reply
Re: [TLA] page.cgi Bug Report - Fix Anyone? In reply to
FWIW: Static vs Dynamic

You don't save *bandwidth* you save CPU or server resources.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [TLA] page.cgi Bug Report - Fix Anyone? In reply to
I want something more because I want a page hierarchy, i.e. one page is a "child" of a different page.

Plus (but that's off topic here), pagebuilder can build pages for links, categories, users, editors, reviews.

Ivan
-----
Iyengar Yoga Resources / GT Plugins