Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 12 years ago

#4523 closed defect (bug) (fixed)

On submitting a new activity, I got error "There was a problem posting your update, please try again."

Reported by: renp's profile renp Owned by:
Milestone: 1.6.2 Priority: normal
Severity: major Version: 1.6.1
Component: Activity Keywords: needs-testing
Cc:

Description

In activity stream, when I write something and click Post update, it always writes (in a red box): "There was a problem posting your update, please try again." and the activity is not saved.
Running on Wordpress 3.4.2, BuddyPress 1.6.1, Apache (httpd) 2.2.21, PHP 5.3.17 (also tried 5.2.17), MySQL 5.1.60, Windows 7.

Change History (12)

#1 @renp
12 years ago

  • Severity changed from major to critical

I've turned WP error logging on and this is the cause of the error:

WordPress database error: [Incorrect integer value: for column 'item_id' at row 1]
INSERT INTO wp_bp_activity ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( 1, 'activity', 'activity_update', '<a href=\"http://localhost/members/admin/\" title=\"admin\">admin</a> posted an update', 'test', 'http://localhost/members/admin/', '2012-09-13 13:00:40',
, , 0, 0 )
-1

#2 @boonebgorges
12 years ago

  • Keywords reporter-feedback added

Thanks for the details.

What theme are you using? Other BP plugins? Can you enable your Javascript console, and (a) see if there are any errors when posting the new activity, and (b) look at the content of the POST payload?

#3 @renp
12 years ago

  • Keywords dev-feedback added; reporter-feedback removed

I've checked that the error occurs even on clean WP installation with the default BP template. In JS console, no error occurs. The ajax response is as follows (part of it is the error message which I posted above):

<div id='error'>

<p class='wpdberror'><strong>WordPress database error:</strong> [Incorrect integer value: &#039;&#039; for column &#039;item_id&#039; at row 1]<br />
<code>INSERT INTO wp_bp_activity ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( 1, &#039;activity&#039;, &#039;activity_update&#039;, &#039;&lt;a href=\&quot;http://localhost/members/admin/\&quot; title=\&quot;admin\&quot;&gt;admin&lt;/a&gt; posted an update&#039;, &#039;sdgsdg&#039;, &#039;http://localhost/members/admin/&#039;, &#039;2012-09-13 13:50:14&#039;, &#039;&#039;, &#039;&#039;, 0, 0 )</code></p>
</div>-1<div id="message" class="error"><p>There was a problem posting your update, please try again.</p></div>

#4 @boonebgorges
12 years ago

  • Keywords reporter-feedback added; dev-feedback removed

What's the data being sent along with the inital POST request? This is the 'Post' tab when viewing the expanded version of the POST request in Firebug.

#5 @renp
12 years ago

  • Keywords dev-feedback added; reporter-feedback removed

This should be it (it's from chrome actually):

action:post_update
cookie:http%3A%2F%2Flocalhost%2F%23s5_scrolltotop%3D0.75%2C0.75%3B%20http%3A%2F%2Flocalhost%2F%3D0.75%2C0.75%3B%20wp-settings-1%3Dmfold%253Do%3B%20wp-settings-time-1%3D1347355115%3B%20mp_globalcart_c9db569cb388e160e4b86ca1ddff84d7%3Da%253A1%253A%257Bi%253A2%253Ba%253A0%253A%257B%257D%257D%3B%20wp-settings-time-3%3D1347460003%3B%20wp-settings-time-2%3D1347463109%3B%20PHPSESSID%3Dqh4bu80nbcjj62qd66d1fsfme0%3B%20wp-settings-time-5%3D1347533852%3B%20bp_new_group_id%3D1%3B%20bp_completed_create_steps%3Da%253A4%253A%257Bi%253A0%253Bs%253A13%253A%2522group-details%2522%253Bi%253A1%253Bs%253A14%253A%2522group-settings%2522%253Bi%253A2%253Bs%253A12%253A%2522group-avatar%2522%253Bi%253A3%253Bs%253A13%253A%2522group-invites%2522%253B%257D%3B%20wp-settings-time-4%3D1347543059%3B%20wordpress_test_cookie%3DWP%2BCookie%2Bcheck%3B%20bp-activity-oldestpage%3D1
_wpnonce_post_update:b1e315c075
content:rrghrghwr
object:
item_id:0
_bp_as_nonce:

#6 @DJPaul
12 years ago

I can't recreate on WP 3.4.1 and BP 1.6.1.

#7 @boonebgorges
12 years ago

  • Keywords needs-testing added
  • Milestone changed from Awaiting Review to 1.6.2
  • Severity changed from critical to major

renp - Thanks for the additional info.

I've confirmed the issue. renp, you must be running MySQL using sql_mode TRADITIONAL or something like that, which means that what are normally syntax warnings (which fail gracefully) become fatal errors. This isn't the default setup, and I haven't heard this bug reported before, so I'm going to reduce the severity a bit.

In any case, the problem is that we recently (r5955) converted the item_id and secondary_item_id columns of the activity table to bigint(20). But we didn't, at the same time, change the $wpdb->prepare() statement in BP_Activity_Activity::get() to account for the fact that these values should be integers rather than strings. As a result, NULL becomes '', rather than 0.

Changing those two %s to %d fixes the problem in my tests. Can another dev have a look and let me know whether they foresee any complications with this?

#8 @DJPaul
12 years ago

Should be ok. In my database, existing records are set to 0, so shouldn't break any query.

#9 @renp
12 years ago

  • Keywords close added; dev-feedback needs-testing removed
  • Resolution set to worksforme
  • Status changed from new to closed

boonebgorges, thanks for an excellent support!
I've managed to fix the problem by modifying the query in bp-activity-classes.php so that if item_id is null, I send '0' to the DB (instead of ). The same applies to secondary_item_id.

#10 @DJPaul
12 years ago

  • Keywords needs-testing added; close removed
  • Resolution worksforme deleted
  • Status changed from closed to reopened

Please keep the ticket open so we remember to patch BuddyPress :)

#12 @boonebgorges
12 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.