jenkins-bot has submitted this change and it was merged. Change subject: Fix actions on Special:Gather ......................................................................
Fix actions on Special:Gather * Require collection id to be an Integer * Don't return null/false or something like that in OverlayManagers factory function, always return everything suitable. For non-existent actions or if the action seems to be done on the false collection, show an error toast and return a Deferred and just don't resolve it. * Fix: Watchlist really isn't editable. Change-Id: Ib7db1d7ffbf276ceaa3baa869b357a96c12e61fb --- M i18n/en.json M i18n/qqq.json M includes/specials/SpecialGather.php M resources/Resources.php M resources/ext.gather.special/init.js 5 files changed, 21 insertions(+), 2 deletions(-) Approvals: Jdlrobson: Looks good to me, approved jenkins-bot: Verified diff --git a/i18n/en.json b/i18n/en.json index ca3ac0a..b3a14eb 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -49,6 +49,8 @@ "gather-add-to-collection-confirm": "Add to collection", "gather-add-to-collection-cancel": "No thanks", "gather-remove-toast": "The page has been removed from your \"$1\" collection.", + "gather-no-such-action": "Sorry, the requested action doesn't exist.", + "gather-unknown-error": "Sorry, there was an unknown error while processing your request.", "gather-desc": "Component of Mobile Frontend allowing users to curate lists.", "gather-no-public-lists-title": "No public collections", "gather-no-public-lists-description": "There are no public collections for this user.", diff --git a/i18n/qqq.json b/i18n/qqq.json index 6dfdc6e..d5fcea6 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -53,6 +53,8 @@ "gather-add-to-collection-confirm": "Label for button that user can click if they would like to add the current page to a collection", "gather-add-to-collection-cancel": "Label for button that user can click if they do not want to add to a collection.\n{{Identical|No thanks}}", "gather-remove-toast": "Message displayed when you remove an item from a collection. Parameters:\n* $1 - Name of collection.", + "gather-no-such-action": "Message used, if thse user tried to request a non-existent action on a collection.", + "gather-unknown-error": "Used as an error message, if there was an unknown error.", "gather-desc": "{{desc|name=Gather|url=https://www.mediawiki.org/wiki/Extension:Gather}}", "gather-no-public-lists-title": "The title of the view shown when there are no public collections for a user.", "gather-no-public-lists-description": "The descriptive text explaining that there are no public collections for a user.", diff --git a/includes/specials/SpecialGather.php b/includes/specials/SpecialGather.php index a484c6c..4b8b3dd 100644 --- a/includes/specials/SpecialGather.php +++ b/includes/specials/SpecialGather.php @@ -12,6 +12,7 @@ use \UsageException; use \DerivativeRequest; use \ApiMain; +use \Exception; /** * Render a collection of articles. @@ -63,7 +64,7 @@ } elseif ( preg_match( '/^by\/(?<user>\w+)\/(?<id>\d+)$/', $subpage, $matches ) ) { // Collection page // /by/:user/:id - $id = $matches['id']; + $id = (int)$matches['id']; $user = User::newFromName( $matches['user'] ); if ( !( $user && $user->getId() ) ) { @@ -108,6 +109,10 @@ * @param int $id collection id */ public function renderUserCollection( User $user, $id ) { + if ( !is_int( $id ) ) { + throw new Exception( __METHOD__ . ' requires the second parameter to be an integer, ' + . gettype( $id ) . ' given.' ); + } $collection = models\Collection::newFromApi( $id, $user ); if ( $collection === null || diff --git a/resources/Resources.php b/resources/Resources.php index 060a233..b2eaf65 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -218,6 +218,10 @@ 'scripts' => array( 'ext.gather.special/init.js', ), + 'messages' => array( + 'gather-no-such-action', + 'gather-unknown-error', + ), ), 'ext.gather.lists' => $wgGatherMobileSpecialPageResourceBoilerplate + array( diff --git a/resources/ext.gather.special/init.js b/resources/ext.gather.special/init.js index 698b699..e75404e 100644 --- a/resources/ext.gather.special/init.js +++ b/resources/ext.gather.special/init.js @@ -2,6 +2,7 @@ var CollectionEditOverlay = M.require( 'ext.gather.edit/CollectionEditOverlay' ), CollectionDeleteOverlay = M.require( 'ext.gather.delete/CollectionDeleteOverlay' ), + toast = M.require( 'toast' ), overlayManager = M.require( 'overlayManager' ); /** Add routes for editing and deleting to the overlay manager */ @@ -14,6 +15,7 @@ collection = this; } } ); + if ( collection ) { if ( action === 'edit' ) { return new CollectionEditOverlay( { @@ -23,9 +25,13 @@ return new CollectionDeleteOverlay( { collection: collection } ); + } else { + toast.show( mw.msg( 'gather-no-such-action' ), 'error' ); + return $.Deferred(); } } else { - return null; + toast.show( mw.msg( 'gather-unknown-error' ), 'error' ); + return $.Deferred(); } } ); } -- To view, visit https://gerrit.wikimedia.org/r/199659 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ib7db1d7ffbf276ceaa3baa869b357a96c12e61fb Gerrit-PatchSet: 7 Gerrit-Project: mediawiki/extensions/Gather Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: Jdlrobson <jrob...@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