Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors on updating the draft and pending status #62

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

ingeniumed
Copy link
Contributor

Description

  • Fix an issue introduced with Refactor the remaining modules #59 that stopped updates being possible to the draft and pending review statuses, as they were marked as restricted entirely instead of just to their names and slug.
  • As part of this, I've also enabled updates to both the draft and pending review status's names. Internally, we reset the slug if it's ever updated so we never need to re-assign posts, etc. We also ensure that the new names are registered correctly.
  • I have also updated the validation logic to be a lot more stricter as previously there were some edge cases that could get through.

Deletion of restricted statuses is still not allowed but this would be a good middle ground imo.

Steps to Test

  • Test from scratch that the names of draft and pending review can be changed
  • Test also that new statuses with the same name as one existing or a restricted status cannot be made

@ingeniumed ingeniumed requested a review from a team as a code owner October 10, 2024 02:06
@ingeniumed ingeniumed self-assigned this Oct 10, 2024
@ingeniumed
Copy link
Contributor Author

image

Draft and pending statuses can now be renamed with this PR!

// translators: %s: Post status, like "Draft"
return new WP_Error( 'restricted', sprintf( __( 'Changing the name and slug of a restricted status (%s) is not allowed.', 'vip-workflow' ), $old_status->name ) );
// If the name was changed, we need to change the slug unless its banned from slug updates
if ( isset( $args['name'] ) && $args['name'] !== $old_status->name && ! self::is_status_banned_from_slug_changes( $old_status->slug ) ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove the ! self::is_status_banned_from_slug_changes( $old_status->slug ) check from here, as the code unsets $args['slug'] if the status is banned below anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh, I put it there for safety reasons just in case

@ingeniumed ingeniumed merged commit e7e6d82 into trunk Oct 10, 2024
5 checks passed
@ingeniumed ingeniumed deleted the fix/draft-and-ending-status branch October 10, 2024 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants