Ticket #5010 (closed defect (bug): fixed)

Opened 1 year ago

Last modified 1 year ago

Bug in Updating attachment of a post = losing post_parent

Reported by: michelwp Assigned to: anonymous
Priority: high Milestone: 2.3
Component: Administration Version: 2.2.3
Severity: major Keywords: attachment post_parent has-patch
Cc: filosofo

Description

When updating (ie title or description) of an attachment "attached" to a post, the "link" to the parent post is set to 0 and the attachment disappear for the author of the parent post... webmaster workaround : phpmyadmin seem present since 221 Best regards Michel

Attachments

save_post_parent_id.diff (1.4 kB) - added by filosofo on 09/21/07 11:20:58.

Change History

09/19/07 10:49:09 changed by michelwp

Confirm the bug introduced by the new constant EXTR_SKIP function line 1223 of post.php
if replacing by previous version as

// Export array as variables
	extract($object);/*, EXTR_SKIP);*/


the attachment updating conserve the post_parent.. and the attachment remain in UI for the author.
I don't no why, but it is !

09/19/07 19:22:17 changed by foolswisdom

  • milestone changed from 2.2.3 to 2.3.

michelwp, with 2.3 in release candidate, can you confirm the bug is present there?

09/20/07 18:02:22 changed by michelwp

After installing 2.3 RC1, and testing after uploading images attached to one post :
Symptoms of the bug are the same : the author see images linked to his post disapperance !
A quick look on code (post.php) confirm the same probable origine lines 1275- 1286 i.e. variable passed in function...

Good road for solutions...

09/21/07 11:20:58 changed by filosofo

  • attachment save_post_parent_id.diff added.

09/21/07 11:23:03 changed by filosofo

  • cc set to filosofo.
  • keywords changed from attachment post_parent to attachment post_parent has-patch.

I've attached a patch to fix this bug.

09/21/07 15:57:26 changed by ryan

  • priority changed from normal to high.

09/21/07 16:10:51 changed by ryan

I'm not sure why wp_insert_attachment() has a $post_parent argument. I don't see it used anywhere. If it's there I figure it should override the parent in the object so how about we rename the arg to $parent and then insert it into the object as post_parent if it is not zero?

09/21/07 20:37:28 changed by michelwp

I agree : EXTR_SKIP introduced with 2.2 reveal that the third arg $post_parent is set by default to 0.... and the post_parent transmitted by the object cannot be created...
I don't know why both object and this arg are in the function ?
And if calling functions use this both args..
(for temporary patch I use it (3° arg) from the calling function with an internal name as $parent...)
The patch of filosofo don't keep the problem of this third arg....

09/22/07 16:30:40 changed by ryan

  • status changed from new to closed.
  • resolution set to fixed.

(In [6155]) Don't reset parent when updating attachment. Props filosofo and michelwp. fixes #5010

01/05/08 11:15:58 changed by Curioso

  • status changed from closed to reopened.
  • resolution deleted.

When you are in a write new post window, post_id is set to temp_ID, which is a large negative number. This ends up as the post_parent of atachments that are updated in the browse-all tab, so these attachments get a parent set to this large negative number, which confuses WordPress.

Also if you are in the edit post window and update an attachment in the browse-all tab, it is moved to the post that you are editing and is lost in the post where it was originally attached.

01/05/08 13:15:28 changed by Curioso

A working solution is to include array('post_id' => ) as 5th entry in $wp_upload_tabsbrowse-all? in upload.php. This resets the post_id argument, and upload.js already tests on this.

01/05/08 13:16:52 changed by Curioso

There was an empty string after the =>, WikiFormatting probably ate it....

01/05/08 14:27:01 changed by filosofo

  • summary changed from Bug in Updating attachment of a post = loosing post_parent to Bug in Updating attachment of a post = losing post_parent.

Curioso, this has been fixed for a while. What version of WordPress are you testing against?

(follow-up: ↓ 14 ) 01/05/08 15:53:56 changed by Curioso

I am testing against WP 2.3.1, but I did not see any changes in this area in the current trunk.

The bug I see is not the same as the one originally mentioned, but closely related, because in the browse-all tab attachments are shown with various post_parents, and I think they should not be reset to the post_parent of the current post when updating.

(in reply to: ↑ 13 ) 01/05/08 15:59:50 changed by filosofo

  • status changed from reopened to closed.
  • resolution set to invalid.

Replying to Curioso:

The bug I see is not the same as the one originally mentioned, but closely related, because in the browse-all tab attachments are shown with various post_parents, and I think they should not be reset to the post_parent of the current post when updating.

If it's not the same bug, then please open a new ticket.

When you do, please give the steps for reproducing the bug in either the latest stable release (currently 2.3.2) and/or trunk.

Thanks for your help!

01/24/08 17:11:42 changed by Nazgul

  • status changed from closed to reopened.
  • resolution deleted.

01/24/08 17:12:04 changed by Nazgul

  • status changed from reopened to closed.
  • resolution set to fixed.

Reclosing to the previous fixed state.