Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Infinite loop when posting group activity comment

  • Under certain circumstances, there is an infinite loop inside the bp_legacy_theme_new_activity_comment() function. Specifically, when all of the secondary_item_id fields are zero, the $parent_id will continually be set to zero. An infinite loop ensues and eventually the script will time out. This causes new activity items to not display until the page is refreshed, as mentioned here: https://buddypress.org/support/topic/activity-comments-post-blank-until-refresh/.

    This error happens when attempting to add a comment to a group post. I believe this is a similar problem as the one expressed here: https://buddypress.org/support/topic/activity-comments-post-blank-until-refresh/

    For information:

    • WordPress 4.5.3
    • BuddyPress 2.6.1.1
    • Single site install in web root
    • There are indeed other plugins activated on this site. The full list is below. This site is for a client, and I’m unsure of which plugins can be safely deactivated to test.
    • We’re using a customized theme, but I have tested with the TwentySixteen theme and found the same results.
    • The core BuddyPress files have not been modified to my knowledge.
    • The site is hosted on Page.ly, but I can reproduce the problems in a local VVV install
    • The live site is http://www.lifeofdad.com/

    I believe that this may be a problem inside BuddyPress itself, as the function with the infinite loop is part of BuddyPress. The Javascript that makes the Ajax request is part of the BuddyPress Wall plugin, but from what I can tell the problem is in the aforementioned bp_legacy_theme_new_activity_comment() function.

    My specific concern is this loop:

    
    	// Load the new activity item into the $activities_template global.
    	bp_has_activities( 'display_comments=stream&hide_spam=false&show_hidden=true&include=' . $comment_id );
    
    	// Swap the current comment with the activity item we just loaded.
    	if ( isset( $activities_template->activities[0] ) ) {
    		$activities_template->activity = new stdClass();
    		$activities_template->activity->id              = $activities_template->activities[0]->item_id;
    		$activities_template->activity->current_comment = $activities_template->activities[0];
    
    		// Because the whole tree has not been loaded, we manually
    		// determine depth.
    		$depth = 1;
    		$parent_id = (int) $activities_template->activities[0]->secondary_item_id;
    		while ( $parent_id !== (int) $activities_template->activities[0]->item_id ) {
    			$depth++;
    			$p_obj = new BP_Activity_Activity( $parent_id );
    			$parent_id = (int) $p_obj->secondary_item_id;
    		}
    		$activities_template->activity->current_comment->depth = $depth;
    	}
    

    I’ve run XDebug locally to inspect the items in the loop as it is running. If some of the raw variable data is required, I can provide that.

    I have tried making some changes to the code in this loop to prevent the infinite loop from occurring. While successful in that endeavor with a few tweaks, the result is that the comment sent back through the Ajax response is the wrong comment, and a page refresh is still needed.

    I considered filing a bug in Trac, but I wasn’t certain whether something else could possibly be interfering.

    
    +--------------------------------------+--------+-----------+---------+
    | name                                 | status | update    | version |
    +--------------------------------------+--------+-----------+---------+
    | akismet                              | active | none      | 3.1.11  |
    | all-in-one-seo-pack                  | active | available | 2.3.7   |
    | appbuddy                             | active | available | 2.0.7   |
    | appcamera                            | active | available | 2.0.0   |
    | appfbconnect                         | active | none      | 2.3.0   |
    | apppresser                           | active | none      | 2.5.0   |
    | apppush                              | active | available | 2.1.0   |
    | appshare                             | active | none      | 2.1.0   |
    | appswiper                            | active | available | 2.2.1   |
    | bp-profile-search                    | active | none      | 4.5.2   |
    | buddypress                           | active | none      | 2.6.1.1 |
    | buddypress-activity-plus             | active | none      | 1.6.4   |
    | bp-moderation                        | active | none      | 0.1.7   |
    | buddypress-nocaptcha-register-box    | active | none      | 1.1.3   |
    | buddypress-toolbar                   | active | none      | 1.6.0   |
    | buddypress-wall                      | active | none      | 0.9.4   |
    | buddypress-xprofile-image-field      | active | none      | 2.0.1   |
    | category-posts                       | active | none      | 4.6.1   |
    | contact-form-7                       | active | none      | 4.4.2   |
    | contact-form-7-to-database-extension | active | none      | 2.10.20 |
    | cubell-themes-functionality          | active | none      | 3.1     |
    | envato-wordpress-toolkit             | active | none      | 1.7.3   |
    | hashbuddy                            | active | none      | 1.5.2   |
    | login-with-ajax                      | active | none      | 3.1.6   |
    | mailchimp-for-wp                     | active | none      | 3.1.11  |
    | nav-menu-roles                       | active | none      | 1.8.2   |
    | nextend-facebook-connect             | active | none      | 1.5.9   |
    | buddypress-media                     | active | none      | 4.0.4   |
    | vine-embed                           | active | none      | 0.2     |
    | wds-lod-automatic-friends            | active | none      | 0.1.0   |
    | wds-lod-base                         | active | none      | 0.1.0   |
    | wds-lod-bp                           | active | none      | 0.1.0   |
    | wds-lod-post-types                   | active | none      | 0.1.0   |
    | wds-lod-widgets                      | active | none      | 0.1.0   |
    | wordpress-importer                   | active | none      | 0.6.1   |
    +--------------------------------------+--------+-----------+---------+
    
Viewing 7 replies - 1 through 7 (of 7 total)

  • shanebp
    Moderator

    @shanebp

    If you can reproduce the issue with a vanilla install, definitely open a report on trac.


    danbp
    Moderator

    @danbp

    Hi,

    apparently there is a conflict somewhere. Do you receive php notice or warnings with wp_debug activated ? The fn you mention posts new Activity comments received via a POST request.

    Before opening a ticket, can you provide some more details about your install please ? Server type, php version and memory_limit.

    Theme
    Is Valenti theme updated to fit with BuddyPress 2.6 ? No information about this detail on the theme presentation even if recent update (23/6/2016). But it’s crucial to know, as many things changed in 2.6+

    Plugins
    Hashbuddy wasn’t updated since 2 years.
    Do you use WDS-BuddyPress-Project-Framework ?

    Debug
    To test, you can deactivate all plugins except BP. It’s important you ensure that at least the basic install of WP+BP is fully working. First with a twenty theme and second, with your theme (not the child).

    If the site is for a client, you’re a pro. Hopefully you have a sandbox install (locally or online) to do this debug work ?!!!

    Any thoughts @djpaul, @r-a-y ?


    r-a-y
    Keymaster

    @r-a-y

    Try disabling all BuddyPress plugins and try duplicating the problem again.

    My guess is the problem is with the BuddyPress Wall plugin. Deactivate that and see if your problem pops up again.

    Do you have any specific steps to duplicate your problem? Does the problem occur after replying under a certain comment depth or when you hit a certain number of comments in the group update?

    Thanks all for the quick replies. I don’t mean to ignore all of your helpful questions and suggestions, but those may not be needed anymore.

    After getting a chance to speak with a colleague who’s been out of the office for a while, I was able to identify the problem here. A function from a custom plugin was filtering both the bp_before_has_activities_parse_args and bp_after_has_activities_parse_args filters, and the specific problem was that it was setting $args['include'] to an empty string. This removed the comment ID that was supposed to be part of the query, and resulted in the wrong query. We don’t know why it was doing this in the first place, but it has been corrected and the infinite loop has been fixed.

    Regardless, it may be beneficial to include some checking in this code to prevent the possibility of an infinite loop even for edge cases like this.


    danbp
    Moderator

    @danbp

    When a drama is only an incident… 🙂 Glad you got it!


    tall00
    Participant

    @tall00

    Hi @jpry,

    I noticed that you are using buddypress activity plus with apppresser. I am unable to get it to work together on mobile ( don’t see the photo upload icons) . I thought it was not compatible but wanted to check and see does it work for you out of the box.


    tall00
    Participant

    @tall00

    Would appreciate if anyone else can help me with my question

    I basically need to know does buddy press activity plus work with apprepresser on iphone. Would I be able to post pictures via apppresser if I use this plugin. I know it works via a browser but am unable to figure out if it has compatibility with apppresser or not.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Skip to toolbar