Open snarfed opened 1 month ago
Categories seem to be added/mapped here: https://github.com/indieweb/wordpress-micropub/blob/4a2ffa06fb82f93d1096be160fdfe56bf1786734/includes/class-micropub-endpoint.php#L756
This function is itself called here: https://github.com/indieweb/wordpress-micropub/blob/4a2ffa06fb82f93d1096be160fdfe56bf1786734/includes/class-micropub-endpoint.php#L441
And then this here line is where the resulting $args
array is passed on to WordPress' wp_insert_post()
.
In other words, after all the inputs (including categories) are converted to a single, fairly standard WordPress post argument array, it's just core WP doing its thing.
If I'm not mistaking, core will execute multiple SQL calls; not sure this plugin can do much to work around that.
Thanks for looking at this @janboddez! That makes sense...and it's also disappointing and worrying, since it would seem to mean this will be harder to fix or do anything about, if even possible at all. 😕
@janboddez That's what I saw also, but wanted to do some research to see if anything popped out
This keeps happening to me. I dug in a bit just now and figured out more of what's going on. It looks like the micropub and mf2 wp_postmeta
rows aren't getting written. For a successful reply, wp_postmeta
has rows for the post with meta_key
s micropub_auth_response
, micropub_version
, mf2_type
, mf2_category
, mf2_in-reply-to
, and mf2_syndication
. When this happens, none of those wp_postmeta
rows are there.
Could you put the wp_postmeta
writes inside the same transaction as the post write? Or something similar to have the same effect?
I don't see any reason it shouldn't work. From the looks of it, it is as expected. But I can try cleaning up some of the code to see if it becomes more evident. I know I've seen a category issue reported in WordPress when you try to do it in the initial post creation...but that shouldn't affect meta
This generally happens when my hosting provider is extremely slow, which happens occasionally, eg rendering a wp-admin page takes 30-60s. When I've tried to dig in, the conclusion has been that MySQL itself is unhappy, queries and writes take an unusually long time, and sometimes fail or time out altogether.
May seek some guidance from the community
Hi guys! I've noticed a bug (I think) that's bit me a few times over the last few months: occasionally posts will get created, and published, but the category in the micropub request doesn't get set.
I use category to hide replies, likes, reposts, etc from my home page, so the result is that those occasionally show up on the home page, which is a bit confusing and embarrassing :grin:
I think this tends to happen when either my site or the db or both are unusually slow. I'm guessing the post is getting created, and then something hits a request or db timeout somewhere, and the rest of the processing gets cut off and the category doesn't get applied. Sounds like ideally the category should get written in the same database transaction as the post?