jenkins-bot has submitted this change and it was merged. Change subject: Remove param index ......................................................................
Remove param index It's (mostly) unused, and it would become problematic once we have notifications from multiple places (where those ids could conflict) Change-Id: Ib3bb5ae1e5689037b38290c9ce3d8691f52582b0 --- M i18n/en.json M i18n/qqq.json M includes/api/ApiEchoNotifications.php M modules/api/mw.echo.api.APIHandler.js M modules/special/ext.echo.special.js M tests/phpunit/api/ApiEchoNotificationsTest.php 6 files changed, 8 insertions(+), 44 deletions(-) Approvals: Catrope: Looks good to me, approved jenkins-bot: Verified diff --git a/i18n/en.json b/i18n/en.json index 854af07..799829e 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -232,7 +232,6 @@ "apihelp-query+notifications-paramvalue-format-flyout": "<span class=\"apihelp-deprecated\">Deprecated</span>. Use <kbd>$1format=model</kbd> for raw data", "apihelp-query+notifications-paramvalue-format-html": "<span class=\"apihelp-deprecated\">Deprecated</span>. Use <kbd>$1format=model</kbd> for raw data", "apihelp-query+notifications-param-limit": "The maximum number of notifications to return.", - "apihelp-query+notifications-param-index": "If specified, a list of notification IDs, in order, will be returned.", "apihelp-query+notifications-param-noforn": "True to opt out of data about notifications on foreign wikis.", "apihelp-query+notifications-param-alertcontinue": "When more alert results are available, use this to continue.", "apihelp-query+notifications-param-unreadfirst": "Whether to show unread notifications first (only used if groupbysection is not set).", diff --git a/i18n/qqq.json b/i18n/qqq.json index 5bb22f5..39ebbb9 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -223,7 +223,6 @@ "apihelp-query+notifications-paramvalue-format-flyout": "<span class=\"apihelp-deprecated\">Deprecated</span>", "apihelp-query+notifications-paramvalue-format-html": "<span class=\"apihelp-deprecated\">Deprecated</span>", "apihelp-query+notifications-param-limit": "{{doc-apihelp-param|query+notifications|limit}}", - "apihelp-query+notifications-param-index": "{{doc-apihelp-param|query+notifications|index}}", "apihelp-query+notifications-param-noforn": "{{doc-apihelp-param|query+notifications|noforn}}", "apihelp-query+notifications-param-alertcontinue": "{{doc-apihelp-param|query+notifications|alertcontinue}}", "apihelp-query+notifications-param-unreadfirst": "{{doc-apihelp-param|query+notifications|unreadfirst}}", diff --git a/includes/api/ApiEchoNotifications.php b/includes/api/ApiEchoNotifications.php index 4dbed47..5897e27 100644 --- a/includes/api/ApiEchoNotifications.php +++ b/includes/api/ApiEchoNotifications.php @@ -54,11 +54,6 @@ } $this->getResult()->setIndexedTagName( $result[$section]['list'], 'notification' ); - // 'index' is built on top of 'list' - if ( in_array( 'index', $prop ) ) { - $result[$section]['index'] = $this->getPropIndex( $result[$section]['list'] ); - $this->getResult()->setIndexedTagName( $result[$section]['index'], 'id' ); - } } } else { $attributeManager = EchoAttributeManager::newFromGlobalVars(); @@ -79,11 +74,6 @@ } $this->getResult()->setIndexedTagName( $result['list'], 'notification' ); - // 'index' is built on top of 'list' - if ( in_array( 'index', $prop ) ) { - $result['index'] = $this->getPropIndex( $result['list'] ); - $this->getResult()->setIndexedTagName( $result['index'], 'id' ); - } } } @@ -259,23 +249,6 @@ return $result; } - /** - * Internal helper method for getting property 'index' data - * @param array $list - * @return array - */ - protected function getPropIndex( $list ) { - $result = array(); - foreach ( array_keys( $list ) as $key ) { - // Don't include the XML tag name ('_element' key) - if ( $key != '_element' ) { - $result[] = $key; - } - } - - return $result; - } - protected function makeForeignNotification( User $user, $format, EchoForeignNotifications $foreignNotifications, $section = null ) { $wikis = $foreignNotifications->getWikis( $section ); $count = $foreignNotifications->getCount( $section ); @@ -340,7 +313,6 @@ ApiBase::PARAM_TYPE => array( 'list', 'count', - 'index', ), ApiBase::PARAM_DFLT => 'list', ), @@ -371,7 +343,6 @@ ApiBase::PARAM_MAX => ApiBase::LIMIT_SML1, ApiBase::PARAM_MAX2 => ApiBase::LIMIT_SML2, ), - 'index' => false, 'continue' => array( ApiBase::PARAM_HELP_MSG => 'api-help-param-continue', ), diff --git a/modules/api/mw.echo.api.APIHandler.js b/modules/api/mw.echo.api.APIHandler.js index fb3b2d9..0100e9a 100644 --- a/modules/api/mw.echo.api.APIHandler.js +++ b/modules/api/mw.echo.api.APIHandler.js @@ -68,7 +68,7 @@ notformat: 'model', notlimit: this.limit, notunreadfirst: 1, - notprop: 'index|list|count', + notprop: 'list|count', uselang: this.userLang }, this.getTypeParams( type ) ); diff --git a/modules/special/ext.echo.special.js b/modules/special/ext.echo.special.js index feaba07..30c401e 100644 --- a/modules/special/ext.echo.special.js +++ b/modules/special/ext.echo.special.js @@ -59,7 +59,7 @@ * Load more notification records. */ loadMore: function () { - var notifications, data, container, $li, + var notifications, container, $li, api = new mw.Api( { ajax: { cache: false } } ), seenTime = mw.config.get( 'wgEchoSeenTime' ), that = this, @@ -68,7 +68,7 @@ action: 'query', meta: 'notifications', notformat: 'special', - notprop: 'index|list', + notprop: 'list', notcontinue: this.notcontinue, notlimit: mw.config.get( 'wgEchoDisplayNum' ), uselang: useLang @@ -79,9 +79,7 @@ notifications = result.query.notifications; unread = []; - $.each( notifications.index, function ( index, id ) { - data = notifications.list[ id ]; - + $.each( notifications.list, function ( index, data ) { if ( that.header !== data.timestamp.date ) { that.header = data.timestamp.date; $( '<li></li>' ).addClass( 'mw-echo-date-section' ).append( that.header ).appendTo( container ); @@ -89,7 +87,7 @@ $li = $( '<li></li>' ) .data( 'details', data ) - .data( 'id', id ) + .data( 'id', data.id ) .addClass( 'mw-echo-notification' ) .attr( { 'data-notification-category': data.category, @@ -101,7 +99,7 @@ if ( !data.read ) { $li.addClass( 'mw-echo-unread' ); - unread.push( id ); + unread.push( data.id ); } if ( seenTime !== null && data.timestamp.mw > seenTime ) { diff --git a/tests/phpunit/api/ApiEchoNotificationsTest.php b/tests/phpunit/api/ApiEchoNotificationsTest.php index cd1a973..3ce3726 100644 --- a/tests/phpunit/api/ApiEchoNotificationsTest.php +++ b/tests/phpunit/api/ApiEchoNotificationsTest.php @@ -15,7 +15,7 @@ 'notsections' => 'alert|message', 'notgroupbysection' => 1, 'notlimit' => 10, - 'notprop' => 'index|list|count' ) ); + 'notprop' => 'list|count' ) ); $this->assertArrayHasKey( 'query', $data[0] ); $this->assertArrayHasKey( 'notifications', $data[0]['query'] ); @@ -31,7 +31,6 @@ $alert = $result['alert']; $this->assertArrayHasKey( 'list', $alert ); $this->assertArrayHasKey( 'continue', $alert ); - $this->assertArrayHasKey( 'index', $alert ); $this->assertArrayHasKey( 'rawcount', $alert ); $this->assertArrayHasKey( 'count', $alert ); @@ -40,7 +39,6 @@ $message = $result['message']; $this->assertArrayHasKey( 'list', $message ); $this->assertArrayHasKey( 'continue', $message ); - $this->assertArrayHasKey( 'index', $message ); $this->assertArrayHasKey( 'rawcount', $message ); $this->assertArrayHasKey( 'count', $message ); } @@ -51,7 +49,7 @@ 'meta' => 'notifications', 'notsections' => 'alert|message', 'notlimit' => 10, - 'notprop' => 'index|list|count' ) ); + 'notprop' => 'list|count' ) ); $this->assertArrayHasKey( 'query', $data[0] ); $this->assertArrayHasKey( 'notifications', $data[0]['query'] ); @@ -62,7 +60,6 @@ $this->assertArrayHasKey( 'rawcount', $result ); $this->assertArrayHasKey( 'list', $result ); $this->assertArrayHasKey( 'continue', $result ); - $this->assertArrayHasKey( 'index', $result ); $this->assertTrue( !isset( $result['alert'] ) ); $this->assertTrue( !isset( $result['message'] ) ); -- To view, visit https://gerrit.wikimedia.org/r/284674 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib3bb5ae1e5689037b38290c9ce3d8691f52582b0 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Echo Gerrit-Branch: master Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Siebrand <siebr...@kitano.nl> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits