Closed andrewryantech closed 4 years ago
public function get_columns( $table ) {
$primary_key = array();
$columns = array( );
// Get a list of columns in this table
$fields = $this->db_query( "DESCRIBE {$table}" );
if ( ! $fields ) {
$this->add_error( $this->db_error( ), 'db' );
} else {
while( $column = $this->db_fetch( $fields ) ) {
if ( false !== stristr( $column['Type'], 'binary' )){
$this->add_error( 'Skip field ' . $table . ' - ' . $column[ 'Field' ] . ', fieldtype is ' . $column['Type'] , 'results' );
continue;
}
$columns[] = $column[ 'Field' ];
if ( $column[ 'Key' ] == 'PRI' )
$primary_key[] = $column[ 'Field' ];
}
}
return array( $primary_key, $columns );
}
Great, does this mean the problem's fixed? :)
This appears to occur when the database field contains binary data. Some wordpress plugins do this, eg Wordfence
It appears there are no unit test to cover this case. I considered adding them, but looks like there's a bit of work to get them modernised. Would rather not sink time into that unless the maintainers are on board.
Considered using
mb_detect_encoding
, but it appears there are cases wheremb_detect_encoding
can detect a valid encoding for whichmb_split
still returnsfalse
.Not sure if there are cases where we do really want to modify binary data, but seems like a pretty risky edge case imo.