Make WordPress Core

Opened 6 years ago

Closed 4 years ago

#42466 closed defect (bug) (fixed)

HTTP status code is wrong on setup error

Reported by: linyows's profile linyows Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: 2nd-opinion has-patch
Focuses: administration Cc:

Description

Since setup error and http status are not matched, it is necessary to correct it.

Attachments (1)

setup-config.php.patch (964 bytes) - added by linyows 6 years ago.

Download all attachments as: .zip

Change History (7)

#1 @linyows
6 years ago

  • Type changed from enhancement to defect (bug)

#2 @dd32
6 years ago

  • Keywords 2nd-opinion added

A 409 doesn't seem like the correct code here - The 4xx series of codes are a "Client error" (ie. incorrect data sent) which isn't the case here.

A 500 error seems to fit best when looking through the various codes, although a 200 is possibly also the correct response here. The error is a "Sorry, but this isn't usable right now, it looks like your server is already configured" (which makes it sound like a 403 would be correct, but that would also be incorrect as it's not a client error)

#3 @ocean90
6 years ago

  • Keywords has-patch added
  • Version trunk deleted

The 409 (Conflict) status code indicates that the request could not be completed due to a conflict with the current state of the target resource. This code is used in situations where the user might be able to resolve the conflict and resubmit the request. The server SHOULD generate a payload that includes enough information for a user to recognize the source of the conflict.
https://tools.ietf.org/html/rfc7231#section-6.5.8

Based on the definition I think it's actually an appropriate code.

#4 @linyows
6 years ago

I think the server side detects client duplication as it detects file duplication. If the user runs the installer again it is obviously a client error. Also, I think that it is more programmable to match these errors with the message being returned than to put them together as a 500 error.

#5 @SergeyBiryukov
4 years ago

  • Component changed from General to Upgrade/Install
  • Milestone changed from Awaiting Review to 5.5
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#6 @SergeyBiryukov
4 years ago

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

In 47478:

Upgrade/Install: Return a more appropriate HTTP response status code (409 Conflict) if the wp-config.php file already exists.

Props linyows, ocean90.
Fixes #42466.

Note: See TracTickets for help on using tickets.