Make WordPress Core

Opened 10 years ago

Last modified 3 months ago

#29999 new defect (bug)

update post overwrites slug if current_user is contributor

Reported by: jnhghy's profile jnhghy Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 4.0
Component: Posts, Post Types Keywords: has-patch dev-feedback
Focuses: Cc:


The wp_update_post function calls wp_insert_post which is located in wp-includes/post.php in posts.php at lines 3168 - 3171 there is this code:

	        // Don't allow contributors to set the post slug for pending review posts.
	        if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) ) {
	                $post_name = '';

this will remove post_name if the current user is a contributor without any message or notification. This creates an issue because scripts/plugins that uses wp_upadate_post usually don't handle this case (the documentation doesn't cover this also - I would update the documentation but I'm wondering if there's no other solution).

I don't see the issues that a contributor changing the slug would create (a contributor vs an editor) anybody does?

Attachments (1)

29999.patch (2.1 KB) - added by deconf 9 years ago.

Download all attachments as: .zip

Change History (20)

#1 @jnhghy
10 years ago

  • Severity changed from normal to trivial

#2 @jayelebun
9 years ago

  • Keywords reporter-feedback added

Hey @jnhghy,

I went through in an attempt to reproduce. Here is a rundown of what I did trying to see if the post slug would disappear or if I would be blocked from updating the post slug as a contributor

  1. Save test post as a draft as contributor.
  1. Changed the title and the post slug updated successfully. Save post as pending review.
  1. Logged in as admin. Published test post. The title and post slug changes persist. Now signing out to edit title and slug as a contributor.
  1. Unpublished as admin, logged in as contributor, still able to edit both the title and post slug and both persist on save draft. Not able to reproduce this error.

Could you provide some more steps on how you're running into this issue? Have you tested this on vanilla WP? For the installation where you're seeing this issue are there any other plugins dealing with permissions?


#3 @jnhghy
9 years ago

Hi, Thank you for your time spent on this.

Here are the steps I'm making to hit this issue:

1) Create post with contributor user and submit it for publish
2) Publish post with admin
3) Draft post with admin
4) Edit post with contributor and change slug, send for review
5) Edit post again with contributor (no slug changing option at this time), send for review again
6) check post with admin, no slug changes will be seen

I haven't tested this with vanilla WP sorry (I'm not familiar with vanila WP, a link? or is it the vanila WP plugin?)

Let me know if you need any other info or if you can confirm this issue.

This ticket was mentioned in Slack in #core by jnhghy. View the logs.

9 years ago

#5 @SergeyBiryukov
9 years ago

  • Component changed from Role/Capability to Posts, Post Types

#6 @jnhghy
9 years ago

  • Keywords reporter-feedback removed

Also tested with a fresh install of WordPress the issue is still there in wp 4.1.1.

9 years ago

#7 @deconf
9 years ago

I was able to replicate the issue. will allow contributors to edit the slug while a post is waiting for review.

Allowing contributors to edit slugs while a post is pending review also fixes this bug.

I can't see why a contributor should be restricted on changing the slug while the post is waiting for review, since he's allowed to edit it while the post is a Draft.

Version 4, edited 9 years ago by deconf (previous) (next) (diff)

#8 @ocean90
9 years ago

  • Type changed from feature request to enhancement

Introduced in [9055], #7805.

#9 @jnhghy
9 years ago

  • Type changed from enhancement to defect (bug)

Because of this issue info is lost so I'd leave its status as bug instead of enhancement.

Last edited 9 years ago by jnhghy (previous) (diff)

#10 @deconf
9 years ago

  • Focuses docs removed
  • Keywords has-patch dev-feedback added
  • Severity changed from trivial to minor

#11 @repenter
8 years ago

Guyz I reported this bug here: #37262

Are these bugs the same?

Last edited 7 years ago by SergeyBiryukov (previous) (diff)

#12 @SergeyBiryukov
7 years ago

#37262 was marked as a duplicate.

#14 @repenter
5 years ago

Seriously no one wants to fix this issue in wordpress?

This ticket was mentioned in Slack in #bbpress by netweb. View the logs.

5 years ago

#16 @SergeyBiryukov
4 years ago

#46486 was marked as a duplicate.

This ticket was mentioned in Slack in #core-editor by gwwar. View the logs.

3 years ago

#18 @helpingcat
3 years ago

Is the behavior here expected? From the code comment here, it looks intentional, but it'd be great if we could clarify for folks why we check for this. (For example, is this security related?)

#19 @brookedot
3 months ago

The field has been hidden in the block editor in

However, looking at this again, I am wondering if we should add a filter to allow contributors to edit the slug?

In other words, a filter that allows the conditional to return false.


Note: See TracTickets for help on using tickets.