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

WordPress Trac noreply at wordpress.org
Wed Feb 27 08:22:55 UTC 2013


#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 rmccue):

 The attached patch is the simplest thing that can possibly work. All it
 does is set `$wp->GET`, `$wp->POST` and `$wp->REQUEST` after deslashing
 and before reslashing.

 This does involve one change that may break a bit of compatibility. In
 order to set those variables without unslashing them again,
 `wp_magic_quotes()` needs to be called after the request object is
 instantiated. I chose to move this to after `new WP()` but this may affect
 things hooked into `sanitize_comment_cookies` or via
 `WP_Rewrite::__construct()`. I'll test this further, but we're going to
 have to move one of them to use `$wp->...`

 Alternatively:
 1. We could set these as static variables on `WP`. This kind of defeats
 the purpose of having a request object though.
 2. We could unslash the superglobals in `WP::init()`. This means between
 `wp_magic_quotes()` and `WP::init()`, we need to manually unslash any
 superglobals, which may be a bit weird for plugins hooked in at those
 points. Additionally, this is extra work for the server (unslash magicked
 vars, slash all vars, unslash for `$wp` copy)
 3. We could instantiate `WP` earlier. This may affect plugins in subtle
 ways, so I haven't fully investigated this yet.

 I'm happy to revise the patch for these choices. I'm in favour of 3, but
 it may have subtle effects.

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


More information about the wp-trac mailing list