Changeset 8038
- Timestamp:
- 10/15/2026 11:08:10 PM (10 days ago)
- Location:
- branches/2.6
- Files:
-
- 5 edited
-
CHANGELOG.md (modified) (1 diff)
-
src/includes/common/functions.php (modified) (1 diff)
-
src/includes/core/filters.php (modified) (1 diff)
-
tests/phpunit/testcases/common/functions.php (modified) (1 diff)
-
tests/phpunit/testcases/common/rest.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/2.6/CHANGELOG.md
r8028 r8038 13 13 Development for the next bbPress release is in progress. See the active 14 14 [Trac milestones](https://bbpress.trac.wordpress.org/roadmap) for planned work. 15 16 ### Fixed 17 18 - Preserved the original date of pending topics and replies across status changes. 15 19 16 20 ## 2.6.20 - 2026-10-15 -
branches/2.6/src/includes/common/functions.php
r8017 r8038 262 262 263 263 return $retval; 264 } 265 266 /** 267 * Set the GMT date for pending topics and replies. 268 * 269 * WordPress leaves the GMT date empty for pending posts, which can cause a 270 * later status change to replace the original post date. 271 * 272 * @since 2.6.21 bbPress 273 * 274 * @param array $data Post data 275 * @return array Filtered post data 276 */ 277 function bbp_set_pending_post_date_gmt( $data = array() ) { 278 if ( 279 isset( $data['post_type'], $data['post_status'], $data['post_date'], $data['post_date_gmt'] ) 280 && in_array( $data['post_type'], array( bbp_get_topic_post_type(), bbp_get_reply_post_type() ), true ) 281 && ( bbp_get_pending_status_id() === $data['post_status'] ) 282 && ( '0000-00-00 00:00:00' === $data['post_date_gmt'] ) 283 ) { 284 $data['post_date_gmt'] = get_gmt_from_date( $data['post_date'] ); 285 } 286 287 return $data; 264 288 } 265 289 -
branches/2.6/src/includes/core/filters.php
r8013 r8038 59 59 add_filter( 'rest_request_before_callbacks', 'bbp_filter_rest_user_discovery', 10, 3 ); 60 60 61 // Filter WordPress post data for forums and anonymous posts61 // Filter WordPress post data for forums, pending dates, and anonymous posts 62 62 add_filter( 'wp_insert_post_data', 'bbp_filter_admin_forum_post_data', 20, 2 ); 63 add_filter( 'wp_insert_post_data', 'bbp_set_pending_post_date_gmt', 25 ); 63 64 add_filter( 'wp_insert_post_data', 'bbp_fix_post_author', 30, 2 ); 64 65 -
branches/2.6/tests/phpunit/testcases/common/functions.php
r7998 r8038 635 635 'This test has not been implemented yet.' 636 636 ); 637 } 638 639 /** 640 * @covers ::bbp_set_pending_post_date_gmt 641 */ 642 public function test_bbp_set_pending_post_date_gmt_preserves_dates_on_status_change() { 643 $forum_id = $this->factory->forum->create(); 644 $topic_id = $this->factory->topic->create( array( 645 'post_parent' => $forum_id, 646 'post_status' => bbp_get_pending_status_id(), 647 'post_date' => '2020-01-01 00:00:00', 648 'topic_meta' => array( 'forum_id' => $forum_id ), 649 ) ); 650 $reply_id = $this->factory->reply->create( array( 651 'post_parent' => $topic_id, 652 'post_status' => bbp_get_pending_status_id(), 653 'post_date' => '2020-01-02 00:00:00', 654 'reply_meta' => array( 655 'forum_id' => $forum_id, 656 'topic_id' => $topic_id, 657 ), 658 ) ); 659 660 foreach ( array( $topic_id, $reply_id ) as $post_id ) { 661 $post_date = get_post_field( 'post_date', $post_id ); 662 $this->assertSame( get_gmt_from_date( $post_date ), get_post_field( 'post_date_gmt', $post_id ) ); 663 664 wp_update_post( array( 665 'ID' => $post_id, 666 'post_status' => bbp_get_spam_status_id(), 667 ) ); 668 669 $this->assertSame( $post_date, get_post_field( 'post_date', $post_id ) ); 670 } 637 671 } 638 672 -
branches/2.6/tests/phpunit/testcases/common/rest.php
r8017 r8038 1095 1095 1096 1096 /** 1097 * A pending topic's zeroGMT date must not lock out its recent author.1097 * A pending topic's GMT date must not lock out its recent author. 1098 1098 * 1099 1099 * @covers BBP_REST_Posts_Controller::update_item_permissions_check … … 1108 1108 bbp_set_user_role( $user_id, bbp_get_participant_role() ); 1109 1109 1110 $this->assertSame( '0000-00-00 00:00:00', get_post_field( 'post_date_gmt', $topic_id ) );1110 $this->assertSame( get_gmt_from_date( get_post_field( 'post_date', $topic_id ) ), get_post_field( 'post_date_gmt', $topic_id ) ); 1111 1111 $response = $this->update_item( bbp_get_topic_post_type(), $topic_id, $user_id, array( 'content' => 'Pending revision.' ) ); 1112 1112 … … 1194 1194 bbp_set_user_role( $user_id, bbp_get_participant_role() ); 1195 1195 1196 $this->assertSame( '0000-00-00 00:00:00', get_post_field( 'post_date_gmt', $reply_id ) );1196 $this->assertSame( get_gmt_from_date( get_post_field( 'post_date', $reply_id ) ), get_post_field( 'post_date_gmt', $reply_id ) ); 1197 1197 $response = $this->update_item( bbp_get_reply_post_type(), $reply_id, $user_id, array( 'content' => 'Pending reply revision.' ) ); 1198 1198
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)