| @@ -3,14 +3,8 @@ | ||
| 3 | 3 | die( 'You are not allowed to call this page directly.' ); |
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmEntryValidate { |
| 7 | - | |
| 8 | - /** | |
| 9 | - * @param array $values | |
| 10 | - * @param string[]|bool $exclude | |
| 11 | - * @return array | |
| 12 | - */ | |
| 13 | 7 | public static function validate( $values, $exclude = false ) { |
| 14 | 8 | FrmEntry::sanitize_entry_post( $values ); |
| 15 | 9 | $errors = array(); |
| 16 | 10 | |
| @@ -49,16 +43,10 @@ | ||
| 49 | 43 | * @param array $errors Errors data. |
| 50 | 44 | * @param array $values Value data of the form. |
| 51 | 45 | * @param array $args Custom arguments. Contains `exclude` and `posted_fields`. |
| 52 | 46 | */ |
| 53 | - $filtered_errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude', 'posted_fields' ) ); | |
| 47 | + $errors = apply_filters( 'frm_validate_entry', $errors, $values, compact( 'exclude', 'posted_fields' ) ); | |
| 54 | 48 | |
| 55 | - if ( is_array( $filtered_errors ) ) { | |
| 56 | - $errors = $filtered_errors; | |
| 57 | - } else { | |
| 58 | - _doing_it_wrong( __FUNCTION__, 'Only arrays should be returned when using the frm_validate_entry filter.', '6.3' ); | |
| 59 | - } | |
| 60 | - | |
| 61 | 49 | return $errors; |
| 62 | 50 | } |
| 63 | 51 | |
| 64 | 52 | private static function set_item_key( &$values ) { |
| @@ -161,10 +149,9 @@ | ||
| 161 | 149 | $item_name = $value; |
| 162 | 150 | } |
| 163 | 151 | |
| 164 | 152 | if ( false !== $item_name ) { |
| 165 | - // Item name has a max length of 255 characters so truncate it so it doesn't fail to save in the database. | |
| 166 | - $_POST['item_name'] = substr( $item_name, 0, 255 ); | |
| 153 | + $_POST['item_name'] = $item_name; | |
| 167 | 154 | } |
| 168 | 155 | } |
| 169 | 156 | |
| 170 | 157 | /** |
| @@ -316,10 +303,9 @@ | ||
| 316 | 303 | } |
| 317 | 304 | |
| 318 | 305 | /** |
| 319 | 306 | * @param int $form_id |
| 320 | - * | |
| 321 | - * @return bool|string | |
| 307 | + * @return boolean | |
| 322 | 308 | */ |
| 323 | 309 | private static function is_antispam_check( $form_id ) { |
| 324 | 310 | $aspm = new FrmAntiSpam( $form_id ); |
| 325 | 311 | return $aspm->validate(); |
| @@ -373,8 +359,11 @@ | ||
| 373 | 359 | return false; |
| 374 | 360 | } |
| 375 | 361 | |
| 376 | 362 | $content = FrmEntriesHelper::entry_array_to_string( $values ); |
| 363 | + if ( empty( $content ) ) { | |
| 364 | + return false; | |
| 365 | + } | |
| 377 | 366 | |
| 378 | 367 | self::prepare_values_for_spam_check( $values ); |
| 379 | 368 | $ip = FrmAppHelper::get_ip_address(); |
| 380 | 369 | $user_agent = FrmAppHelper::get_server_value( 'HTTP_USER_AGENT' ); |