#48288 [NEW]: comment above else statment skips it
| From: | atomkirk at gmail dot com | Date: | Thu, 14 May 2009 23:51:34 +0000 |
| Subject: | #48288 [NEW]: comment above else statment skips it | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-2261@lists.php.net to get a copy of this message | ||
From: atomkirk at gmail dot com
Operating system: mac osx leopard
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: comment above else statment skips it
Description:
------------
if you look at the comment "if this child has no other parents besides
this one being deleted" right above the else statement. That comment
causes php to skip over the else statement, so both blocks are executed. I
moved that comment below the else statment, and it executes only the block
its supposed to. In other words, it fixes the problem. I'm no seasoned
programmer, but it seems you should be able to place comments there without
a problem.
Reproduce code:
---------------
//otherwise, we are deleting the actual record and need to transfer
primary children to a secondary parent
$get_direct_decendants = q("SELECT * FROM dayta_records WHERE
parent_record = '$record_id'");
while($child = mysql_fetch_assoc($get_direct_decendants))
{
$child_id = $child['record_id'];
$get_other_parents = q("SELECT * FROM dayta_parents WHERE record_id =
'$child_id'");
//if this child has another parent, transfer it into its primary
if(mysql_num_rows($get_other_parents)>0)
{
$parent = mysql_fetch_assoc($get_other_parents);
//get another parent and make it the primary parent record
$new_parent_id = $parent['parent_id'];
$update = q("UPDATE dayta_records SET parent_record = '$new_parent_id'
WHERE record_id = '$child_id'");
$delete = q("DELETE FROM dayta_parents WHERE record_id = '$child_id'
AND parent_id = '$new_parent_id'");
//if this child has no other parents besides this one being deleted
}else{
//if this child has no other parents besides this one being deleted
$update = q("UPDATE dayta_records SET parent_record = '0' WHERE
record_id = '$child_id'");
//deleteRecord($child_id);
}
}
Expected result:
----------------
should execute only the IF block
Actual result:
--------------
but because of the comment, it executes both IF and ELSE blocks.
--
Edit bug report at http://bugs.php.net/?id=48288&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48288&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48288&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48288&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=48288&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48288&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=48288&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=48288&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=48288&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=48288&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=48288&r=support
Expected behavior: http://bugs.php.net/fix.php?id=48288&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=48288&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=48288&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=48288&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48288&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48288&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=48288&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=48288&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=48288&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=48288&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=48288&r=mysqlcfg