WordPress.org

Make WordPress Core

Ticket #22873: 22873.diff

File 22873.diff, 1.8 KB (added by aaroncampbell, 16 months ago)

Uses _doing_it_wrong() and throws error in alpha, warning in beta, and notice otherwise

  • wp-includes/wp-db.php

     
    987987         * @return null|false|string Sanitized query string, null if there is no query, false if there is an error and string 
    988988         *      if there was something to prepare 
    989989         */ 
    990         function prepare( $query, $args ) { 
     990        function prepare( $query, $args = null ) { 
    991991                if ( is_null( $query ) ) 
    992992                        return; 
    993993 
     994                if ( is_null( $args ) ) 
     995                        _doing_it_wrong( __METHOD__, sprintf( __( 'The %s parameter should not be empty.' ), '<code>$args</code>' ), '3.5' ); 
     996 
    994997                $args = func_get_args(); 
    995998                array_shift( $args ); 
    996999                // If args were passed as an array (as in vsprintf), move them up 
  • wp-includes/functions.php

     
    29392939 
    29402940        // Allow plugin to filter the output error trigger 
    29412941        if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) { 
     2942                global $wp_version; 
    29422943                $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version ); 
    29432944                $message .= ' ' . __( 'Please see <a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information.' ); 
    2944                 trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ) ); 
     2945 
     2946                $error_type = E_USER_NOTICE; 
     2947                if ( false !== strpos( $wp_version, '-alpha' ) ) 
     2948                        $error_type = E_USER_ERROR; 
     2949                elseif ( false !== strpos( $wp_version, '-beta' ) ) 
     2950                        $error_type = E_USER_WARNING; 
     2951 
     2952                trigger_error( sprintf( __( '%1$s was called <strong>incorrectly</strong>. %2$s %3$s' ), $function, $message, $version ), $error_type ); 
    29452953        } 
    29462954} 
    29472955