• Hi,

    I think I’ve found a bug in BuddyPress for Learndash.

    Steps to repeat:

    1. Environment:
    • Multisite
    • Plugins active
    • bbPress
    • BuddyPress (w/ groups)
    • Learndash
    • BuddyPress for Learndash
    • Themes active:
    • Twenty Sixteen
    • Publish a course.
    • Create a group with forum and attach it to the course.
    • Go back to the course, confirm that the group is attached and save (no changes made).
    • What I expected:

      The course would’ve been published as normal

      What happened:

      Error 500

      Suspected reason for bug:

      The php script enters an infinite loop caused by
      function bp_learndash_save_postdata
      at buddypress-learndash/includes/bp-learndash-groups.php:104

      It’s attached to ‘save_post’-hook and calls
      function bp_learndash_attach_forum()
      at buddypress-learndash/includes/bp-learndash-functions.php:207
      which calls wp_update_post() which fires ‘save_post’-hook again and the loop continues on from there.

      This loop should be stopped by
      if ( 'sfwd-courses' == $_POST[ 'post_type' ] )
      at bp-learndash-groups.php:120
      but this checks the HTTP POST, not the actual WP_Post.

      Suggested fix:

      Change the condition to check against the WP_Post object.

      add_action( 'save_post', array ( $this, 'bp_learndash_save_postdata' ), 10, 2 );
      at bp-learndash-groups.php:44

      public function bp_learndash_save_postdata( $post_id, $post ) {
      at bp-learndash-groups.php:104

      if ( 'sfwd-courses' == $post->post_type ) {
      at bp-learndash-groups.php:120

      https://www.ads-software.com/plugins/buddypress-learndash/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Infinite loop on saving course w/ attached course’ is closed to new replies.