Don't choke if there an object with an empty APID already in the db

This commit is contained in:
Jeremy Dormitzer 2018-11-09 08:14:01 -05:00
parent a364322c77
commit 0881890b41
2 changed files with 3 additions and 2 deletions

View File

@ -74,7 +74,7 @@ function post_to_object( $post ) {
);
$existing = \pterotype\objects\get_object_by_url( $permalink );
if ( $existing ) {
$object['id'] = $existing->activitypub_id;
$object['id'] = $existing['id'];
}
return $object;
}

View File

@ -18,7 +18,8 @@ function create_local_object( $object ) {
}
$object = compact_object( $object );
$res = $wpdb->insert( $wpdb->prefix . 'pterotype_objects', array(
'object' => wp_json_encode( $object )
'object' => wp_json_encode( $object ),
'activitypub_id' => "uninitialized_" . rand(),
) );
if ( !$res ) {
return new \WP_Error(