We have a situation where we write data to a metabox custom table but we dont specify a primary key, we allow the increment to autogenerate an id. This means that our object_id is null. Whenever we call \MetaBox\CustomTable\API::add( null...)
The following tries to occur:
public static function add( ?int $object_id, string $table, array $row ) {
global $wpdb;
$row['ID'] = $object_id;
$row = array_map( function ($item) {
return self::maybe_serialize( $item );
}, $row );
$row = apply_filters( 'mbct_add_data', $row, $object_id, $table );
do_action( 'mbct_before_add', $object_id, $table, $row );
$output = $wpdb->insert( $table, $row );
do_action( 'mbct_after_add', $object_id, $table, $row );
Cache::delete( $object_id, $table );
return $output;
}
Maybe Cache::delete should run if $object_id is not null?