WordPress.org

Ready to get started?Download WordPress

Ideas

Update sanitize functions to accept unset variables

  1. Luke Gedeon
    Member

    12345

    One seemingly unnecessary pain in processing $_POST values is that you *should* be checking if a value is passed before sanitizing. Although, I often see this skipped - probably because this is so painful:

    $my_var = isset( $_POST[ 'my_var' ] ) ? $_POST[ 'my_var' ] : null;

    Instead, we could update all sanitization functions to receive by reference and check for isset() inside the functions.

    Alternatively, we could add a function like:

    function set( &$test, $default = null ) {
    	return isset( $test ) ? $test : $default;
    }

    Then you could at least use that in place of an unsightly ternary.

    Posted: 2 months ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    4 Votes
  • Status

    This idea is under consideration