WPDB Error Messages
-
Can we please get some helpful error messages when wpdb just returns false, typiclly the process_fields function.
i.e.
/** * Processes arrays of field/value pairs and field formats. * * This is a helper method for wpdb's CRUD methods, which take field/value pairs * for inserts, updates, and where clauses. This method first pairs each value * with a format. Then it determines the charset of that field, using that * to determine if any invalid text would be stripped. If text is stripped, * then field processing is rejected and the query fails. * * @since 4.2.0 * * @param string $table Table name. * @param array $data Field/value pair. * @param mixed $format Format for each field. * @return array|false An array of fields that contain paired value and formats. * False for invalid values. */ protected function process_fields( $table, $data, $format ) { $data = $this->process_field_formats( $data, $format ); if ( false === $data ) { $this->last_error = 'invalid formats'; return false; } $data = $this->process_field_charsets( $data, $table ); if ( false === $data ) { $this->last_error = 'invalid charsets'; return false; } $data = $this->process_field_lengths( $data, $table ); if ( false === $data ) { $this->last_error = 'invalid lengths'; return false; } $converted_data = $this->strip_invalid_text( $data ); if ( $data !== $converted_data ) { $this->last_error = 'invalid data, affected fields: '; foreach($data as $key => &$value) { if($value != ($converted_data[$key] ?? false)) { $this->last_error .= $key; } } return false; } return $data; }
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘WPDB Error Messages’ is closed to new replies.