[wp-trac] [WordPress Trac] #22325: Abstract GPCS away from the superglobals

WordPress Trac noreply at wordpress.org
Fri Nov 2 19:05:11 UTC 2012


#22325: Abstract GPCS away from the superglobals
-------------------------+-----------------------------
 Reporter:  rmccue       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Future Release
Component:  General      |     Version:
 Severity:  minor        |  Resolution:
 Keywords:               |
-------------------------+-----------------------------

Comment (by MikeSchinkel):

 Replying to [comment:16 CaptainN]:
 > Here's a quick version I through together (without testing):
 > $wp_get = $_GET;
 > $wp_post = $_POST;
 > $wp_request = $_REQUEST;
 > $wp_cookie = $_COOKIE;
 > $wp_server = $_SERVER;

 Ignoring everything else for the moment, I think WordPress is moving away
 from global vars and not adding any new ones. Can someone else confirm
 this?

 > So how do you mix the default value specification in the method
 signature that retains the multidimensional capability of PHP forms
 (name="level1[level2]"). I'd use the second (third, etc.) arguments as a
 way to access the indexes in the array (_get('level1','level2');), but
 you've used them to specify the default value.

 The code I uploaded used an array for that, i.e.:

 {{{
 $print_r(  _GET( array( 'level1', 'level2' ) ) );
 }}}

 > Also, how would you know that you've set the default value? You'd still
 have to check that. Maybe more methods are called for?
 >
 > {{{
 > // default value and set in the GPCS method
 > if ( _get( 'myVar', 'default value' ) != 'default value' ) {
 >     // validation passes
 > }

 What's the use case where that is needed that `has_GET()`and not passing a
 default `_GET( 'myVar' )`  doesn't address?

 > // a function to check for a default value with NULL checks
 > if ( _check( _get( 'myVar' ), 'default value' )  {
 >     // the value is validated
 > }
 >
 > // and if you need to output the value with a default
 > echo _default( _get( 'myVar' ), 'default value' );

 `_default()` and `_check()` seems like more work than doing it the old
 way.  IMO, of course.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/22325#comment:17>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list