Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)

  • SlothLoveChunk
    Participant

    @slothlovechunk


    SlothLoveChunk
    Participant

    @slothlovechunk

    @r-a-y After a bit more debugging I’ve traced the route of the problem to the updated, “bp_filter_metaid_column_name” function in /bp-core/bp-core-filters.php. The updated function includes a new regex:

    function bp_filter_metaid_column_name( $q ) {
    	/*
    	 * Replace quoted content with __QUOTE__ to avoid false positives.
    	 * This regular expression will match nested quotes.
    	 */
    	$quoted_regex = "/'[^'\\\\]*(?:\\\\.[^'\\\\]*)*'/s";
    	preg_match_all( $quoted_regex, $q, $quoted_matches );
    	$q = preg_replace( $quoted_regex, '__QUOTE__', $q );
    
    	$q = str_replace( 'meta_id', 'id', $q );
    
    	// Put quoted content back into the string.
    	if ( ! empty( $quoted_matches[0] ) ) {
    		for ( $i = 0; $i < count( $quoted_matches[0] ); $i++ ) {
    			$quote_pos = strpos( $q, '__QUOTE__' );
    			$q = substr_replace( $q, $quoted_matches[0][ $i ], $quote_pos, 9 );
    		}
    	}
    
    	return $q;
    }

    The old function was simply:

    function bp_filter_metaid_column_name( $q ) {
    	return str_replace( 'meta_id', 'id', $q );
    }

    If I swap out the updated version of this function for the old one everything works fine. Also, if I comment out the regex portion of ‘bp_filter_metaid_column_name’ it works fine as well.

    I added some logging to this function and the output seems a bit strange to me. It’s a bit hard to follow, but here it goes:

    [06-Feb-2015 18:40:43 UTC] $q First: SELECT activity_id, meta_key, meta_value FROM wp_bp_activity_meta WHERE activity_id IN (404095) ORDER BY meta_id ASC
    
    [06-Feb-2015 18:40:43 UTC] $q Second: SELECT activity_id, meta_key, meta_value FROM wp_bp_activity_meta WHERE activity_id IN (404095) ORDER BY id ASC
    
    [06-Feb-2015 18:40:43 UTC] $q First: SELECT meta_id FROM wp_bp_activity_meta WHERE meta_key = __QUOTE__ AND activity_id = 404095
    
    [06-Feb-2015 18:40:43 UTC] $q Second: SELECT id FROM wp_bp_activity_meta WHERE meta_key = __QUOTE__ AND activity_id = 404095
    
    [06-Feb-2015 18:40:43 UTC] $q Third: SELECT id FROM wp_bp_activity_meta WHERE meta_key = '_bp_akismet_result' AND activity_id = 404095
    
    [06-Feb-2015 18:40:43 UTC] $q First: INSERT INTO <code>wp_bp_activity_meta</code> (<code>activity_id</code>,<code>meta_key</code>,<code>meta_value</code>) VALUES (__QUOTE__,__QUOTE__,__QUOTE__)
    
    [06-Feb-2015 18:40:43 UTC] $q Second: INSERT INTO <code>wp_bp_activity_meta</code> (<code>activity_id</code>,<code>meta_key</code>,<code>meta_value</code>) VALUES (__QUOTE__,__QUOTE__,__QUOTE__)
    
    [06-Feb-2015 18:40:43 UTC] $q Third: INSERT INTO <code>wp_bp_activity_meta</code> (<code>activity_id</code>,<code>meta_key</code>,<code>meta_value</code>) VALUES ('404095',__QUOTE__,__QUOTE__)
    
    [06-Feb-2015 18:40:43 UTC] $q Third: INSERT INTO <code>wp_bp_activity_meta</code> (<code>activity_id</code>,<code>meta_key</code>,<code>meta_value</code>) VALUES ('404095','_bp_akismet_result',__QUOTE__)
    
    [06-Feb-2015 18:40:43 UTC] $q Third: INSERT INTO <code>wp_bp_activity_meta</code> (<code>activity_id</code>,<code>meta_key</code>,<code>meta_value</code>) VALUES ('404095','_bp_akismet_result','false')

    The SQL statement appended to the ‘$q Third:’ output is logged from inside the ‘$quoted_matches[0]’ for loop (line 744). I get the idea here is for backwards compatibility between ‘id’ and ‘activity_id’, but shouldn’t it still return the “SELECT’ portion of the SQL query?

    Anyhow, I could be completely wrong here, but @r-a-y / @johnjamesjacoby, I’d love to know your thoughts. Sorry for the super long reply


    SlothLoveChunk
    Participant

    @slothlovechunk

    This is definitely strange @r-a-y. If I revert back all works as it should. I’ve debugged a bunch of the functions and they seem to be returning the proper values. It seems that ‘post_update’ action in buddypress.js is not receiving a response though. e.g.

    jq.post( ajaxurl, {
    	action: 'post_update',
    	'cookie': bp_get_cookies(),
    	'_wpnonce_post_update': jq('#_wpnonce_post_update').val(),
    	'content': content,
    	'object': object,
    	'item_id': item_id,
    	'since': last_date_recorded,
    	'_bp_as_nonce': jq('#_bp_as_nonce').val() || ''
    },
    function(response) {
        (removed for sake of shorting the reply here)
    }

    Any guesses as to why not? When debugging Akismet I was able to get a 200 response back no problem.

    [response] => Array
    	(
    		[headers] => Array
    			(
    				[server] => nginx
    				[date] => Fri, 06 Feb 2015 01:00:40 GMT
    				[content-type] => text/plain; charset=utf-8
    				[content-length] => 5
    				[connection] => close
    				[x-akismet-server] => 10.4.64.80
    				[x-akismet-guid] => 42e6a5b9b7e87435df0bd1812654520f
    			)
    
    		[body] => false
    		[response] => Array
    			(
    				 => 200
    				[message] => OK
    			)
    
    		[cookies] => Array
    			(
    			)
    
    		[filename] => 
    	)

    SlothLoveChunk
    Participant

    @slothlovechunk

    I appreciate the update @r-a-y. Akismet is working on my end too; however, that’s not really the problem. The issue seems to be that when Akismet is enabled the spam check prevents an activity update from appearing in the activities list below (prepending to <ul id=”activity-stream” class=”activity-list item-list”>). “Load Newest” does appear, the activity update is saved, and the activity admin shows “Cleared by Akismet”.

    I hope that makes things a bit more clear.


    SlothLoveChunk
    Participant

    @slothlovechunk

    @r-a-y

    FWIW, I am testing locally, but ‘wp_remote_post( ‘https://buddypress.org&#8217; );’ seems to return a response just fine. RSS items displayed in the “WordPress News” dashboard widget load as well.

    I don’t want to this to be a red herring, so I am happy to test out any other ideas.


    SlothLoveChunk
    Participant

    @slothlovechunk

    Appreciate that.

    I should add that if I re-enable Akismet while commenting out line 52 in /bp-activity/bp-activity-akismet.php, activity updates post fine.

    Line 52
    add_action( 'bp_activity_before_save',     array( $this, 'check_activity' ), 4, 1 );
Viewing 6 replies - 1 through 6 (of 6 total)
Skip to toolbar