The wordpress function "get_default_post_to_edit" inside the "post.php" file located at "wp-admin/includes/" is not working correctly.
When I am loading the page: wp-admin/post-new.php?post_type=product :I get an HTTP 500 error, but it does store a record inside my database, but $post_id echo's '0' (which is not 0 in the new record).
When I comment out the line below, in this function I mention above, I get no HTTP 500 error, but my page is not working correctly:
$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) );
When I add the following code after the $post_id = wp_insert_post(.... it echo's 'NULL':
exit(var_dump( $wpdb->last_query));
When I try to save the product page, it tells me I don't have the permission to do that.
Also when I try to edit an earlier posted product I can retrieve all information, but when I try to save the changes it throws me an HTTP 500 error again in the script "post.php" from this code:
$success = wp_update_post( $post_data );
How I can debug or troubleshoot wordpress in those kind of situations?
I just noticed that I can't add, edit or delete anything using WordPress without getting an HTTP 500 Error, but it does add/edit/delete the content to the database.
All of this happend after I've updated WooCommerce and some other plugins and updated the data structure, I have compared my new scripts to my old scripts but I don't see any difference.
It turns out it was the update of WooCommerce 3.0.3 which broke the full site down.. Have downgraded again and am now reading how to migrate properly.. Apparently this was a Major upgrade at which they have moved to a new "CRUD" -method, basicly adding another layer between website and database..
Scroll down on this site below untill you see the part about: Upgrading to 3.0 https://woocommerce.wordpress.com/2017/04/04/say-hello-to-woocommerce-3-0-bionic-butterfly/
EDIT: most of the problems are fixed by reading migration notes of woocommerce, but the backend working with post.php e.g. was because of a third party plugin that wasnt compatible with woocommerce 3.0.