Attachments post_parent

  1. It looks like when photos are uploaded within posts via the WP iPhone App, they are added before the blog post. Accordingly, the attachment isn't associated with the blog post (i.e., post_parent is set to 0).

    Is this just how it is or should I be doing something different?

    If this is known, is there a workaround?

  2. There is some code on the WP to allow attachments to be associated with a new post via XML-RPC. I haven't looked into the app to see if that is the approach it is using. Another thing that was recently brought is that some database changes that WP made might be breaking this as well.

  3. As far as I can tell, the App is not associating photos with the post itself. When you look in the Media Library after posting, "Attached to" is blank for any photos posted through the App.

    I will check out the code you mentioned. I figured it was on the XML-RPC side, but wasn't sure where to start looking for a fix.


  4. If this is related to the issue that I think it is then it's from a DB field change from signed bigint to unsigned bigint for post id and post parent id.

  5. Ok, cool. I'll check out both and report back after I come to some kind of resolution.

  6. You were right, the post_parent field in WP 2.8.3 is set to bigint(20) UNSIGNED.

    The attach_uploads function in xmlrpc.php calls (Line 2272):

    "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '-1' AND post_type = 'attachment'"

    I changed the -1 to 0 and it seems to work properly again:

    SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'

    I suppose you could change the mw_newMediaObject function to not use -1 as post_id (Line 2879), but either way that seems to fix the problem (at least until we get an official XML-RPC fix).

    I don't like touching core files, but I don't know of another way of fixing that issue.

    Thanks for the help.

  7. There's a WP ticket - - to make that exact change, from -1 to zero. Having you confirm that the change works is a good sign. I'll be generating a patch and ask about getting it committed so that the next release of WP has this fix.

  8. Word. I'll keep my eye out for that release.

    Thanks again for your help.

  9. Just in case anyone comes across this thread and is dealing with the same issue in WP itself.

    Apparently, the schema change affected more than the XML-RPC file:

    Attachments uploaded before post is saved or autosaved get 0 (zero) for post_parent (instead of temp_id value)

    I'm having the same issues.

    Here's a temp fix and explanation of the issue, because it appears we're not getting an official fix until WP 2.9 now. So, best take care of it yourself in the meantime.

Topic Closed

This topic has been closed to new replies.

About this Topic