@@ 2187-2206 (lines=20) @@ | ||
2184 | * @param string $table Table name. |
|
2185 | * @return array|false The same array as $data with additional 'charset' keys. |
|
2186 | */ |
|
2187 | protected function process_field_charsets( $data, $table ) { |
|
2188 | foreach ( $data as $field => $value ) { |
|
2189 | if ( '%d' === $value['format'] || '%f' === $value['format'] ) { |
|
2190 | /* |
|
2191 | * We can skip this field if we know it isn't a string. |
|
2192 | * This checks %d/%f versus ! %s because its sprintf() could take more. |
|
2193 | */ |
|
2194 | $value['charset'] = false; |
|
2195 | } else { |
|
2196 | $value['charset'] = $this->get_col_charset( $table, $field ); |
|
2197 | if ( is_wp_error( $value['charset'] ) ) { |
|
2198 | return false; |
|
2199 | } |
|
2200 | } |
|
2201 | ||
2202 | $data[ $field ] = $value; |
|
2203 | } |
|
2204 | ||
2205 | return $data; |
|
2206 | } |
|
2207 | ||
2208 | /** |
|
2209 | * For string fields, record the maximum string length that field can safely save. |
|
@@ 2219-2238 (lines=20) @@ | ||
2216 | * @return array|false The same array as $data with additional 'length' keys, or false if |
|
2217 | * any of the values were too long for their corresponding field. |
|
2218 | */ |
|
2219 | protected function process_field_lengths( $data, $table ) { |
|
2220 | foreach ( $data as $field => $value ) { |
|
2221 | if ( '%d' === $value['format'] || '%f' === $value['format'] ) { |
|
2222 | /* |
|
2223 | * We can skip this field if we know it isn't a string. |
|
2224 | * This checks %d/%f versus ! %s because its sprintf() could take more. |
|
2225 | */ |
|
2226 | $value['length'] = false; |
|
2227 | } else { |
|
2228 | $value['length'] = $this->get_col_length( $table, $field ); |
|
2229 | if ( is_wp_error( $value['length'] ) ) { |
|
2230 | return false; |
|
2231 | } |
|
2232 | } |
|
2233 | ||
2234 | $data[ $field ] = $value; |
|
2235 | } |
|
2236 | ||
2237 | return $data; |
|
2238 | } |
|
2239 | ||
2240 | /** |
|
2241 | * Retrieve one variable from the database. |