Changeset 24718
- Timestamp:
- 07/16/2013 05:44:42 PM (12 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/formatting.php
r24683 r24718 2592 2592 2593 2593 /** 2594 * Escapes data for use in a MySQL query 2595 * 2596 * This is just a handy shortcut for $wpdb->escape(), for completeness' sake 2594 * Escapes data for use in a MySQL query. 2595 * 2596 * Usually you should prepare queries using wpdb::prepare(). 2597 * Sometimes, spot-escaping is required or useful. One example 2598 * is preparing an array for use in an IN clause. 2597 2599 * 2598 2600 * @since 2.8.0 2599 * @param string $ sql Unescaped SQLdata2600 * @return string The cleaned $sql2601 */ 2602 function esc_sql( $ sql) {2601 * @param string $data Unescaped data 2602 * @return string Escaped data 2603 */ 2604 function esc_sql( $data ) { 2603 2605 global $wpdb; 2604 return $wpdb-> escape( $sql);2606 return $wpdb->_escape( $data ); 2605 2607 } 2606 2608 -
trunk/wp-includes/wp-db.php
r24712 r24718 847 847 848 848 /** 849 * Weak escape, using addslashes() 850 * 851 * @see addslashes() 849 * Do not use, deprecated. 850 * 851 * Use esc_sql() or wpdb::prepare() instead. 852 * 852 853 * @since 2.8.0 854 * @deprecated 3.6.0 855 * @see wpdb::prepare 856 * @see esc_sql() 853 857 * @access private 854 858 * … … 857 861 */ 858 862 function _weak_escape( $string ) { 863 if ( func_num_args() === 1 ) 864 _deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' ); 859 865 return addslashes( $string ); 860 866 } … … 877 883 * Escape data. Works on arrays. 878 884 * 879 * @uses wpdb::_escape()880 885 * @uses wpdb::_real_escape() 881 886 * @since 2.8.0 … … 887 892 function _escape( $data ) { 888 893 if ( is_array( $data ) ) { 889 foreach ( (array)$data as $k => $v ) {894 foreach ( $data as $k => $v ) { 890 895 if ( is_array($v) ) 891 896 $data[$k] = $this->_escape( $v ); … … 901 906 902 907 /** 903 * Escapes content for insertion into the database using addslashes(), for security. 904 * 905 * Works on arrays. 906 * 907 * @since 0.71 908 * @param string|array $data to escape 909 * @return string|array escaped as query safe string 908 * Do not use, deprecated. 909 * 910 * Use esc_sql() or wpdb::prepare() instead. 911 * 912 * @since 0.71 913 * @deprecated 3.6.0 914 * @see wpdb::prepare() 915 * @see esc_sql() 916 * 917 * @param mixed $data 918 * @return mixed 910 919 */ 911 920 function escape( $data ) { 921 if ( func_num_args() === 1 ) 922 _deprecated_function( __METHOD__, '3.6', 'wpdb::prepare() or esc_sql()' ); 912 923 if ( is_array( $data ) ) { 913 foreach ( (array)$data as $k => $v ) {924 foreach ( $data as $k => $v ) { 914 925 if ( is_array( $v ) ) 915 $data[$k] = $this->escape( $v );926 $data[$k] = $this->escape( $v, 'recursive' ); 916 927 else 917 $data[$k] = $this->_weak_escape( $v );928 $data[$k] = $this->_weak_escape( $v, 'internal' ); 918 929 } 919 930 } else { 920 $data = $this->_weak_escape( $data );931 $data = $this->_weak_escape( $data, 'internal' ); 921 932 } 922 933
Note: See TracChangeset
for help on using the changeset viewer.