Gossamer Forum
Quote Reply
Icky Loop
I have the following code in a plugin:

Code:
else {
die "GOT HERE";
print $IN->header();
print Links::SiteHTML::display('cart_verify_error', { undef_error => 1 } );
}

....the die part is for debugging. When I run the script it dies with "GOT HERE" so I know we are at the else block, however as soon as I remove the die() I just get an infinite loop and no template shows.

Can anyone think why?
Quote Reply
Re: [Paul] Icky Loop In reply to
Maybe you need an exit? The die forces an exit, but when you take that out then it's going to go 'loopy' - hey, that's another technical term for you today ;-).

Code:
else {
# die "GOT HERE";
print $IN->header();
print Links::SiteHTML::display('cart_verify_error', { undef_error => 1 } );
exit;
}

- wil
Quote Reply
Re: [Wil] Icky Loop In reply to
Nope, the exit isn't it. I've tried exits and returns. Even if an exit was needed that wouldnt cause a loop, it would just print two templates on one page.

Last edited by:

Paul: Apr 22, 2002, 8:04 AM
Quote Reply
Re: [Paul] Icky Loop In reply to
Ah well. Worth a try. I don't have a clue how these GT programs work, so I was just observing Perl code.

Cheers

- wil
Quote Reply
Re: [Paul] Icky Loop In reply to
Well,

Did you try putting a "print" statement before the code, and then after it?

What happens?

Do the two lines of code excute (ie: the second print statement executes?)

The loop may be AFTER that point, since "die" terminates the program execution, the use of print statements and if you want to stop execution "exit" code is better than "die".

Print lets you check several breakpoints, and see what is really happening.

Put the exit after the two lines of code. if they excute, and/or the program stops, the loop is not at that point, but later on.


PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Icky Loop In reply to
>>
Put the exit after the two lines of code. if they excute, and/or the program stops, the loop is not at that point, but later on.
<<

As I mentioned I've tried exit and return already and it never reaches that point so it is something to do with loading and parsing the template but I can't figure out why seeing as calling templates in another routine works with exactly the same code..

>>if you want to stop execution "exit" code is better than "die". <<

Well depends on what you want to achieve. Just quitting then use exit yes. But really you shouldn't need exits at all apart from in error routines.

Last edited by:

Paul: Apr 23, 2002, 1:50 AM
Quote Reply
Re: [Paul] Icky Loop In reply to
This is so weird...its happening on two different copies of Links SQL

I had:

Code:
if ($variable->{payment_status} !~ /completed/i) {
print $IN->header();
print Links::SiteHTML::display('cart_verify_error', { incomplete => 1 } );
return;
}

....which caused the loop and nearly crashed the server, but when I changed it to:

Code:
if ($variable->{payment_status} !~ /completed/i) {
print $IN->header();
print "DIE";
#print Links::SiteHTML::display('cart_verify_error', { incomplete => 1 } );
return;
}
...it worked fine.

What can be causing it to loop? ugh.

Last edited by:

Paul: Apr 23, 2002, 5:27 AM
Quote Reply
Re: [Paul] Icky Loop In reply to
Running:

print Links::SiteHTML::display('cart_verify_error', { incomplete => 1 } );

is causing the your plugin to fire again, which runs that sub, which causes the plugin to fire, and so on, and so on. =)

That's most likely where the problem is. Without knowing more about the hooks setup, I couldn't say more.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Icky Loop In reply to
Thats strange...why is it doing that?

That particular routine isn't hooked anywhere, it is being posted to by paypal.

I have all the subs in one pm file but a seperate script calling that one routine with the problematic code in.

So in ipn.cgi I call Plugins::ShoppingCart::verify

....thats when I hit the problem.

The rest of the cart works perfectly well when showing templates.

Last edited by:

Paul: Apr 24, 2002, 2:05 AM
Quote Reply
Re: [Alex] Icky Loop In reply to
I've removed the code from the main plugin so it can't be affected by hooks and it is still looping.
Quote Reply
Re: [Alex] Icky Loop In reply to
Heeeelp! Smile

The script is totally seperate from the plugin now and it is still looping. I've tried adding STOP actions everywhere and it makes no difference.....I've changed:

GT::Plugins->dispatch ($CFG->{admin_root_path} . '/Plugins', 'verify_ipn', \&Plugins::IPN::verify);

to:

Plugins::IPN::verify;

....and it is still looping.
Quote Reply
Re: [Alex] Icky Loop In reply to
Any thoughts on this Alex?...nothing I try seems to fix it.
Quote Reply
Re: [Paul] Icky Loop In reply to
Unsure
Quote Reply
Re: [Paul] Icky Loop In reply to
Sorry Paul, must have missed this. Send me the code and I'll take a look and see what's wrong.

Cheers,

Alex
--
Gossamer Threads Inc.