Reply to Help!! Inexplicable PHP issue - driving me further into insanity

Your name:

Reply:


Posted by adrian.price@gmail.com on 02/15/06 17:04

Okay. I've been staring at this for 48 hours now, with absolutely no
luck. Every time I try to break it down further, it makes less sense.
I've now broken this down to such a level that I can't think of any way
this can even happen. But enough of that. Take this code:

$x = "( ( !$enrollment_id || !$sch_id || \"".$course['state']."\" !=
\"approved\" ) && !".(int)
$auth->check_perm('lms','submit_course',PERM_READ)." )";
$y = ( ( !$enrollment_id || !$sch_id || $course['state'] != 'approved'
) && !$auth->check_perm('lms','submit_course',PERM_READ) );

debug($x,$y);

if ( $y )
debug($x,$y);

if ( ( !$enrollment_id || !$sch_id || $course['state'] != 'approved' )
&& !$auth->check_perm('lms','submit_course',PERM_READ) )
{ /* real code here */ }


$auth->check_perm returns a boolean. In this context, $enrollment_id
and $sch_id are provided and non-zero, and $course['state'] =
"approved". The function debug() spits out all the provided arguments
along with some debugging info, and serves as a breakpoint. Now. Out of
150 users of this system, 4 have experienced an issue where, when that
if should be false, it comes out true, reliably, on the server and my
test platform. There's a lot of background information, some of which I
can provide (though I have to be somewhat vague, as this is proprietary
code), but I don't think I need to, and I'll explain why:

If you leave the first breakpoint in, you get this:
Debugging: array (
0 => '( ( !36 || !19 || "approved" != "approved" ) && !0 )',
1 => false,
)

If you comment out the first breakpoint, it breaks inside the if
statement, even though it just said the value in the if expression is
false:
Debugging: array (
0 => '( ( ! || ! || "approved" != "approved" ) && !0 )',
1 => true,
)

So, my question is, how can the values referenced in the assignment of
$x and $y change based on whether or not those variables, or variables
assigned using data from those variables, are in an if statement? If
you can explain that to me, I'd be thrilled, because I have a headache
the size of siberia right now!

(The code above is obviously incomplete, but it is copy-and-pasted from
the source file unaltered, save for commenting out the code at the very
end. And I don't really see how any other code in the file could affect
it in this situation, but obviously something is.)

If you can give even a clue or a direction to look in, I'd hugely
appreciate it!!!

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация