jenkins-bot has submitted this change and it was merged.

Change subject: Register WikiLove parts of 'ext.pageTriage.views.toolbar' 
conditionally
......................................................................


Register WikiLove parts of 'ext.pageTriage.views.toolbar' conditionally

Register JS and CSS conditionally, only if WikiLove is present.

This ensures that there will never be missing messages registered,
and also fixes a CI error (though for CI we should load WikiLove
anyway).

Bug: T145798
Change-Id: I7c5ee1127963108e97298cc46d59fbac82514f10
---
M PageTriage.hooks.php
M PageTriage.php
2 files changed, 150 insertions(+), 131 deletions(-)

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



diff --git a/PageTriage.hooks.php b/PageTriage.hooks.php
index 6e30285..28d7339 100755
--- a/PageTriage.hooks.php
+++ b/PageTriage.hooks.php
@@ -467,10 +467,12 @@
                        $wgTalkPageNoteTemplate;
 
                // check if WikiLove is enabled
-               if ( !class_exists( 'ApiWikiLove' ) ) {
-                       if ( array_key_exists( 'wikiLove', 
$wgPageTriageCurationModules ) ) {
-                               unset( $wgPageTriageCurationModules['wikiLove'] 
);
-                       }
+               if ( ExtensionRegistry::getInstance()->isLoaded( 'WikiLove' ) ) 
{
+                       $wgPageTriageCurationModules['wikiLove'] = [
+                               // depends on WikiLove extension
+                               'helplink' => 
'//en.wikipedia.org/wiki/Wikipedia:Page_Curation/Help#WikiLove',
+                               'namespace' => [ NS_MAIN, NS_USER ],
+                       ];
                }
 
                $vars['wgPageTriageCurationModules'] = 
$wgPageTriageCurationModules;
@@ -480,6 +482,149 @@
        }
 
        /**
+        * Register modules that depend on other state
+        *
+        * @param ResourceLoader &$resourceLoader
+        * @return bool true
+        */
+       public static function onResourceLoaderRegisterModules( 
&$resourceLoader ) {
+               $template = [
+                       'localBasePath' => __DIR__. '/modules',
+                       'remoteExtPath' => 'PageTriage/modules'
+               ];
+
+               $module = $template + [
+                       'dependencies' => [
+                               'mediawiki.jqueryMsg',
+                               'ext.pageTriage.models',
+                               'ext.pageTriage.util',
+                               'jquery.badge',
+                               'jquery.ui.button',
+                               'jquery.ui.draggable',
+                               'jquery.spinner',
+                               'jquery.client',
+                               'ext.pageTriage.externalTagsOptions',
+                               'ext.pageTriage.externalDeletionTagsOptions'
+                       ],
+                       'scripts' => [
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.toolView.js', // abstract class 
first
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.articleInfo.js', // article 
metadata
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.minimize.js', // minimize
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.tags.js', // tagging
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.mark.js', // mark as reviewed
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.next.js', // next article
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.delete.js', // mark for deletion
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.toolbarView.js', // overall 
toolbar view last
+                               'external/jquery.effects.core.js',
+                               'external/jquery.effects.squish.js',
+                       ],
+                       'styles' => [
+                               'ext.pageTriage.css', // stuff that's shared 
across all views
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.toolbarView.css',
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.toolView.css',
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.articleInfo.css',
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.mark.css',
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.tags.css',
+                               
'ext.pageTriage.views.toolbar/ext.pageTriage.delete.css'
+                       ],
+                       'messages' => [
+                               'pagetriage-creation-dateformat',
+                               'pagetriage-user-creation-dateformat',
+                               'pagetriage-mark-as-reviewed',
+                               'pagetriage-mark-as-unreviewed',
+                               'pagetriage-info-title',
+                               'pagetriage-byline',
+                               'pagetriage-byline-new-editor',
+                               'pagetriage-articleinfo-byline',
+                               'pagetriage-articleinfo-byline-new-editor',
+                               'pipe-separator',
+                               'pagetriage-edits',
+                               'pagetriage-editcount',
+                               'pagetriage-author-bot',
+                               'pagetriage-no-author',
+                               'pagetriage-info-problem-header',
+                               'pagetriage-info-history-header',
+                               'pagetriage-info-history-show-full',
+                               'pagetriage-info-help',
+                               'pagetriage-info-no-problems',
+                               'pagetriage-info-problem-non-autoconfirmed',
+                               
'pagetriage-info-problem-non-autoconfirmed-desc',
+                               'pagetriage-info-problem-blocked',
+                               'pagetriage-info-problem-blocked-desc',
+                               'pagetriage-info-problem-no-categories',
+                               'pagetriage-info-problem-no-categories-desc',
+                               'pagetriage-info-problem-orphan',
+                               'pagetriage-info-problem-orphan-desc',
+                               'pagetriage-info-problem-no-references',
+                               'pagetriage-info-problem-no-references-desc',
+                               'pagetriage-info-timestamp-date-format',
+                               'pagetriage-info-timestamp-time-format',
+                               'pagetriage-info-tooltip',
+                               'pagetriage-toolbar-collapsed',
+                               'pagetriage-toolbar-linktext',
+                               'pagetriage-toolbar-learn-more',
+                               'pagetriage-mark-as-reviewed-helptext',
+                               'pagetriage-mark-as-unreviewed-helptext',
+                               'pagetriage-mark-as-reviewed-error',
+                               'pagetriage-mark-as-unreviewed-error',
+                               'pagetriage-markpatrolled',
+                               'pagetriage-markunpatrolled',
+                               'pagetriage-note-reviewed',
+                               'pagetriage-note-not-reviewed',
+                               'pagetriage-note-deletion',
+                               'pagetriage-next-tooltip',
+                               'sp-contributions-talk',
+                               'contribslink',
+                               'comma-separator',
+                               'unknown-error',
+                               'pagetriage-add-a-note-creator',
+                               'pagetriage-add-a-note-reviewer',
+                               'pagetriage-characters-left',
+                               'pagetriage-personal-default-note',
+                               'pagetriage-special-contributions',
+                               'pagetriage-tagging-error',
+                               'pagetriage-del-log-page-missing-error',
+                               'pagetriage-del-log-page-adding-error',
+                               'pagetriage-del-talk-page-notify-error',
+                               'pagetriage-del-discussion-page-adding-error',
+                               'pagetriage-page-status-reviewed',
+                               'pagetriage-page-status-reviewed-anonymous',
+                               'pagetriage-page-status-unreviewed',
+                               'pagetriage-page-status-autoreviewed',
+                               'pagetriage-page-status-delete',
+                               'pagetriage-dot-separator',
+                               'pagetriage-articleinfo-stat',
+                               'pagetriage-bytes',
+                               'pagetriage-edits',
+                               'pagetriage-categories',
+                               'pagetriage-add-tag-confirmation',
+                               'pagetriage-tags-note-edit-summary',
+                               'pagetriage-del-talk-page-notify-summary',
+                               'pagetriage-tag-deletion-error',
+                               'pagetriage-toolbar-close',
+                               'pagetriage-toolbar-minimize',
+                               'pagetriage-tag-warning-notice'
+                       ]
+               ];
+
+               if ( ExtensionRegistry::getInstance()->isLoaded( 'WikiLove' ) ) 
{
+                       $module['scripts'][] = 
'ext.pageTriage.views.toolbar/ext.pageTriage.wikilove.js';
+                       $module['styles'][] = 
'ext.pageTriage.views.toolbar/ext.pageTriage.wikilove.css';
+                       $module['messages'] = array_merge( $module['messages'], 
[
+                               'pagetriage-wikilove-page-creator',
+                               'pagetriage-wikilove-edit-count',
+                               'pagetriage-wikilove-helptext',
+                               'pagetriage-wikilove-no-recipients',
+                               'pagetriage-wikilove-tooltip',
+                               'wikilove',
+                               'wikilove-button-send',
+                       ] );
+               }
+
+               $resourceLoader->register( 'ext.pageTriage.views.toolbar', 
$module );
+       }
+
+       /**
         * Add PageTriage events to Echo
         *
         * @param $notifications array a list of enabled echo events
diff --git a/PageTriage.php b/PageTriage.php
index 8197504..b62184a 100644
--- a/PageTriage.php
+++ b/PageTriage.php
@@ -74,11 +74,6 @@
                'helplink' => 
'//en.wikipedia.org/wiki/Wikipedia:Page_Curation/Help#PageInfo',
                'namespace' => [ NS_MAIN, NS_USER ],
        ],
-       'wikiLove' => [
-               // depends on WikiLove extension
-               'helplink' => 
'//en.wikipedia.org/wiki/Wikipedia:Page_Curation/Help#WikiLove',
-               'namespace' => [ NS_MAIN, NS_USER ],
-       ],
        'mark' => [
                'helplink' => 
'//en.wikipedia.org/wiki/Wikipedia:Page_Curation/Help#MarkReviewed',
                'namespace' => [ NS_MAIN, NS_USER ],
@@ -185,6 +180,7 @@
 $wgHooks['EchoGetDefaultNotifiedUsers'][] = 
'PageTriageHooks::onEchoGetDefaultNotifiedUsers';
 $wgHooks['LocalUserCreated'][] = 'PageTriageHooks::onLocalUserCreated';
 $wgHooks['UserMergeAccountFields'][] = 
'PageTriageHooks::onUserMergeAccountFields';
+$wgHooks['ResourceLoaderRegisterModules'][] 
='PageTriageHooks::onResourceLoaderRegisterModules';
 
 // logging
 $wgLogTypes[] = 'pagetriage-curation';
@@ -633,128 +629,6 @@
                'pagetriage-info-timestamp-date-format',
                'pagetriage-no-reference',
                'pagetriage-stats-filter-page-count'
-       ]
-];
-
-$wgResourceModules['ext.pageTriage.views.toolbar'] = $ptResourceTemplate + [
-       'dependencies' => [
-               'mediawiki.jqueryMsg',
-               'ext.pageTriage.models',
-               'ext.pageTriage.util',
-               'jquery.badge',
-               'jquery.ui.button',
-               'jquery.ui.draggable',
-               'jquery.spinner',
-               'jquery.client',
-               'ext.pageTriage.externalTagsOptions',
-               'ext.pageTriage.externalDeletionTagsOptions'
-       ],
-       'scripts' => [
-               'ext.pageTriage.views.toolbar/ext.pageTriage.toolView.js', // 
abstract class first
-               'ext.pageTriage.views.toolbar/ext.pageTriage.articleInfo.js', 
// article metadata
-               'ext.pageTriage.views.toolbar/ext.pageTriage.minimize.js', // 
minimize
-               'ext.pageTriage.views.toolbar/ext.pageTriage.tags.js', // 
tagging
-               'ext.pageTriage.views.toolbar/ext.pageTriage.mark.js', // mark 
as reviewed
-               'ext.pageTriage.views.toolbar/ext.pageTriage.next.js', // next 
article
-               'ext.pageTriage.views.toolbar/ext.pageTriage.delete.js', // 
mark for deletion
-               'ext.pageTriage.views.toolbar/ext.pageTriage.wikilove.js', // 
mark for deletion
-               'ext.pageTriage.views.toolbar/ext.pageTriage.toolbarView.js', 
// overall toolbar view last
-               'external/jquery.effects.core.js',
-               'external/jquery.effects.squish.js',
-       ],
-       'styles' => [
-               'ext.pageTriage.css', // stuff that's shared across all views
-               'ext.pageTriage.views.toolbar/ext.pageTriage.toolbarView.css',
-               'ext.pageTriage.views.toolbar/ext.pageTriage.toolView.css',
-               'ext.pageTriage.views.toolbar/ext.pageTriage.articleInfo.css',
-               'ext.pageTriage.views.toolbar/ext.pageTriage.mark.css',
-               'ext.pageTriage.views.toolbar/ext.pageTriage.tags.css',
-               'ext.pageTriage.views.toolbar/ext.pageTriage.wikilove.css',
-               'ext.pageTriage.views.toolbar/ext.pageTriage.delete.css'
-       ],
-       'messages' => [
-               'pagetriage-creation-dateformat',
-               'pagetriage-user-creation-dateformat',
-               'pagetriage-mark-as-reviewed',
-               'pagetriage-mark-as-unreviewed',
-               'pagetriage-info-title',
-               'pagetriage-byline',
-               'pagetriage-byline-new-editor',
-               'pagetriage-articleinfo-byline',
-               'pagetriage-articleinfo-byline-new-editor',
-               'pipe-separator',
-               'pagetriage-edits',
-               'pagetriage-editcount',
-               'pagetriage-author-bot',
-               'pagetriage-no-author',
-               'pagetriage-info-problem-header',
-               'pagetriage-info-history-header',
-               'pagetriage-info-history-show-full',
-               'pagetriage-info-help',
-               'pagetriage-info-no-problems',
-               'pagetriage-info-problem-non-autoconfirmed',
-               'pagetriage-info-problem-non-autoconfirmed-desc',
-               'pagetriage-info-problem-blocked',
-               'pagetriage-info-problem-blocked-desc',
-               'pagetriage-info-problem-no-categories',
-               'pagetriage-info-problem-no-categories-desc',
-               'pagetriage-info-problem-orphan',
-               'pagetriage-info-problem-orphan-desc',
-               'pagetriage-info-problem-no-references',
-               'pagetriage-info-problem-no-references-desc',
-               'pagetriage-info-timestamp-date-format',
-               'pagetriage-info-timestamp-time-format',
-               'pagetriage-info-tooltip',
-               'pagetriage-toolbar-collapsed',
-               'pagetriage-toolbar-linktext',
-               'pagetriage-toolbar-learn-more',
-               'pagetriage-mark-as-reviewed-helptext',
-               'pagetriage-mark-as-unreviewed-helptext',
-               'pagetriage-mark-as-reviewed-error',
-               'pagetriage-mark-as-unreviewed-error',
-               'pagetriage-markpatrolled',
-               'pagetriage-markunpatrolled',
-               'pagetriage-note-reviewed',
-               'pagetriage-note-not-reviewed',
-               'pagetriage-note-deletion',
-               'pagetriage-wikilove-page-creator',
-               'pagetriage-wikilove-edit-count',
-               'pagetriage-wikilove-helptext',
-               'pagetriage-wikilove-tooltip',
-               'pagetriage-next-tooltip',
-               'wikilove',
-               'wikilove-button-send',
-               'sp-contributions-talk',
-               'contribslink',
-               'comma-separator',
-               'unknown-error',
-               'pagetriage-add-a-note-creator',
-               'pagetriage-add-a-note-reviewer',
-               'pagetriage-characters-left',
-               'pagetriage-personal-default-note',
-               'pagetriage-special-contributions',
-               'pagetriage-tagging-error',
-               'pagetriage-del-log-page-missing-error',
-               'pagetriage-del-log-page-adding-error',
-               'pagetriage-del-talk-page-notify-error',
-               'pagetriage-del-discussion-page-adding-error',
-               'pagetriage-page-status-reviewed',
-               'pagetriage-page-status-reviewed-anonymous',
-               'pagetriage-page-status-unreviewed',
-               'pagetriage-page-status-autoreviewed',
-               'pagetriage-page-status-delete',
-               'pagetriage-dot-separator',
-               'pagetriage-articleinfo-stat',
-               'pagetriage-bytes',
-               'pagetriage-edits',
-               'pagetriage-categories',
-               'pagetriage-add-tag-confirmation',
-               'pagetriage-tags-note-edit-summary',
-               'pagetriage-del-talk-page-notify-summary',
-               'pagetriage-tag-deletion-error',
-               'pagetriage-toolbar-close',
-               'pagetriage-toolbar-minimize',
-               'pagetriage-tag-warning-notice'
        ]
 ];
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7c5ee1127963108e97298cc46d59fbac82514f10
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/PageTriage
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org>
Gerrit-Reviewer: Reedy <re...@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