Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: class-wpdb.php
/**
[2500] Fix | Delete
* Replaces a row in the table or inserts it if it does not exist, based on a PRIMARY KEY or a UNIQUE index.
[2501] Fix | Delete
*
[2502] Fix | Delete
* A REPLACE works exactly like an INSERT, except that if an old row in the table has the same value as a new row
[2503] Fix | Delete
* for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted.
[2504] Fix | Delete
*
[2505] Fix | Delete
* Examples:
[2506] Fix | Delete
*
[2507] Fix | Delete
* $wpdb->replace(
[2508] Fix | Delete
* 'table',
[2509] Fix | Delete
* array(
[2510] Fix | Delete
* 'ID' => 123,
[2511] Fix | Delete
* 'column1' => 'foo',
[2512] Fix | Delete
* 'column2' => 'bar',
[2513] Fix | Delete
* )
[2514] Fix | Delete
* );
[2515] Fix | Delete
* $wpdb->replace(
[2516] Fix | Delete
* 'table',
[2517] Fix | Delete
* array(
[2518] Fix | Delete
* 'ID' => 456,
[2519] Fix | Delete
* 'column1' => 'foo',
[2520] Fix | Delete
* 'column2' => 1337,
[2521] Fix | Delete
* ),
[2522] Fix | Delete
* array(
[2523] Fix | Delete
* '%d',
[2524] Fix | Delete
* '%s',
[2525] Fix | Delete
* '%d',
[2526] Fix | Delete
* )
[2527] Fix | Delete
* );
[2528] Fix | Delete
*
[2529] Fix | Delete
* @since 3.0.0
[2530] Fix | Delete
*
[2531] Fix | Delete
* @see wpdb::prepare()
[2532] Fix | Delete
* @see wpdb::$field_types
[2533] Fix | Delete
* @see wp_set_wpdb_vars()
[2534] Fix | Delete
*
[2535] Fix | Delete
* @param string $table Table name.
[2536] Fix | Delete
* @param array $data Data to insert (in column => value pairs).
[2537] Fix | Delete
* Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
[2538] Fix | Delete
* A primary key or unique index is required to perform a replace operation.
[2539] Fix | Delete
* Sending a null value will cause the column to be set to NULL - the corresponding
[2540] Fix | Delete
* format is ignored in this case.
[2541] Fix | Delete
* @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
[2542] Fix | Delete
* If string, that format will be used for all of the values in `$data`.
[2543] Fix | Delete
* A format is one of '%d', '%f', '%s' (integer, float, string).
[2544] Fix | Delete
* If omitted, all values in `$data` will be treated as strings unless otherwise
[2545] Fix | Delete
* specified in wpdb::$field_types. Default null.
[2546] Fix | Delete
* @return int|false The number of rows affected, or false on error.
[2547] Fix | Delete
*/
[2548] Fix | Delete
public function replace( $table, $data, $format = null ) {
[2549] Fix | Delete
return $this->_insert_replace_helper( $table, $data, $format, 'REPLACE' );
[2550] Fix | Delete
}
[2551] Fix | Delete
[2552] Fix | Delete
/**
[2553] Fix | Delete
* Helper function for insert and replace.
[2554] Fix | Delete
*
[2555] Fix | Delete
* Runs an insert or replace query based on `$type` argument.
[2556] Fix | Delete
*
[2557] Fix | Delete
* @since 3.0.0
[2558] Fix | Delete
*
[2559] Fix | Delete
* @see wpdb::prepare()
[2560] Fix | Delete
* @see wpdb::$field_types
[2561] Fix | Delete
* @see wp_set_wpdb_vars()
[2562] Fix | Delete
*
[2563] Fix | Delete
* @param string $table Table name.
[2564] Fix | Delete
* @param array $data Data to insert (in column => value pairs).
[2565] Fix | Delete
* Both `$data` columns and `$data` values should be "raw" (neither should be SQL escaped).
[2566] Fix | Delete
* Sending a null value will cause the column to be set to NULL - the corresponding
[2567] Fix | Delete
* format is ignored in this case.
[2568] Fix | Delete
* @param string[]|string $format Optional. An array of formats to be mapped to each of the value in `$data`.
[2569] Fix | Delete
* If string, that format will be used for all of the values in `$data`.
[2570] Fix | Delete
* A format is one of '%d', '%f', '%s' (integer, float, string).
[2571] Fix | Delete
* If omitted, all values in `$data` will be treated as strings unless otherwise
[2572] Fix | Delete
* specified in wpdb::$field_types. Default null.
[2573] Fix | Delete
* @param string $type Optional. Type of operation. Either 'INSERT' or 'REPLACE'.
[2574] Fix | Delete
* Default 'INSERT'.
[2575] Fix | Delete
* @return int|false The number of rows affected, or false on error.
[2576] Fix | Delete
*/
[2577] Fix | Delete
public function _insert_replace_helper( $table, $data, $format = null, $type = 'INSERT' ) {
[2578] Fix | Delete
$this->insert_id = 0;
[2579] Fix | Delete
[2580] Fix | Delete
if ( ! in_array( strtoupper( $type ), array( 'REPLACE', 'INSERT' ), true ) ) {
[2581] Fix | Delete
return false;
[2582] Fix | Delete
}
[2583] Fix | Delete
[2584] Fix | Delete
$data = $this->process_fields( $table, $data, $format );
[2585] Fix | Delete
if ( false === $data ) {
[2586] Fix | Delete
return false;
[2587] Fix | Delete
}
[2588] Fix | Delete
[2589] Fix | Delete
$formats = array();
[2590] Fix | Delete
$values = array();
[2591] Fix | Delete
foreach ( $data as $value ) {
[2592] Fix | Delete
if ( is_null( $value['value'] ) ) {
[2593] Fix | Delete
$formats[] = 'NULL';
[2594] Fix | Delete
continue;
[2595] Fix | Delete
}
[2596] Fix | Delete
[2597] Fix | Delete
$formats[] = $value['format'];
[2598] Fix | Delete
$values[] = $value['value'];
[2599] Fix | Delete
}
[2600] Fix | Delete
[2601] Fix | Delete
$fields = '`' . implode( '`, `', array_keys( $data ) ) . '`';
[2602] Fix | Delete
$formats = implode( ', ', $formats );
[2603] Fix | Delete
[2604] Fix | Delete
$sql = "$type INTO `$table` ($fields) VALUES ($formats)";
[2605] Fix | Delete
[2606] Fix | Delete
$this->check_current_query = false;
[2607] Fix | Delete
return $this->query( $this->prepare( $sql, $values ) );
[2608] Fix | Delete
}
[2609] Fix | Delete
[2610] Fix | Delete
/**
[2611] Fix | Delete
* Updates a row in the table.
[2612] Fix | Delete
*
[2613] Fix | Delete
* Examples:
[2614] Fix | Delete
*
[2615] Fix | Delete
* $wpdb->update(
[2616] Fix | Delete
* 'table',
[2617] Fix | Delete
* array(
[2618] Fix | Delete
* 'column1' => 'foo',
[2619] Fix | Delete
* 'column2' => 'bar',
[2620] Fix | Delete
* ),
[2621] Fix | Delete
* array(
[2622] Fix | Delete
* 'ID' => 1,
[2623] Fix | Delete
* )
[2624] Fix | Delete
* );
[2625] Fix | Delete
* $wpdb->update(
[2626] Fix | Delete
* 'table',
[2627] Fix | Delete
* array(
[2628] Fix | Delete
* 'column1' => 'foo',
[2629] Fix | Delete
* 'column2' => 1337,
[2630] Fix | Delete
* ),
[2631] Fix | Delete
* array(
[2632] Fix | Delete
* 'ID' => 1,
[2633] Fix | Delete
* ),
[2634] Fix | Delete
* array(
[2635] Fix | Delete
* '%s',
[2636] Fix | Delete
* '%d',
[2637] Fix | Delete
* ),
[2638] Fix | Delete
* array(
[2639] Fix | Delete
* '%d',
[2640] Fix | Delete
* )
[2641] Fix | Delete
* );
[2642] Fix | Delete
*
[2643] Fix | Delete
* @since 2.5.0
[2644] Fix | Delete
*
[2645] Fix | Delete
* @see wpdb::prepare()
[2646] Fix | Delete
* @see wpdb::$field_types
[2647] Fix | Delete
* @see wp_set_wpdb_vars()
[2648] Fix | Delete
*
[2649] Fix | Delete
* @param string $table Table name.
[2650] Fix | Delete
* @param array $data Data to update (in column => value pairs).
[2651] Fix | Delete
* Both $data columns and $data values should be "raw" (neither should be SQL escaped).
[2652] Fix | Delete
* Sending a null value will cause the column to be set to NULL - the corresponding
[2653] Fix | Delete
* format is ignored in this case.
[2654] Fix | Delete
* @param array $where A named array of WHERE clauses (in column => value pairs).
[2655] Fix | Delete
* Multiple clauses will be joined with ANDs.
[2656] Fix | Delete
* Both $where columns and $where values should be "raw".
[2657] Fix | Delete
* Sending a null value will create an IS NULL comparison - the corresponding
[2658] Fix | Delete
* format will be ignored in this case.
[2659] Fix | Delete
* @param string[]|string $format Optional. An array of formats to be mapped to each of the values in $data.
[2660] Fix | Delete
* If string, that format will be used for all of the values in $data.
[2661] Fix | Delete
* A format is one of '%d', '%f', '%s' (integer, float, string).
[2662] Fix | Delete
* If omitted, all values in $data will be treated as strings unless otherwise
[2663] Fix | Delete
* specified in wpdb::$field_types. Default null.
[2664] Fix | Delete
* @param string[]|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
[2665] Fix | Delete
* If string, that format will be used for all of the items in $where.
[2666] Fix | Delete
* A format is one of '%d', '%f', '%s' (integer, float, string).
[2667] Fix | Delete
* If omitted, all values in $where will be treated as strings unless otherwise
[2668] Fix | Delete
* specified in wpdb::$field_types. Default null.
[2669] Fix | Delete
* @return int|false The number of rows updated, or false on error.
[2670] Fix | Delete
*/
[2671] Fix | Delete
public function update( $table, $data, $where, $format = null, $where_format = null ) {
[2672] Fix | Delete
if ( ! is_array( $data ) || ! is_array( $where ) ) {
[2673] Fix | Delete
return false;
[2674] Fix | Delete
}
[2675] Fix | Delete
[2676] Fix | Delete
$data = $this->process_fields( $table, $data, $format );
[2677] Fix | Delete
if ( false === $data ) {
[2678] Fix | Delete
return false;
[2679] Fix | Delete
}
[2680] Fix | Delete
$where = $this->process_fields( $table, $where, $where_format );
[2681] Fix | Delete
if ( false === $where ) {
[2682] Fix | Delete
return false;
[2683] Fix | Delete
}
[2684] Fix | Delete
[2685] Fix | Delete
$fields = array();
[2686] Fix | Delete
$conditions = array();
[2687] Fix | Delete
$values = array();
[2688] Fix | Delete
foreach ( $data as $field => $value ) {
[2689] Fix | Delete
if ( is_null( $value['value'] ) ) {
[2690] Fix | Delete
$fields[] = "`$field` = NULL";
[2691] Fix | Delete
continue;
[2692] Fix | Delete
}
[2693] Fix | Delete
[2694] Fix | Delete
$fields[] = "`$field` = " . $value['format'];
[2695] Fix | Delete
$values[] = $value['value'];
[2696] Fix | Delete
}
[2697] Fix | Delete
foreach ( $where as $field => $value ) {
[2698] Fix | Delete
if ( is_null( $value['value'] ) ) {
[2699] Fix | Delete
$conditions[] = "`$field` IS NULL";
[2700] Fix | Delete
continue;
[2701] Fix | Delete
}
[2702] Fix | Delete
[2703] Fix | Delete
$conditions[] = "`$field` = " . $value['format'];
[2704] Fix | Delete
$values[] = $value['value'];
[2705] Fix | Delete
}
[2706] Fix | Delete
[2707] Fix | Delete
$fields = implode( ', ', $fields );
[2708] Fix | Delete
$conditions = implode( ' AND ', $conditions );
[2709] Fix | Delete
[2710] Fix | Delete
$sql = "UPDATE `$table` SET $fields WHERE $conditions";
[2711] Fix | Delete
[2712] Fix | Delete
$this->check_current_query = false;
[2713] Fix | Delete
return $this->query( $this->prepare( $sql, $values ) );
[2714] Fix | Delete
}
[2715] Fix | Delete
[2716] Fix | Delete
/**
[2717] Fix | Delete
* Deletes a row in the table.
[2718] Fix | Delete
*
[2719] Fix | Delete
* Examples:
[2720] Fix | Delete
*
[2721] Fix | Delete
* $wpdb->delete(
[2722] Fix | Delete
* 'table',
[2723] Fix | Delete
* array(
[2724] Fix | Delete
* 'ID' => 1,
[2725] Fix | Delete
* )
[2726] Fix | Delete
* );
[2727] Fix | Delete
* $wpdb->delete(
[2728] Fix | Delete
* 'table',
[2729] Fix | Delete
* array(
[2730] Fix | Delete
* 'ID' => 1,
[2731] Fix | Delete
* ),
[2732] Fix | Delete
* array(
[2733] Fix | Delete
* '%d',
[2734] Fix | Delete
* )
[2735] Fix | Delete
* );
[2736] Fix | Delete
*
[2737] Fix | Delete
* @since 3.4.0
[2738] Fix | Delete
*
[2739] Fix | Delete
* @see wpdb::prepare()
[2740] Fix | Delete
* @see wpdb::$field_types
[2741] Fix | Delete
* @see wp_set_wpdb_vars()
[2742] Fix | Delete
*
[2743] Fix | Delete
* @param string $table Table name.
[2744] Fix | Delete
* @param array $where A named array of WHERE clauses (in column => value pairs).
[2745] Fix | Delete
* Multiple clauses will be joined with ANDs.
[2746] Fix | Delete
* Both $where columns and $where values should be "raw".
[2747] Fix | Delete
* Sending a null value will create an IS NULL comparison - the corresponding
[2748] Fix | Delete
* format will be ignored in this case.
[2749] Fix | Delete
* @param string[]|string $where_format Optional. An array of formats to be mapped to each of the values in $where.
[2750] Fix | Delete
* If string, that format will be used for all of the items in $where.
[2751] Fix | Delete
* A format is one of '%d', '%f', '%s' (integer, float, string).
[2752] Fix | Delete
* If omitted, all values in $data will be treated as strings unless otherwise
[2753] Fix | Delete
* specified in wpdb::$field_types. Default null.
[2754] Fix | Delete
* @return int|false The number of rows deleted, or false on error.
[2755] Fix | Delete
*/
[2756] Fix | Delete
public function delete( $table, $where, $where_format = null ) {
[2757] Fix | Delete
if ( ! is_array( $where ) ) {
[2758] Fix | Delete
return false;
[2759] Fix | Delete
}
[2760] Fix | Delete
[2761] Fix | Delete
$where = $this->process_fields( $table, $where, $where_format );
[2762] Fix | Delete
if ( false === $where ) {
[2763] Fix | Delete
return false;
[2764] Fix | Delete
}
[2765] Fix | Delete
[2766] Fix | Delete
$conditions = array();
[2767] Fix | Delete
$values = array();
[2768] Fix | Delete
foreach ( $where as $field => $value ) {
[2769] Fix | Delete
if ( is_null( $value['value'] ) ) {
[2770] Fix | Delete
$conditions[] = "`$field` IS NULL";
[2771] Fix | Delete
continue;
[2772] Fix | Delete
}
[2773] Fix | Delete
[2774] Fix | Delete
$conditions[] = "`$field` = " . $value['format'];
[2775] Fix | Delete
$values[] = $value['value'];
[2776] Fix | Delete
}
[2777] Fix | Delete
[2778] Fix | Delete
$conditions = implode( ' AND ', $conditions );
[2779] Fix | Delete
[2780] Fix | Delete
$sql = "DELETE FROM `$table` WHERE $conditions";
[2781] Fix | Delete
[2782] Fix | Delete
$this->check_current_query = false;
[2783] Fix | Delete
return $this->query( $this->prepare( $sql, $values ) );
[2784] Fix | Delete
}
[2785] Fix | Delete
[2786] Fix | Delete
/**
[2787] Fix | Delete
* Processes arrays of field/value pairs and field formats.
[2788] Fix | Delete
*
[2789] Fix | Delete
* This is a helper method for wpdb's CRUD methods, which take field/value pairs
[2790] Fix | Delete
* for inserts, updates, and where clauses. This method first pairs each value
[2791] Fix | Delete
* with a format. Then it determines the charset of that field, using that
[2792] Fix | Delete
* to determine if any invalid text would be stripped. If text is stripped,
[2793] Fix | Delete
* then field processing is rejected and the query fails.
[2794] Fix | Delete
*
[2795] Fix | Delete
* @since 4.2.0
[2796] Fix | Delete
*
[2797] Fix | Delete
* @param string $table Table name.
[2798] Fix | Delete
* @param array $data Array of values keyed by their field names.
[2799] Fix | Delete
* @param string[]|string $format Formats or format to be mapped to the values in the data.
[2800] Fix | Delete
* @return array|false An array of fields that contain paired value and formats.
[2801] Fix | Delete
* False for invalid values.
[2802] Fix | Delete
*/
[2803] Fix | Delete
protected function process_fields( $table, $data, $format ) {
[2804] Fix | Delete
$data = $this->process_field_formats( $data, $format );
[2805] Fix | Delete
if ( false === $data ) {
[2806] Fix | Delete
return false;
[2807] Fix | Delete
}
[2808] Fix | Delete
[2809] Fix | Delete
$data = $this->process_field_charsets( $data, $table );
[2810] Fix | Delete
if ( false === $data ) {
[2811] Fix | Delete
return false;
[2812] Fix | Delete
}
[2813] Fix | Delete
[2814] Fix | Delete
$data = $this->process_field_lengths( $data, $table );
[2815] Fix | Delete
if ( false === $data ) {
[2816] Fix | Delete
return false;
[2817] Fix | Delete
}
[2818] Fix | Delete
[2819] Fix | Delete
$converted_data = $this->strip_invalid_text( $data );
[2820] Fix | Delete
[2821] Fix | Delete
if ( $data !== $converted_data ) {
[2822] Fix | Delete
[2823] Fix | Delete
$problem_fields = array();
[2824] Fix | Delete
foreach ( $data as $field => $value ) {
[2825] Fix | Delete
if ( $value !== $converted_data[ $field ] ) {
[2826] Fix | Delete
$problem_fields[] = $field;
[2827] Fix | Delete
}
[2828] Fix | Delete
}
[2829] Fix | Delete
[2830] Fix | Delete
wp_load_translations_early();
[2831] Fix | Delete
[2832] Fix | Delete
if ( 1 === count( $problem_fields ) ) {
[2833] Fix | Delete
$this->last_error = sprintf(
[2834] Fix | Delete
/* translators: %s: Database field where the error occurred. */
[2835] Fix | Delete
__( 'WordPress database error: Processing the value for the following field failed: %s. The supplied value may be too long or contains invalid data.' ),
[2836] Fix | Delete
reset( $problem_fields )
[2837] Fix | Delete
);
[2838] Fix | Delete
} else {
[2839] Fix | Delete
$this->last_error = sprintf(
[2840] Fix | Delete
/* translators: %s: Database fields where the error occurred. */
[2841] Fix | Delete
__( 'WordPress database error: Processing the values for the following fields failed: %s. The supplied values may be too long or contain invalid data.' ),
[2842] Fix | Delete
implode( ', ', $problem_fields )
[2843] Fix | Delete
);
[2844] Fix | Delete
}
[2845] Fix | Delete
[2846] Fix | Delete
return false;
[2847] Fix | Delete
}
[2848] Fix | Delete
[2849] Fix | Delete
return $data;
[2850] Fix | Delete
}
[2851] Fix | Delete
[2852] Fix | Delete
/**
[2853] Fix | Delete
* Prepares arrays of value/format pairs as passed to wpdb CRUD methods.
[2854] Fix | Delete
*
[2855] Fix | Delete
* @since 4.2.0
[2856] Fix | Delete
*
[2857] Fix | Delete
* @param array $data Array of values keyed by their field names.
[2858] Fix | Delete
* @param string[]|string $format Formats or format to be mapped to the values in the data.
[2859] Fix | Delete
* @return array {
[2860] Fix | Delete
* Array of values and formats keyed by their field names.
[2861] Fix | Delete
*
[2862] Fix | Delete
* @type mixed $value The value to be formatted.
[2863] Fix | Delete
* @type string $format The format to be mapped to the value.
[2864] Fix | Delete
* }
[2865] Fix | Delete
*/
[2866] Fix | Delete
protected function process_field_formats( $data, $format ) {
[2867] Fix | Delete
$formats = (array) $format;
[2868] Fix | Delete
$original_formats = $formats;
[2869] Fix | Delete
[2870] Fix | Delete
foreach ( $data as $field => $value ) {
[2871] Fix | Delete
$value = array(
[2872] Fix | Delete
'value' => $value,
[2873] Fix | Delete
'format' => '%s',
[2874] Fix | Delete
);
[2875] Fix | Delete
[2876] Fix | Delete
if ( ! empty( $format ) ) {
[2877] Fix | Delete
$value['format'] = array_shift( $formats );
[2878] Fix | Delete
if ( ! $value['format'] ) {
[2879] Fix | Delete
$value['format'] = reset( $original_formats );
[2880] Fix | Delete
}
[2881] Fix | Delete
} elseif ( isset( $this->field_types[ $field ] ) ) {
[2882] Fix | Delete
$value['format'] = $this->field_types[ $field ];
[2883] Fix | Delete
}
[2884] Fix | Delete
[2885] Fix | Delete
$data[ $field ] = $value;
[2886] Fix | Delete
}
[2887] Fix | Delete
[2888] Fix | Delete
return $data;
[2889] Fix | Delete
}
[2890] Fix | Delete
[2891] Fix | Delete
/**
[2892] Fix | Delete
* Adds field charsets to field/value/format arrays generated by wpdb::process_field_formats().
[2893] Fix | Delete
*
[2894] Fix | Delete
* @since 4.2.0
[2895] Fix | Delete
*
[2896] Fix | Delete
* @param array $data {
[2897] Fix | Delete
* Array of values and formats keyed by their field names,
[2898] Fix | Delete
* as it comes from the wpdb::process_field_formats() method.
[2899] Fix | Delete
*
[2900] Fix | Delete
* @type array ...$0 {
[2901] Fix | Delete
* Value and format for this field.
[2902] Fix | Delete
*
[2903] Fix | Delete
* @type mixed $value The value to be formatted.
[2904] Fix | Delete
* @type string $format The format to be mapped to the value.
[2905] Fix | Delete
* }
[2906] Fix | Delete
* }
[2907] Fix | Delete
* @param string $table Table name.
[2908] Fix | Delete
* @return array|false {
[2909] Fix | Delete
* The same array of data with additional 'charset' keys, or false if
[2910] Fix | Delete
* the charset for the table cannot be found.
[2911] Fix | Delete
*
[2912] Fix | Delete
* @type array ...$0 {
[2913] Fix | Delete
* Value, format, and charset for this field.
[2914] Fix | Delete
*
[2915] Fix | Delete
* @type mixed $value The value to be formatted.
[2916] Fix | Delete
* @type string $format The format to be mapped to the value.
[2917] Fix | Delete
* @type string|false $charset The charset to be used for the value.
[2918] Fix | Delete
* }
[2919] Fix | Delete
* }
[2920] Fix | Delete
*/
[2921] Fix | Delete
protected function process_field_charsets( $data, $table ) {
[2922] Fix | Delete
foreach ( $data as $field => $value ) {
[2923] Fix | Delete
if ( '%d' === $value['format'] || '%f' === $value['format'] ) {
[2924] Fix | Delete
/*
[2925] Fix | Delete
* We can skip this field if we know it isn't a string.
[2926] Fix | Delete
* This checks %d/%f versus ! %s because its sprintf() could take more.
[2927] Fix | Delete
*/
[2928] Fix | Delete
$value['charset'] = false;
[2929] Fix | Delete
} else {
[2930] Fix | Delete
$value['charset'] = $this->get_col_charset( $table, $field );
[2931] Fix | Delete
if ( is_wp_error( $value['charset'] ) ) {
[2932] Fix | Delete
return false;
[2933] Fix | Delete
}
[2934] Fix | Delete
}
[2935] Fix | Delete
[2936] Fix | Delete
$data[ $field ] = $value;
[2937] Fix | Delete
}
[2938] Fix | Delete
[2939] Fix | Delete
return $data;
[2940] Fix | Delete
}
[2941] Fix | Delete
[2942] Fix | Delete
/**
[2943] Fix | Delete
* For string fields, records the maximum string length that field can safely save.
[2944] Fix | Delete
*
[2945] Fix | Delete
* @since 4.2.1
[2946] Fix | Delete
*
[2947] Fix | Delete
* @param array $data {
[2948] Fix | Delete
* Array of values, formats, and charsets keyed by their field names,
[2949] Fix | Delete
* as it comes from the wpdb::process_field_charsets() method.
[2950] Fix | Delete
*
[2951] Fix | Delete
* @type array ...$0 {
[2952] Fix | Delete
* Value, format, and charset for this field.
[2953] Fix | Delete
*
[2954] Fix | Delete
* @type mixed $value The value to be formatted.
[2955] Fix | Delete
* @type string $format The format to be mapped to the value.
[2956] Fix | Delete
* @type string|false $charset The charset to be used for the value.
[2957] Fix | Delete
* }
[2958] Fix | Delete
* }
[2959] Fix | Delete
* @param string $table Table name.
[2960] Fix | Delete
* @return array|false {
[2961] Fix | Delete
* The same array of data with additional 'length' keys, or false if
[2962] Fix | Delete
* information for the table cannot be found.
[2963] Fix | Delete
*
[2964] Fix | Delete
* @type array ...$0 {
[2965] Fix | Delete
* Value, format, charset, and length for this field.
[2966] Fix | Delete
*
[2967] Fix | Delete
* @type mixed $value The value to be formatted.
[2968] Fix | Delete
* @type string $format The format to be mapped to the value.
[2969] Fix | Delete
* @type string|false $charset The charset to be used for the value.
[2970] Fix | Delete
* @type array|false $length {
[2971] Fix | Delete
* Information about the maximum length of the value.
[2972] Fix | Delete
* False if the column has no length.
[2973] Fix | Delete
*
[2974] Fix | Delete
* @type string $type One of 'byte' or 'char'.
[2975] Fix | Delete
* @type int $length The column length.
[2976] Fix | Delete
* }
[2977] Fix | Delete
* }
[2978] Fix | Delete
* }
[2979] Fix | Delete
*/
[2980] Fix | Delete
protected function process_field_lengths( $data, $table ) {
[2981] Fix | Delete
foreach ( $data as $field => $value ) {
[2982] Fix | Delete
if ( '%d' === $value['format'] || '%f' === $value['format'] ) {
[2983] Fix | Delete
/*
[2984] Fix | Delete
* We can skip this field if we know it isn't a string.
[2985] Fix | Delete
* This checks %d/%f versus ! %s because its sprintf() could take more.
[2986] Fix | Delete
*/
[2987] Fix | Delete
$value['length'] = false;
[2988] Fix | Delete
} else {
[2989] Fix | Delete
$value['length'] = $this->get_col_length( $table, $field );
[2990] Fix | Delete
if ( is_wp_error( $value['length'] ) ) {
[2991] Fix | Delete
return false;
[2992] Fix | Delete
}
[2993] Fix | Delete
}
[2994] Fix | Delete
[2995] Fix | Delete
$data[ $field ] = $value;
[2996] Fix | Delete
}
[2997] Fix | Delete
[2998] Fix | Delete
return $data;
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function