Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#55367 closed defect (bug) (fixed)

Requests to the media/edit endpoint are returning a 500 status

Reported by: talldanwp's profile talldanwp Owned by: hellofromtonya's profile hellofromTonya
Milestone: 6.0 Priority: normal
Severity: normal Version: 6.0
Component: REST API Keywords: has-patch has-unit-tests commit
Focuses: Cc:

Description

The Gutenberg e2e tests seem to have caught a bug with the media/edit endpoint.

The endpoint is now returning a 500 status for most use cases.

Creating a ticket here as I was able to ascertain that it works on a past commit of wordpress-develop, but is broken on the latest commit, so it's not a Gutenberg bug.

To reproduce:

  1. Open the browser dev tools to the network tab
  2. In the post editor, add an image block and upload an image
  3. Select ‘Crop’ from the toolbar and adjust the zoom on the image
  4. Click ‘Apply’
  5. Observe that the request to the media endpoint returns a 500 status

Attachments (1)

55367-before-after-pr-2400.jpg (50.9 KB) - added by costdev 3 years ago.
Before / After PR 2400

Download all attachments as: .zip

Change History (16)

#2 @peterwilsoncc
3 years ago

  • Milestone changed from Awaiting Review to 6.0

This ticket was mentioned in Slack in #core-editor by talldanwp. View the logs.


3 years ago

This ticket was mentioned in Slack in #core-editor by zieladam. View the logs.


3 years ago

This ticket was mentioned in PR #2400 on WordPress/wordpress-develop by spacedmonkey.


3 years ago
#5

  • Keywords has-patch has-unit-tests added; needs-patch removed

#6 @spacedmonkey
3 years ago

Worked out the issue. Was getting a function does not exist message. Moving the function to functions.php seems to do the trick. Also makes sense to live there, this function is useful everywhere.

This ticket was mentioned in Slack in #core-test by spacedmonkey. View the logs.


3 years ago

#8 @costdev
3 years ago

Test Report

Env

  • Web Server: Apache (Linux)
  • WordPress: 6.0-alpha-52448-src
  • Browser: Chrome
  • OS: Windows 10
  • Theme: Twenty Twenty-Two
  • Plugins: None activated.

Steps to test

  1. Open the browser dev tools to the Network tab.
  2. In the post editor, add an image block and upload an image.
  3. Select Crop from the toolbar and adjust the zoom on the image.
  4. Click Apply.
  5. Observe that the request to the media endpoint returns a 500 status.
  6. Apply PR 2400
  7. Observe that the request to the media endpoint no longer returns a 500 status.

Results

  1. Before PR 2400: Received a 500 status.
  2. After PR 2400: Did not receive a 500 status.

PR resolves the issue. 👍

@costdev
3 years ago

Before / After PR 2400

This ticket was mentioned in Slack in #core-editor by mamaduka. View the logs.


3 years ago

This ticket was mentioned in Slack in #core-editor by get_dave. View the logs.


3 years ago

#11 @antonvlasenko
3 years ago

Test Report

Web Server: Apache
WordPress: 6.0-alpha
Browser: Chrome 99
OS: macOS 12.2.1
Theme: Twenty Twenty-Two
Plugins: None.

Steps to test:

  1. Open the browser dev tools to the network tab.
  2. In the post editor, add an image block and upload an image.
  3. Select ‘Crop’ from the toolbar and adjust the zoom on the image.
  4. Click ‘Apply’.
  5. Observe that the request to the media endpoint returns a 500 status code.
  6. Apply 2400
  7. Repeat steps 1-4.
  8. Observe that the request ended successfully (200 status code).

Before:
https://cldup.com/k3sr3UYtb0.png

After:
https://cldup.com/MiVoBtdmnB.png

The proposed PR fixes the issue and therefore it should be merged.

Last edited 3 years ago by antonvlasenko (previous) (diff)

#12 @costdev
3 years ago

  • Keywords commit added

Thanks for adding your test report @antonvlasenko!

Marking for commit consideration.

#13 @hellofromTonya
3 years ago

  • Owner set to hellofromTonya
  • Status changed from new to reviewing

Thank you @costdev @antonvlasenko for testing and test reports. Thank you @spacedmonkey for the PR.

Assigning to me for commit.

#14 @hellofromTonya
3 years ago

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

In 52932:

Media: Relocate wp_filesize() function for use in frontend and backend.

A new function wp_filesize() was added with [52837]. The function lived in the wp-admin/includes/file.php file. However, this admin specific function is not loaded into memory when hitting media/edit endpoint. The result was a 500 Internal Server Error. Why? The function is invoked with that endpoint, but the function does not exist in memory.

This commit relocates the new function to the wp-includes/functions.php file. In doing so, the function is available for both the frontend and backend.

Follow-up to [52837].

Props talldanwp, spacedmonkey, costdev, antonvlasenko.
Fixes #55367.

Note: See TracTickets for help on using tickets.