From:             jeremy dot tharp at gmail dot com
Operating system: Redhat Linux
PHP version:      5.2.9
PHP Bug Type:     Feature/Change Request
Bug description:  It would be nice if there were a temporary conditions control 
structure

Description:
------------
This isn't really a bug, but I think it would be great to have a control
structure that has temporary execution parameters.  Consider it an
execution space similar to a while or switch, etc.

The reason I could use it in this particular instance is for security
reasons.  For certain code, I need to elevate a logged in user's "status"
to temporarily give them super user permissions.  Basically I temporarily
convert the user, run the code, then convert them back.

convert_user();
execute_code_here();
convert_user_back();

This works great, of course, but if I have to do this 300 times, there is
a decent chance that I would forget to convert_user_back();, causing a
security hole (the user would then be logged in as a super user).

It would be great if I could do something like

execspace conversion_space ($params[]) {
     function start () {
          convert_user();
    }
    function stop  () {
          convert_user_back();
   }
}

Then in my actual code, I would do:

conversion_space {  // start function executes here
      // execute some code
} // stop function executes here

This way, it is grammatically impossible to implement the structure
without closing it.

I think this would be a powerful control structure for the language. 
Perhaps there is an equally useful solution that I am unaware of, but if
not, I think implementing it is worth consideration (and if there is, I
would certainly appreciate the enlightenment!)


-- 
Edit bug report at http://bugs.php.net/?id=47926&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=47926&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=47926&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=47926&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=47926&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47926&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=47926&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=47926&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=47926&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=47926&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=47926&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=47926&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=47926&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=47926&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=47926&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=47926&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=47926&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=47926&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=47926&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=47926&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=47926&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=47926&r=mysqlcfg

Reply via email to