Ready to get started?Download WordPress


Update sanitize functions to accept unset variables

  1. Luke Gedeon


    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: 3 months ago #

RSS feed for this topic


You must log in to post.

  • Rating

    4 Votes
  • Status

    This idea is under consideration