Give a 200 response for valid user pages
authorRyan Lane <rlane@wikimedia.org>
Thu, 21 Feb 2013 22:45:57 +0000 (14:45 -0800)
committerParent5446 <tylerromeo@gmail.com>
Fri, 22 Feb 2013 00:49:39 +0000 (00:49 +0000)
Rather than sending a 404 on empty user pages, send a 200 response.
It's ideal to use the user's page as an OpenID identity url, but
OpenID expects 200 responses on identity urls. If we send 404s on
empty user pages it's necessary for all users to have content on
their pages to use Wikimedia as a provider. This change eliminates
that requirement.

Fixes: bug 45241
Change-Id: I527aa9d9c19c5cef7bebde78ef22f426bcbb3cd6

includes/Article.php

index 1dc27a7..ed9c305 100644 (file)
@@ -1089,6 +1089,7 @@ class Article implements Page {
        public function showMissingArticle() {
                global $wgSend404Code;
                $outputPage = $this->getContext()->getOutput();
+               $validUserPage = false;
 
                # Show info in user (talk) namespace. Does the user exist? Is he blocked?
                if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) {
@@ -1115,6 +1116,9 @@ class Article implements Page {
                                                )
                                        )
                                );
+                               $validUserPage = true;
+                       } else {
+                               $validUserPage = true;
                        }
                }
 
@@ -1128,7 +1132,7 @@ class Article implements Page {
                                'msgKey' => array( 'moveddeleted-notice' ) )
                );
 
-               if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) {
+               if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
                        // If there's no backing content, send a 404 Not Found
                        // for better machine handling of broken links.
                        $this->getContext()->getRequest()->response()->header( "HTTP/1.1 404 Not Found" );