Index: trunk/phase3/includes/OutputPage.php |
— | — | @@ -50,8 +50,8 @@ |
51 | 51 | |
52 | 52 | private $mIndexPolicy = 'index'; |
53 | 53 | private $mFollowPolicy = 'follow'; |
54 | | - private $mVaryHeader = array( 'Accept-Encoding', 'Cookie' ); |
55 | | - private $mXVOHeader = array( 'Accept-Encoding' => array('list-contains=gzip') ); |
| 54 | + private $mVaryHeader = array( 'Accept-Encoding' => array('list-contains=gzip'), |
| 55 | + 'Cookie' => null ); |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Constructor |
— | — | @@ -807,26 +807,21 @@ |
808 | 808 | return false; |
809 | 809 | } |
810 | 810 | |
811 | | - public function addXVOHeader( $header, $option = null ) { |
812 | | - if ( !array_key_exists( $header, $this->mXVOHeader ) ) { |
813 | | - $this->mXVOHeader[$header] = $option; |
| 811 | + public function addVaryHeader( $header, $option = null ) { |
| 812 | + if ( !array_key_exists( $header, $this->mVaryHeader ) ) { |
| 813 | + $this->mVaryHeader[$header] = $option; |
814 | 814 | } |
815 | 815 | elseif( is_array( $option ) ) { |
816 | | - if( is_array( $this->mXVOHeader[$header] ) ) { |
817 | | - $this->mXVOHeader[$header] = array_merge( $this->mXVOHeader[$header], $option ); |
| 816 | + if( is_array( $this->mVaryHeader[$header] ) ) { |
| 817 | + $this->mVaryHeader[$header] = array_merge( $this->mVaryHeader[$header], $option ); |
818 | 818 | } |
819 | 819 | else { |
820 | | - $this->mXVOHeader[$header] = $option; |
| 820 | + $this->mVaryHeader[$header] = $option; |
821 | 821 | } |
822 | 822 | } |
| 823 | + $this->mVaryHeader[$header] = array_unique( $this->mVaryHeader[$header] ); |
823 | 824 | } |
824 | 825 | |
825 | | - public function addVaryHeader( $header ) { |
826 | | - if ( !in_array( $header, $this->mVaryHeader ) ) { |
827 | | - $this->mVaryHeader[] = $header; |
828 | | - } |
829 | | - } |
830 | | - |
831 | 826 | /** Get a complete X-Vary-Options header */ |
832 | 827 | public function getXVO() { |
833 | 828 | $cvCookies = $this->getCacheVaryCookies(); |
— | — | @@ -835,10 +830,10 @@ |
836 | 831 | foreach ( $cvCookies as $cookieName ) { |
837 | 832 | $cookiesOption[] = 'string-contains=' . $cookieName; |
838 | 833 | } |
839 | | - $this->addXVOHeader( 'Cookie', $cookiesOption ); |
| 834 | + $this->addVaryHeader( 'Cookie', $cookiesOption ); |
840 | 835 | |
841 | 836 | $headers = array(); |
842 | | - foreach( $this->mXVOHeader as $header => $option ) { |
| 837 | + foreach( $this->mVaryHeader as $header => $option ) { |
843 | 838 | $newheader = $header; |
844 | 839 | if( is_array( $option ) ) |
845 | 840 | $newheader .= ';' . implode( ';', $option ); |
— | — | @@ -858,7 +853,7 @@ |
859 | 854 | |
860 | 855 | # don't serve compressed data to clients who can't handle it |
861 | 856 | # maintain different caches for logged-in users and non-logged in ones |
862 | | - $response->header( 'Vary: ' . join( ', ', $this->mVaryHeader ) ); |
| 857 | + $response->header( 'Vary: ' . join( ', ', array_keys( $this->mVaryHeader ) ) ); |
863 | 858 | |
864 | 859 | if ( $wgUseXVO ) { |
865 | 860 | # Add an X-Vary-Options header for Squid with Wikimedia patches |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -197,7 +197,9 @@ |
198 | 198 | */ |
199 | 199 | function handleSpecialCases( &$title, &$output, $request ) { |
200 | 200 | wfProfileIn( __METHOD__ ); |
| 201 | + global $wgContLang, $wgUser; |
201 | 202 | $action = $this->getVal( 'Action' ); |
| 203 | + $perferred = $wgContLang->getPreferredVariant( false ); |
202 | 204 | // Invalid titles |
203 | 205 | if( is_null($title) || $title->getDBkey() == '' ) { |
204 | 206 | $title = SpecialPage::getTitleFor( 'Badtitle' ); |
— | — | @@ -222,7 +224,9 @@ |
223 | 225 | } |
224 | 226 | // Redirect loops, no title in URL, $wgUsePathInfo URLs |
225 | 227 | } else if( $action == 'view' && !$request->wasPosted() && |
226 | | - ( !isset($this->GET['title']) || $title->getPrefixedDBKey() != $this->GET['title'] ) && |
| 228 | + ( ( !isset($this->GET['title']) || $title->getPrefixedDBKey() != $this->GET['title'] ) || |
| 229 | + ( !isset($this->GET['variant']) && $perferred != $wgContLang->getCode() && |
| 230 | + $wgContLang->hasVariants() && !$wgUser->isLoggedIn() ) ) && |
227 | 231 | !count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) ) |
228 | 232 | { |
229 | 233 | $targetUrl = $title->getFullURL(); |
Index: trunk/phase3/includes/Title.php |
— | — | @@ -733,7 +733,7 @@ |
734 | 734 | |
735 | 735 | $interwiki = Interwiki::fetch( $this->mInterwiki ); |
736 | 736 | if ( !$interwiki ) { |
737 | | - $url = $this->getLocalUrl( $query, $variant ); |
| 737 | + $url = $this->getLocalURL( $query, $variant ); |
738 | 738 | |
739 | 739 | // Ugly quick hack to avoid duplicate prefixes (bug 4571 etc) |
740 | 740 | // Correct fix would be to move the prepending elsewhere. |
Index: trunk/phase3/languages/LanguageConverter.php |
— | — | @@ -240,11 +240,8 @@ |
241 | 241 | // ONLY add Accept-Language when a variant has been found out |
242 | 242 | // thanks to Liangent's help |
243 | 243 | if( $ret_language !== $this->mMainLanguageCode ) { |
244 | | - global $wgOut, $wgUseXVO; |
245 | | - $wgOut->addVaryHeader( 'Accept-Language' ); |
246 | | - if( $wgUseXVO ) { |
247 | | - $wgOut->addXVOHeader( 'Accept-Language', array($ret_language) ); |
248 | | - } |
| 244 | + global $wgOut; |
| 245 | + $wgOut->addVaryHeader( 'Accept-Language', array('string-contains=' .$ret_language) ); |
249 | 246 | } |
250 | 247 | return $ret_language; |
251 | 248 | } |