Opened 7 years ago
Last modified 6 years ago
#3169 closed defect (bug)
Infinite loop on update reply — at Initial Version
Reported by: | moejonet | Owned by: | |
---|---|---|---|
Milestone: | 2.6 | Priority: | high |
Severity: | critical | Version: | 2.5.14 |
Component: | Extend - BuddyPress | Keywords: | has-patch |
Cc: |
Description
There is an infite loop on reply update caused by buddypress activity from bbpress if bbp_thread_replies() is false.
activity tries to get reply position, in this call position is updated for the reply but we are still in edit_post action so wp_update_post is called recursively until server gives up.
stacktrace:
var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/functions.php(2143): wp_update_post(Array)
#2 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/template.php(1757): bbp_update_reply_position(508812, 1)
#3 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/template.php(487): bbp_get_reply_position(508812, 508811)
#4 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/extend/buddypress/activity.php(552): bbp_get_reply_url(508812)
#5 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/extend/buddypress/activity.php(642): BBP_BuddyPress_Activity->reply_create(508812, 508811, 495076, Array, 47710)
#6 /var/www/clients/client1/web17/web/wp-includes/class-wp-hook.php(298): BBP_BuddyPress_Activity->reply_update(508812, Object(WP_Post))
#7 /var/www/clients/client1/web17/web/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
#8 /var/www/clients/client1/web17/web/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#9 /var/www/clients/client1/web17/web/wp-includes/post.php(3480): do_action('edit_post', 508812, Object(WP_Post))
#10 /var/www/clients/client1/web17/web/wp-includes/post.php(3591): wp_insert_post(Array, false)
#11 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/functions.php(2143): wp_update_post(Array)
#12 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/template.php(1757): bbp_update_reply_position(508812, 1)
#13 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/template.php(487): bbp_get_reply_position(508812, 508811)
#14 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/extend/buddypress/activity.php(552): bbp_get_reply_url(508812)
#15 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/extend/buddypress/activity.php(642): BBP_BuddyPress_Activity->reply_create(508812, 508811, 495076, Array, 47710)
#16 /var/www/clients/client1/web17/web/wp-includes/class-wp-hook.php(298): BBP_BuddyPress_Activity->reply_update(508812, Object(WP_Post))
#17 /var/www/clients/client1/web17/web/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
#18 /var/www/clients/client1/web17/web/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#19 /var/www/clients/client1/web17/web/wp-includes/post.php(3480): do_action('edit_post', 508812, Object(WP_Post))
#20 /var/www/clients/client1/web17/web/wp-includes/post.php(3591): wp_insert_post(Array, false)
#21 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/functions.php(2143): wp_update_post(Array)
#22 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/template.php(1757): bbp_update_reply_position(508812, 1)
#23 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/template.php(487): bbp_get_reply_position(508812, 508811)
#24 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/extend/buddypress/activity.php(552): bbp_get_reply_url(508812)
#25 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/extend/buddypress/activity.php(642): BBP_BuddyPress_Activity->reply_create(508812, 508811, 495076, Array, 47710)
#26 /var/www/clients/client1/web17/web/wp-includes/class-wp-hook.php(298): BBP_BuddyPress_Activity->reply_update(508812, Object(WP_Post))
#27 /var/www/clients/client1/web17/web/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
#28 /var/www/clients/client1/web17/web/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
#29 /var/www/clients/client1/web17/web/wp-includes/post.php(3480): do_action('edit_post', 508812, Object(WP_Post))
#30 /var/www/clients/client1/web17/web/wp-content/plugins/bbpress/includes/replies/functions.php(45): wp_insert_post(Array)
#31 /var/www/clients/client1/web17/web/wp-content/themes/mikmag-child/lib/core/MundrImportForums.php(663): bbp_insert_reply(Array, Array)
My proposal for change would be:
I would propose following changes in bbp_update_reply_position in bbpress/replies/functions.php:2128.
<?php function bbp_update_reply_position( $reply_id = 0, $reply_position = 0 ) { global $wpdb; // Bail if reply_id is empty $reply_id = bbp_get_reply_id( $reply_id ); if ( empty( $reply_id ) ) return false; // If no position was passed, get it from the db and update the menu_order if ( empty( $reply_position ) ) { $reply_position = bbp_get_reply_position_raw( $reply_id, bbp_get_reply_topic_id( $reply_id ) ); } $db_menu_order = $wpdb->get_var("select menu_order from {$wpdb->posts} where ID={$reply_id}"); if($db_menu_order == $reply_position) return (int) $reply_position; // Update the replies' 'menp_order' with the reply position wp_update_post( array( 'ID' => $reply_id, 'menu_order' => $reply_position ) ); return (int) $reply_position; }
my patch to solve this issue