[wp-trac] [WordPress Trac] #38073: Goodbye wp_reset_vars()

WordPress Trac noreply at wordpress.org
Mon Jun 19 05:21:45 UTC 2017


#38073: Goodbye wp_reset_vars()
----------------------------------------+------------------------------
 Reporter:  swissspidy                  |       Owner:
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  Awaiting Review
Component:  General                     |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  needs-patch good-first-bug  |     Focuses:  administration
----------------------------------------+------------------------------

Comment (by jfabot):

 That was indeed the thing I was thinking about.

 Replying to [comment:12 weijland]:
 > Since all wp_reset_vars does is (re)assigning the value of a POST or GET
 request to a variable if it exists, isn't it an idea to write a new
 function which does exactly the same, but without the use of globals?
 Something like this:
 >
 > {{{#!php
 > $action = wp_assign_request_var( 'action' );
 > }}}
 >
 > {{{#!php
 > function wp_assign_request_var( $var ) {
 >    if ( empty( $_POST[ $var ] ) ) {
 >         if ( empty( $_GET[ $var ] ) ) {
 >              return '';
 >         } else {
 >              return $_GET[ $var ];
 >         }
 >    } else {
 >         return $_POST[ $var ];
 >    }
 > }
 > }}}
 >
 > I figure that to fix this issue, a new function is needed, otherwise you
 have to apply the same fix to every file that makes use of
 wp_reset_vars(), which isn't DRY of course. I suggest placing the new
 function in wp-admin/includes/misc.php, since that is the place where the
 original function is located.
 >

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38073#comment:14>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list