Merge "Switched upload chunk status store to the main object stash"
[lhc/web/wiklou.git] / includes / OutputPage.php
index b3720a4..e832b82 100644 (file)
@@ -617,7 +617,8 @@ class OutputPage extends ContextSource {
                        $module = $resourceLoader->getModule( $val );
 
                        if ( $module instanceof ResourceLoaderModule && $module->isPositionDefault() ) {
-                               $warning = __METHOD__ . ': style module should define its position explicitly: ' . $val . ' ' . get_class( $module );
+                               $warning = __METHOD__ . ': style module should define its position explicitly: ' .
+                                       $val . ' ' . get_class( $module );
                                wfDebugLog( 'resourceloader', $warning );
                                wfLogWarning( $warning );
                        }
@@ -2281,7 +2282,6 @@ class OutputPage extends ContextSource {
                if ( $this->mArticleBodyOnly ) {
                        echo $this->mBodytext;
                } else {
-
                        $sk = $this->getSkin();
                        // add skin specific modules
                        $modules = $sk->getDefaultModules();
@@ -3440,12 +3440,12 @@ class OutputPage extends ContextSource {
                                                'href' => $this->getTitle()->getLocalURL( array( 'variant' => $_v ) ) )
                                        );
                                }
+                               # x-default link per https://support.google.com/webmasters/answer/189077?hl=en
+                               $tags["variant-x-default"] = Html::element( 'link', array(
+                                       'rel' => 'alternate',
+                                       'hreflang' => 'x-default',
+                                       'href' => $this->getTitle()->getLocalURL() ) );
                        }
-                       # x-default link per https://support.google.com/webmasters/answer/189077?hl=en
-                       $tags["variant-x-default"] = Html::element( 'link', array(
-                               'rel' => 'alternate',
-                               'hreflang' => 'x-default',
-                               'href' => $this->getTitle()->getLocalURL() ) );
                }
 
                # Copyright
@@ -3524,8 +3524,25 @@ class OutputPage extends ContextSource {
                        if ( $canonicalUrl !== false ) {
                                $canonicalUrl = wfExpandUrl( $canonicalUrl, PROTO_CANONICAL );
                        } else {
-                               $reqUrl = $this->getRequest()->getRequestURL();
-                               $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL );
+                               if ( $this->isArticleRelated() ) {
+                                       // This affects all requests where "setArticleRelated" is true. This is
+                                       // typically all requests that show content (query title, curid, oldid, diff),
+                                       // and all wikipage actions (edit, delete, purge, info, history etc.).
+                                       // It does not apply to File pages and Special pages.
+                                       // 'history' and 'info' actions address page metadata rather than the page
+                                       // content itself, so they may not be canonicalized to the view page url.
+                                       // TODO: this ought to be better encapsulated in the Action class.
+                                       $action = Action::getActionName( $this->getContext() );
+                                       if ( in_array( $action, array( 'history', 'info' ) ) ) {
+                                               $query = "action={$action}";
+                                       } else {
+                                               $query = '';
+                                       }
+                                       $canonicalUrl = $this->getTitle()->getCanonicalURL( $query );
+                               } else {
+                                       $reqUrl = $this->getRequest()->getRequestURL();
+                                       $canonicalUrl = wfExpandUrl( $reqUrl, PROTO_CANONICAL );
+                               }
                        }
                }
                if ( $canonicalUrl !== false ) {
@@ -3942,6 +3959,7 @@ class OutputPage extends ContextSource {
                        'oojs-ui.styles.icons',
                        'oojs-ui.styles.indicators',
                        'oojs-ui.styles.textures',
+                       'mediawiki.widgets.styles',
                ) );
        }
 }