WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#11115 closed defect (bug) (fixed)

Path (file) in postmeta is incorrect after editing image

Reported by: waltervos Owned by:
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.9
Component: Media Keywords: needs-patch image-editor postmeta attachments
Focuses: Cc:

Description

The image editor is buggy on my install. Uploading is still fine, but as soon as I start making edits the file paths in postmeta start to break. Here's what happens:

I upload an image and flip or crop it (the only edits I tried). I then save the image. When I check my database I see the my wp_attachment_metadata has changed from:

array (
  'width' => '3008',
  'height' => '2000',
  'hwstring_small' => 'height=\'85\' width=\'128\'',
  'file' => '2009/11/DSC_0100.JPG',
  (... cut out ...)
)

to:

array (
  'width' => '2105',
  'height' => '1278',
  'hwstring_small' => 'height=\'77\' width=\'128\'',
  'file' => 'C:Program FilesApache Software FoundationApache2.2htdocswordpress/wp-content/uploads/2009/11/DSC_0100-e1257850248955.JPG',
  (... cut out ...)
)

At this point I can still make new edits to the image. However, as soon as I restore the original image the _wp_attached_file field in postmeta also break. Instead of 2009/11/DSC_0100.JPG it now reads C:Program FilesApache Software FoundationApache2.2htdocswordpress/wp-content/uploads/2009/11/DSC_0100-e1257850248955.JPG. After this I also can't make any new edits to the file anymore.

I tried this a couple of times so I'm pretty sure these are the triggers and responses for this bug. I have however only tried cropping and flipping the image and I have only tried it on Windows locally. It may work on linux installs.

This is my first bug report so please add to it if you're missing information or ask me for it.

Change History (4)

comment:1 waltervos4 years ago

On Linux the behaviour is a little different. After editing the image, the file attribute in _wp_attachment_metadata is changed to the absolute path (instead of a relative path such as 2009/11/DSC_100.JPG), starting with a / also. Restoring the original image doesn't change that and _wp_attached_file stays the same as when first uploaded. The image can also still be edited afterwards the corrupt _wp_attached_metadata was introduced (probably because _wp_attached_file is used).

I'd like to add that I'm using PHP5 on both setups.

comment:2 waltervos4 years ago

  • Keywords needs-patch image-editor postmeta attachments added

comment:3 scribu4 years ago

  • Keywords changed from needs-patch, image-editor, postmeta, attachments to needs-patch image-editor postmeta attachments

comment:4 azaozz4 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [12163]) Fix image meta after editing image, disable the Save button when no changes, fixes #11115

Note: See TracTickets for help on using tickets.