#44914 closed defect (bug) (fixed)
Bulk Edit posts changes Post format back to Standard
Reported by: | lanche86 | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 5.1 | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Post Formats | Keywords: | has-screenshots has-patch has-unit-tests dev-feedback |
Focuses: | administration | Cc: |
Description
Hello, all!
Here is the weird bug :) While doing a Bulk edit of posts and even if Post Format is set to "No change" it updates all the posts and it sets them back to Standard format losing all the previous Post Formats.
Steps to reproduce:
1) Select posts you want to edit in bulk, keeping the Post Format to No change - http://prntscr.com/krp0w7
2) Hit Submit
3) All your post formats of the selected posts are Standard now - http://prntscr.com/krp3ml
Attachments (3)
Change History (22)
#2
@
6 years ago
- Focuses administration added
- Keywords reporter-feedback added
@lanche86 Have you checked above issue with default WP and twentyseventeen theme? Also disable all other plugin as Bulk edit is not core functionality of WordPress.
#3
@
6 years ago
- Keywords reporter-feedback removed
Hey, @mukesh27!
Yes, default WordPress installation with twentyseventeen theme activated and no plugins installed/activated.
I am talking about editing posts in bulk, please see the screenshot - http://prntscr.com/krspol - this is core functionality of WordPress. Let me know if you have any questions
#5
@
6 years ago
It looks like the problem could originate from bulk_edit_posts()
(src):
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'names' ) );
where it fetches the post format names, like "Image" or "Video".
Then these names are added into the tax_input
for wp_update_post()
.
But wp_set_post_terms()
doesn't knows how to add post formats without the correct slug prefix.
One suggestion could be to consider using:
$current_terms = (array) wp_get_object_terms( $post_ID, $tax_name, array( 'fields' => 'slugs' ) );
for post formats, to fetch slugs with the correct post format prefix, like post-format-image
and post-format-video
.
#6
@
6 years ago
- Keywords has-patch needs-testing added; needs-patch removed
Hi @lanche86, welcome to WordPress Trac! Thanks for the ticket.
Hi @birgire i have found the issue in bulk_edit_posts
function in which $post_data['tax_input']['post_format']
is not unset when post format selection is empty. you can please check my patch and let me know your though
#7
@
6 years ago
- Keywords has-unit-tests added
- Version changed from 4.9.8 to 4.9
Related ticket #41396
@mukesh27 that looks good
The patch in 44914.diff adjusts 44914.patch by using a single unset.
It also adds a unit test.
We note that get_post_format()
removes the post format prefix 'post-format-'
before returning the post format slug.
It's not enough to assert only with get_post_format()
if the post format was preserved in bulk post editing,
as the bug here removes the post format prefix from the post format slug.
Example: The 'post-format-image'
is changed and saved to 'image'
.
So we need to explicitly check the post format slug.
Here we tested 3 posts;
- the first one with Image post format,
- the second one with Aside post format,
- the third one with Standard post format (means it's not set).
#8
follow-up:
↓ 9
@
6 years ago
@birgire check video https://youtu.be/3SaoiCTI7yo it's working for me.
#9
in reply to:
↑ 8
@
6 years ago
- Keywords needs-testing removed
Replying to mukesh27:
@birgire check video https://youtu.be/3SaoiCTI7yo it's working for me.
Thanks for the video, looks good.
#10
@
6 years ago
- Milestone changed from Awaiting Review to 4.9.9
- Owner set to SergeyBiryukov
- Status changed from new to reviewing
#14
@
6 years ago
- Keywords dev-feedback reporter-feedback added
Hi,
The issue is very relevant and there is a really reproductible bug, but after some tests, the patch doesn't apply on my side, it doesn't fix the problem, post_format
are still removed. @SergeyBiryukov @mukesh27 @birgire @lanche86 Do you think you can test it again and see if the latest patch looks good on your side? Otherwise, we are going to punt it to 5.1. Thanks.
#15
@
6 years ago
- Keywords reporter-feedback removed
@audrasjb thanks for testing
The patch seems to work for me, it just needed a refresh as it didn't apply cleanly after 4 months, creating wp-admin/includes/post.rej
instead of updating the wp-admin/includes/post.php
file.
The unit test is running as expected and I also tested successfully to bulk edit posts with non-default post formats in wp-admin.
If the 44914-2.diff is not working, it would be great if you could post the steps in your testing and very the changes in wp-admin/includes/post.php
, thanks.
True story! Thanks Milan for posting it. :)