[wp-trac] [WordPress Trac] #11863: Trashed items interfere with page/post slug generation
WordPress Trac
noreply at wordpress.org
Tue Apr 5 11:52:21 UTC 2016
#11863: Trashed items interfere with page/post slug generation
-------------------------------------------------+-------------------------
Reporter: Denis-de-Bernardy | Owner: ericlewis
Type: enhancement | Status: reopened
Priority: normal | Milestone: 4.5
Component: Posts, Post Types | Version: 2.9
Severity: normal | Resolution:
Keywords: make-flow has-patch has-unit-tests | Focuses:
needs-testing |
-------------------------------------------------+-------------------------
Changes (by netweb):
* status: closed => reopened
* resolution: fixed =>
Comment:
Reopening as this currently breaks bbPress, with bbPress trashed post
types (topics and replies) can still be viewed, edited, manipulated etc on
the front end and are not limited to the "trash" section of the post types
admin UI back end in `/wp-admin`.
To reproduce:
1. Install bbPress
2. Create a forum with title `11863`
3. Create a topic in the `11863` titled `deleted-topic` and content also
`deleted-topic`
4. Verify the topic exists, e.g `http://src.wordpress-
develop.dev/forums/topic/deleted-topic/`
5. Now "trash" that topic my clicking on the "trash" link in the topic
admin links
6. The topic is only "trashed", the post has not been "deleted" as such it
should still be viewable to those with appropriate roles/caps at
`http://src.wordpress-develop.dev/forums/topic/deleted-topic-%trashed%`
The result above returns an error `400 Bad Request` because `%` percentage
symbols in URL's are [https://en.wikipedia.org/wiki/Percent-encoding
#Percent-encoding_reserved_characters reserved characters].
Workaround is to replace the `%` characters in `-%trashed%` from the
change in r36607 with characters that are valid for URL usage:
{{{
#!diff
Index: src/wp-includes/post.php
===================================================================
--- src/wp-includes/post.php (revision 37158)
+++ src/wp-includes/post.php (working copy)
@@ -6126,11 +6126,11 @@
$post = get_post( $post );
- if ( strpos( $post->post_name, '-%trashed%' ) ) {
+ if ( strpos( $post->post_name, '-yolo-trashed-yolo' ) ) {
return $post->post_name;
}
add_post_meta( $post->ID, '_wp_desired_post_slug',
$post->post_name );
- $post_name = _truncate_post_slug( $post->post_name, 190 ) .
'-%trashed%';
+ $post_name = _truncate_post_slug( $post->post_name, 190 ) .
'-yolo-trashed-yolo';
$wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ),
array( 'ID' => $post->ID ) );
clean_post_cache( $post->ID );
return $post_name;
}}}
The result of applying that page is after restoring the trashed topic,
then applying the patch and trashing the topic once again is that the
topic is now viewable once again on the front end via the URL `http://src
.wordpress-develop.dev/forums/topic/deleted-topic-yolo-trashed-
yolo/?view=all`
Any suggestions apart from `yolo` to replace the `%` characters?
--
Ticket URL: <https://core.trac.wordpress.org/ticket/11863#comment:123>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list