jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/355637 )

Change subject: Breaking change: Remove Sidebar code from RelatedArticles
......................................................................


Breaking change: Remove Sidebar code from RelatedArticles

RelatedArticles will now only render related articles in the footer of
skins.

Bump version to 3.0.0

Bug: T165991
Change-Id: Ia4e28c0ed76b3aff37c0aea8eb713923312ba23c
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/FooterHooks.php
D includes/SidebarHooks.php
M tests/browser/LocalSettings.php
6 files changed, 2 insertions(+), 134 deletions(-)

Approvals:
  Pmiazga: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 34e4872..21f4c85 100644
--- a/extension.json
+++ b/extension.json
@@ -1,6 +1,6 @@
 {
        "name": "RelatedArticles",
-       "version": "2.1.0",
+       "version": "3.0.0",
        "author": [
                "Roland Unger",
                "Hans Musil",
@@ -14,7 +14,6 @@
        "AutoloadClasses": {
                "RelatedArticles\\ResourceLoaderMuHoganModule": 
"includes/ResourceLoaderMuhoganModule.php",
                "RelatedArticles\\Hooks": "includes/Hooks.php",
-               "RelatedArticles\\SidebarHooks": "includes/SidebarHooks.php",
                "RelatedArticles\\FooterHooks": "includes/FooterHooks.php"
        },
        "ExtensionMessagesFiles": {
@@ -30,10 +29,6 @@
                ],
                "OutputPageParserOutput": [
                        "RelatedArticles\\Hooks::onOutputPageParserOutput"
-               ],
-
-               "SidebarBeforeOutput": [
-                       "RelatedArticles\\SidebarHooks::onSidebarBeforeOutput"
                ],
 
                "MakeGlobalVariablesScript": [
@@ -164,8 +159,6 @@
        "config": {
                "@RelatedArticlesCardLimit": "Maximum number of articles that 
should be shown in RelatedArticles widget. This limit is derived from limits in 
TextExtracts and PageImages extensions. Number should be between 1 and 20.",
                "RelatedArticlesCardLimit": 3,
-               "RelatedArticlesShowInSidebar": true,
-               "RelatedArticlesShowInFooter": false,
                "RelatedArticlesUseCirrusSearch": false,
                "RelatedArticlesOnlyUseCirrusSearch": false,
                "RelatedArticlesLoggingBucketSize": 0.01,
diff --git a/i18n/en.json b/i18n/en.json
index 58a3897..bf94bc7 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -2,7 +2,6 @@
        "@metadata": {
                "authors": []
        },
-       "relatedarticles-title": "Related pages",
        "relatedarticles-desc": "Adds a link to related pages on the sidebar or 
in the footer, if the user enables the beta feature.",
        "relatedarticles-read-more-heading": "Related pages"
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 9c37aeb..0b22f7f 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -7,7 +7,6 @@
                        "Robby"
                ]
        },
-       "relatedarticles-title": "Title shown on the sidebar",
        "relatedarticles-desc": "{{desc|name=Related 
Articles|url=https://www.mediawiki.org/wiki/Extension:RelatedArticles}}";,
        "relatedarticles-read-more-heading": "The heading of section, added at 
the end of the page, that lists the related pages"
 }
diff --git a/includes/FooterHooks.php b/includes/FooterHooks.php
index f43e8cc..64559af 100644
--- a/includes/FooterHooks.php
+++ b/includes/FooterHooks.php
@@ -89,7 +89,6 @@
         * to the output when:
         *
         * <ol>
-        *   <li><code>$wgRelatedArticlesShowInFooter</code> is truthy</li>
         *   <li>On mobile, the output is being rendered with
         *     <code>SkinMinervaBeta<code></li>
         *   <li>The page is in mainspace</li>
@@ -105,15 +104,10 @@
         * @return bool Always <code>true</code>
         */
        public static function onBeforePageDisplay( OutputPage $out, Skin $skin 
) {
-               $config = MediaWikiServices::getInstance()->getConfigFactory()
-                       ->makeConfig( 'RelatedArticles' );
-               $showReadMore = $config->get( 'RelatedArticlesShowInFooter' );
-
                $title = $out->getContext()->getTitle();
                $action = $out->getRequest()->getText( 'action', 'view' );
 
                if (
-                       $showReadMore &&
                        $title->inNamespace( NS_MAIN ) &&
                        // T120735
                        $action === 'view' &&
diff --git a/includes/SidebarHooks.php b/includes/SidebarHooks.php
deleted file mode 100644
index 2b73e74..0000000
--- a/includes/SidebarHooks.php
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-
-namespace RelatedArticles;
-
-use MediaWiki\MediaWikiServices;
-use Title;
-use Skin;
-use Html;
-use User;
-
-class SidebarHooks {
-
-       /**
-        * Handler for the <code>SidebarBeforeOutput</code> hook.
-        *
-        * Retrieves the list of related pages
-        * and adds its HTML representation to the sidebar if the ReadMore 
feature
-        * is disabled and the beta feature is enabled by the user.
-        *
-        * @param Skin $skin Skin object
-        * @param array &$bar Sidebar contents
-        * @return bool Always <code>true</code>
-        */
-       public static function onSidebarBeforeOutput( Skin $skin, &$bar ) {
-               $out = $skin->getOutput();
-               $relatedPages = $out->getProperty( 'RelatedArticles' );
-
-               if ( !self::isInSidebar( $relatedPages, $out->getUser() ) ) {
-                       return true;
-               }
-
-               $relatedPagesUrls = self::getRelatedPagesUrls( $relatedPages );
-
-               // build relatedarticles <li>'s
-               $relatedPages = [];
-               foreach ( (array)$relatedPagesUrls as $url ) {
-                       $relatedPages[] =
-                               Html::rawElement( 'li', [ 'class' => 
htmlspecialchars( $url['class'] ) ],
-                                       Html::element( 'a', [ 'href' => 
htmlspecialchars( $url['href'] ) ],
-                                               $url['text']
-                                       )
-                               );
-               }
-
-               // build complete html
-               $bar[$skin->msg( 'relatedarticles-title' )->text()] =
-                       Html::rawElement( 'ul', [],
-                               implode( '', $relatedPages )
-                       );
-
-               return true;
-       }
-
-       /**
-        * Generates anchor element attributes for each entry in list of pages.
-        *
-        * The attributes that are generated are: <code>href</code>,
-        * <code>text</code>, and <code>class</code>, with the latter always
-        * set to <code>"interwiki-relart"</code>.
-        *
-        * If the the page is of the form <code>"Foo && Bar"</code>, then
-        * the <code>text</code> attribute will be set to "Bar", otherwise the
-        * page's {@see Title::getPrefixedText prefixed text} will be used.
-        *
-        * @param array[string] $relatedPages
-        * @return array An array of maps, each with <code>href</code>,
-        *  <code>text</code>, and <code>class</code> entries.
-        */
-       private static function getRelatedPagesUrls( array $relatedPages ) {
-               $relatedPagesUrls = [];
-
-               foreach ( $relatedPages as $page ) {
-                       // Tribute to Evan
-                       $page = urldecode( $page );
-
-                       $altText = '';
-                       if ( preg_match( '/\&\&/', $page ) ) {
-                               $parts = array_map( 'trim', explode( '&&', 
$page, 2 ) );
-                               $page = $parts[0];
-                               $altText = $parts[1];
-                       }
-
-                       $title = Title::newFromText( $page );
-                       if ( $title ) {
-                               $relatedPagesUrls[] = [
-                                       'href' => $title->getLocalURL(),
-                                       'text' => $altText ?: 
$title->getPrefixedText(),
-                                       'class' => 'interwiki-relart'
-                               ];
-                       }
-               };
-
-               return $relatedPagesUrls;
-       }
-
-       /**
-        * Check whether there are related articles that can be displayed, or
-        * the ReadMore feature is disabled. The beta feature is used only
-        * for enabling ReadMore, so do not take it into account.
-        *
-        * @param mixed $relatedPages
-        * @param User $user
-        * @return bool
-        * @throws \ConfigException
-        */
-       private static function isInSidebar( $relatedPages, User $user ) {
-               $config = MediaWikiServices::getInstance()->getConfigFactory()
-                       ->makeConfig( 'RelatedArticles' );
-
-               if ( !$relatedPages || !$config->get( 
'RelatedArticlesShowInSidebar' ) ) {
-                       return false;
-               }
-
-               return true;
-       }
-}
diff --git a/tests/browser/LocalSettings.php b/tests/browser/LocalSettings.php
index 968379d..65bc6a2 100644
--- a/tests/browser/LocalSettings.php
+++ b/tests/browser/LocalSettings.php
@@ -1,7 +1,6 @@
 <?php
 
 $wgRelatedArticlesLoggingBucketSize = 1;
-$wgRelatedArticlesShowInFooter = true;
-$wgRelatedArticlesShowInSidebar = true;
+$wgRelatedArticlesLoggingSamplingRate = 1;
 $wgRelatedArticlesUseCirrusSearch = true;
 $wgRelatedArticlesOnlyUseCirrusSearch = false;

-- 
To view, visit https://gerrit.wikimedia.org/r/355637
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia4e28c0ed76b3aff37c0aea8eb713923312ba23c
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/RelatedArticles
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Pmiazga <pmia...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to