Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#31224 closed defect (bug) (fixed)

maybe_add_existing_user_to_blog() returns http response 500 even on success

Reported by: drzaphod's profile drzaphod Owned by: jeremyfelt's profile jeremyfelt
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.1
Component: Users Keywords: has-patch
Focuses: multisite Cc:

Description (last modified by TobiasBg)

File: wp-includes/ms-functions.php
Function: maybe_add_existing_user_to_blog()
Line: 1938

Calling this function will return HTTP 500 (Server Error) even when the function succeeds. This can cause problems when a caching server such as Varnish reacts unfavorably to the 500 and redirects the user to a sorry page.

Replace line 1938 with the following to correct.

wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ), array( 'response' => 200 ) );

Attachments (2)

31224.diff (1.7 KB) - added by MikeHansenMe 10 years ago.
31224.2.diff (1.7 KB) - added by MikeHansenMe 10 years ago.

Download all attachments as: .zip

Change History (8)

#1 @TobiasBg
10 years ago

  • Description modified (diff)
  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 4.2

@MikeHansenMe
10 years ago

#2 @MikeHansenMe
10 years ago

  • Keywords has-patch added; needs-patch removed

#3 @TobiasBg
10 years ago

Thanks, @MikeHansenMe. Should we maybe add the same response code to the other wp_die() call as well? It also appears to be a legit user-facing error message.

#4 @MikeHansenMe
10 years ago

Good call @TobiasBg

#5 @jeremyfelt
10 years ago

  • Focuses multisite added

Thanks for the report @drzaphod!

I think we can stick to only adding a 200 response to the success message in 31224.diff. Keeping the default as 500 for the actual error matches many other cases in core right now.

#6 @jeremyfelt
10 years ago

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

In 31514:

Use response code 200 when an existing network user joins a site via invitation.

Pass a response code of 200 to wp_die() when a user is successfully added to an individual site after using the /newbloguser/ URL from an invite email. This is a user facing success message.

Props MikeHansenMe.

Fixes #31224.

Note: See TracTickets for help on using tickets.