Page 1 of 2
WTF?? I really don't even know what else to call this thread
Posted: Thu Aug 31, 2006 5:10 pm
by Luke
Alright... I've been messing with this damn thing for about 2 hours now... and it still makes no sense why this is doing this... See how I have the echo "if" in there.... ? while that's there, the script echo's "if". if I comment out that line, it prints "else". WHY?? Unless I have that stupid echo in there, it does goes to "else" WTF?
Code: Select all
protected function doLogin(){
if($this->UserSession->has('id')){
echo "If";
$this->view->username = $this->UserSession->get('username');
$this->view->logged_in = true;
$this->view->leftTemplate = "leftbox/loggedin.tpl.php";
return true;
}
else{
echo "Else";
//$this->redirect('user','login');
}
}
Posted: Thu Aug 31, 2006 5:33 pm
by Benjamin
That makes no sense at all.
Posted: Thu Aug 31, 2006 5:35 pm
by pickle
Does the UserSession involve setting cookie or session variables or somehow sending headers? I'm grasping at straws, but it may be that the echo flushes the headers, which then sets the other variables, which the has() function can then access?
Can you post the code for has()?
Posted: Thu Aug 31, 2006 5:35 pm
by Luke
I know it doesn't. I think I figured it out though... sort of. This function is actually called twice in the script I am executing... and somehow (haven't figured that part out yet) the "if" being printed effects the second time the function is called... see what I mean? So it was just a trick that made it look like it was doing what I said up there^
Posted: Thu Aug 31, 2006 6:24 pm
by feyd
Sounds like your script has a memory overwrite issue.
Posted: Thu Aug 31, 2006 6:25 pm
by Luke
I don't know what that means... and google was sort of useless
Posted: Thu Aug 31, 2006 6:30 pm
by feyd
Something is mangling memory somewhere such that commenting out a piece of code that is benign in nature somehow alters the path taken by the code when it shouldn't. I've run into a few situations where this happened to me in a script. I don't recall what the solution was... but changing the logic seems to be familiar. This may involve changing large sums of code or could simply be a logical error that manifests itself in this fashion.
Posted: Thu Aug 31, 2006 6:43 pm
by RobertGonzalez
Instead of echoing have you tried returning the value of the echo? I cannot fathom why that would happen, unless it has something to do with output coming from a protected method (though I seriously doubt that). But try, instead of outputting, returning and see what that does.
Posted: Thu Aug 31, 2006 6:49 pm
by Luke
The Ninja Space Goat wrote:I know it doesn't. I think I figured it out though... sort of. This function is actually called twice in the script I am executing... and somehow (haven't figured that part out yet) the "if" being printed effects the second time the function is called... see what I mean? So it was just a trick that made it look like it was doing what I said up there^
I am pretty sure this was the problem... because I removed the multiple use of the method and it didn't happen any more. I think that what was going on behind the scenes REALLy made it look like this is what was happening, but it wasn't. I was just careless in how I set up the logic. It doesn't happen any more.
Posted: Thu Aug 31, 2006 6:55 pm
by RobertGonzalez
Cool. Glad you got it working.
Posted: Thu Aug 31, 2006 6:56 pm
by Luke
me too... I was almost to the point where I could smash my head through the screen... then I took a walk.

Posted: Fri Sep 01, 2006 2:29 am
by Chris Corbyn
feyd wrote:Something is mangling memory somewhere such that commenting out a piece of code that is benign in nature somehow alters the path taken by the code when it shouldn't. I've run into a few situations where this happened to me in a script. I don't recall what the solution was... but changing the logic seems to be familiar. This may involve changing large sums of code or could simply be a logical error that manifests itself in this fashion.
We've had this bizzaaro issue at work ourselves. Moving a comment by one line made the script do something completely different. We tried it repeatedly to make sure we hadn't gone insane and indeed it was the position of the comment. Nothing else changed. Very wierd.
Posted: Fri Sep 01, 2006 2:35 am
by RobertGonzalez
Ok, for someone who doesn't understand the language of programming, how does memory get mangled (corrupted)?
Posted: Fri Sep 01, 2006 3:36 am
by Jenk
memory pointers can get confused/overwritten and the engine uses the same pointer for different purposes.
Imagine it like a coat/cloak stall. You give in your Black Leather jacket and are given ticket number A1. Someone else comes in and puts their pink fluffy feather jacket in and are given the same ticket number (A1)
You return with ticket A1 and receive the pink fluffy feather jacket and say "wtf?"
Posted: Fri Sep 01, 2006 9:56 am
by Luke
I'd say sweet... this is way cooler than that crappy leather jacket. Then I would put it on and dance around a little... and maybe buy some high-heels. But I don't want to get off topic.