[MediaWiki-commits] [Gerrit] Revert "Show an error to the user if the spamlist has no tar... - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/297285 Change subject: Revert "Show an error to the user if the spamlist has no targets on it" .. Revert "Show an error to the user if the spamlist has no targets on it" This is causing T139303 This reverts commit 581beff268d5a50cfff13787d54a255f85aa3b9d. Change-Id: Ia033cc0a4d8b2fe4fac9d47d9462ebed6005c86b --- M i18n/en.json M i18n/qqq.json M includes/ApiMassMessage.php M includes/MassMessage.php M includes/MassMessageTargets.php M includes/SpecialMassMessage.php M tests/api/ApiMassMessageTest.php 7 files changed, 16 insertions(+), 45 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/85/297285/1 diff --git a/i18n/en.json b/i18n/en.json index 5494a77..902f97b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -19,8 +19,7 @@ "massmessage-preview-count": "Your message will be sent to {{PLURAL:$1|$1 page|$1 pages}}.", "massmessage-submitted": "Your message delivery to {{PLURAL:$1|$1 page|$1 pages}} has been queued.", "massmessage-just-preview": "This is just a preview. Press \"{{int:massmessage-form-submit}}\" to send the message.", - "massmessage-spamlist-doesnotexist": "The specified list of pages does not exist.", - "massmessage-spamlist-notargets": "The specified list of pages does not have any targets on it.", + "massmessage-spamlist-doesnotexist": "The specified delivery list page or category does not exist.", "massmessage-spamlist-invalid": "The specified page does not contain a valid delivery list.", "massmessage-empty-subject": "The subject line is empty.", "massmessage-empty-message": "The message body is empty.", diff --git a/i18n/qqq.json b/i18n/qqq.json index d48b416..4c52951 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -25,8 +25,7 @@ "massmessage-preview-count": "Text indicating how many pages the message will be sent to. Parameters:\n* $1 - the number of pages", "massmessage-submitted": "Confirmation message the user sees after the form is submitted successfully and the request is queued in the job queue.\n\nParameters:\n* $1 - the number of deliveries that have been queued", "massmessage-just-preview": "Warning to user that what they are seeing is just a preview, and they should hit the send button to actually submit it.\n\nRefers to {{msg-mw|Massmessage-form-submit}}.", - "massmessage-spamlist-doesnotexist": "Error message the user sees if an invalid list of pages is provided.", - "massmessage-spamlist-notargets": "Error message that the user sees if the list of pages provided by the user has no targets listed on it.", + "massmessage-spamlist-doesnotexist": "Error message the user sees if the delivery list page or category they entered does not exist.", "massmessage-spamlist-invalid": "Error message the user sees if the delivery list page they entered is invalid.", "massmessage-empty-subject": "Error message the user sees if the \"subject\" field is empty.", "massmessage-empty-message": "Error message the user sees if the \"message\" field is empty.", diff --git a/includes/ApiMassMessage.php b/includes/ApiMassMessage.php index 19e3dbf..25eb370 100644 --- a/includes/ApiMassMessage.php +++ b/includes/ApiMassMessage.php @@ -16,7 +16,7 @@ $data = $this->extractRequestParams(); $status = new Status(); - MassMessage::verifyData( $data, $status, $this ); + MassMessage::verifyData( $data, $status ); if ( !$status->isOK() ) { $this->dieStatus( $status ); } diff --git a/includes/MassMessage.php b/includes/MassMessage.php index c920766..615d8fc 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -195,9 +195,8 @@ * Verify and cleanup the main user submitted data * @param array &$data should have subject, message, and spamlist keys * @param Status &$status -* @param IContextSource $ctx */ - public static function verifyData( array &$data, Status &$status, IContextSource $ctx ) { + public static function verifyData( array &$data, Status &$status ) { // Trim all the things! foreach ( $data as $k => $v ) { $data[$k] = trim( $v ); @@ -220,18 +219,10 @@ ); } $data['comment'] = [ - $ctx->getUser()->getName(), + RequestContext::getMain()->getUser()->getName(), wfWikiID(), $url ]; - - // Check that the spamlist has targets - $targets =
[MediaWiki-commits] [Gerrit] Fix typo in comment - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/285318 Change subject: Fix typo in comment .. Fix typo in comment Change-Id: I7adeed7e7f5954600da9cbb5edf1e547033016f5 --- M includes/SpecialCreateMassMessageList.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/18/285318/1 diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index cf997c9..689f465 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -110,7 +110,7 @@ } /** -* Build and return the aossociative array for the content radio button field. +* Build and return the associative array for the content radio button field. * @return array */ protected function getContentOptions() { -- To view, visit https://gerrit.wikimedia.org/r/285318 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7adeed7e7f5954600da9cbb5edf1e547033016f5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Support using the user's account to deliver messages - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/285302 Change subject: Support using the user's account to deliver messages .. Support using the user's account to deliver messages Add the option to use the user's account to deliver messages to Special:MassMessage and the API. Follow up to I736f4c675583d3db21ee4a1a259b961494337ef3 Bug: T71954 Change-Id: I64aa554815a42088c2af83748b0d8c7a4d0e0950 --- M i18n/en.json M i18n/qqq.json M includes/ApiMassMessage.php M includes/SpecialMassMessage.php M includes/job/MassMessageJob.php 5 files changed, 50 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/02/285302/1 diff --git a/i18n/en.json b/i18n/en.json index 902f97b..5dba798 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -12,6 +12,9 @@ "massmessage-form-spamlist": "Page or category containing list of pages to leave a message on:", "massmessage-form-subject": "Subject of the message (also used as the edit summary):", "massmessage-form-message": "Body of the message:", + "massmessage-form-sender": "Sender account:", + "massmessage-form-shareduser": "Shared message delivery user", + "massmessage-form-ownuser": "Your own user account", "massmessage-form-preview": "Preview", "massmessage-form-submit": "Send", "massmessage-fieldset-preview": "Preview", diff --git a/i18n/qqq.json b/i18n/qqq.json index 4c52951..a4dfcb6 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -18,6 +18,9 @@ "massmessage-form-spamlist": "Label for an inputbox on [[Special:MassMessage]].", "massmessage-form-subject": "Label for an inputbox on [[Special:MassMessage]].", "massmessage-form-message": "Used as label for a textarea on [[Special:MassMessage]].", + "massmessage-form-sender": "Label for a radio button on [[Special:MassMessage]]", + "massmessage-form-shareduser": "Option label for using the shared message delivery user", + "massmessage-form-ownuser": "Option label for using the user's own account", "massmessage-form-preview": "Label for the preview button on [[Special:MassMessage]].\n{{Identical|Preview}}", "massmessage-form-submit": "Label for the submit button on [[Special:MassMessage]].\n\nUsed in {{msg-mw|Massmessage-just-preview}}.\n{{Identical|Send}}", "massmessage-fieldset-preview": "Label for the fieldset box around the page preview.\n{{Identical|Preview}}", diff --git a/includes/ApiMassMessage.php b/includes/ApiMassMessage.php index 630653b..5465835 100644 --- a/includes/ApiMassMessage.php +++ b/includes/ApiMassMessage.php @@ -44,6 +44,11 @@ ApiBase::PARAM_TYPE => 'string', ApiBase::PARAM_REQUIRED => true ), + 'sender' => array( + ApiBase::PARAM_TYPE => array( 'shareduser', 'ownuser' ), + ApiBase::PARAM_REQUIRED => false, + ApiBase::PARAM_DFLT => 'shareduser' + ), 'token' => null, ); } diff --git a/includes/SpecialMassMessage.php b/includes/SpecialMassMessage.php index 4c1b72f..3457666 100644 --- a/includes/SpecialMassMessage.php +++ b/includes/SpecialMassMessage.php @@ -110,11 +110,29 @@ } /** +* Build and return the aossociative array for the sender field +* @return array +*/ + protected function getSenderOptions() { + $mapping = array( + 'massmessage-form-shareduser' => 'shareduser', + 'massmessage-form-ownuser' => 'ownuser' + ); + + $options = array(); + foreach ( $mapping as $msgKey => $option ) { + $options[$this->msg( $msgKey )->escaped()] = $option; + } + return $options; + } + + /** * @return array */ protected function createForm() { $request = $this->getRequest(); $m = array(); + // Who to send to $m['spamlist'] = array( 'id' => 'mw-massmessage-form-spamlist', @@ -124,6 +142,7 @@ 'label-message' => 'massmessage-form-spamlist', 'default' => $request->getText( 'spamlist' ) ); + // The subject line $m['subject'] = array( 'id' => 'mw-massmessage-form-subject', @@ -145,6 +164,17 @@ 'default' => $request->getText( 'message' ) ); + // Whether to send using the user account or the shared MassMessage user + $m['sender'] = array( +
[MediaWiki-commits] [Gerrit] Add change tag for delivery to wikitext pages - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/284624 Change subject: Add change tag for delivery to wikitext pages .. Add change tag for delivery to wikitext pages Note that this does not cover LiquidThreads or Flow talk pages. Change-Id: I0074b45e40779979c86b47a3b626710228db078f --- M MassMessage.hooks.php M extension.json M i18n/en.json M i18n/qqq.json M includes/job/MassMessageJob.php 5 files changed, 30 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/24/284624/1 diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index 71bb204..bf482dc 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -245,4 +245,14 @@ } return true; } + + /** +* Register the change tag for MassMessage delivery +* @param array &$tags +* @return bool +*/ + public static function onRegisterTags( &$tags ) { + $tags[] = 'massmessage-delivery'; + return true; + } } diff --git a/extension.json b/extension.json index 1b4456f..3b947f9 100644 --- a/extension.json +++ b/extension.json @@ -72,6 +72,12 @@ ], "BeforePageDisplay": [ "MassMessageHooks::onBeforePageDisplay" + ], + "ListDefinedTags": [ + "MassMessageHooks::onRegisterTags" + ], + "ChangeTagsListActive": [ + "MassMessageHooks::onRegisterTags" ] }, "ContentHandlers": { diff --git a/i18n/en.json b/i18n/en.json index 83b2406..902f97b 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -123,5 +123,7 @@ "apihelp-massmessage-example-1": "Send a message to the list at [[Signpost Spamlist]] with the subject \"New Signpost\", and message body of \"Please read it\"", "apihelp-query+mmsites-description": "Serve autocomplete requests for the site field in MassMessage.", "apihelp-query+mmsites-param-term": "The prefix to search for.", - "apihelp-query+mmsites-example-1": "Autocomplete \"en\"" + "apihelp-query+mmsites-example-1": "Autocomplete \"en\"", + "tag-massmessage-delivery": "MassMessage delivery", + "tag-massmessage-delivery-description": "Message delivery using [[:mw:Extension:MassMessage|Extension:MassMessage]]" } diff --git a/i18n/qqq.json b/i18n/qqq.json index fb01efa..4c52951 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -129,5 +129,7 @@ "apihelp-massmessage-example-1": "{{doc-apihelp-example|massmessage}}", "apihelp-query+mmsites-description": "{{doc-apihelp-description|query+mmsites}}", "apihelp-query+mmsites-param-term": "Label of an input area. Connected site names will be returned if they match the provided prefix (e.g. entering \"meta\" may return \"metawiki\").\n\n{{doc-apihelp-param|query+mmsites|term}}", - "apihelp-query+mmsites-example-1": "{{doc-apihelp-example|query+mmsites}}" + "apihelp-query+mmsites-example-1": "{{doc-apihelp-example|query+mmsites}}", + "tag-massmessage-delivery": "Change tag for MassMessage delivery edits", + "tag-massmessage-delivery-description": "Description for MassMessage delivery change tag" } diff --git a/includes/job/MassMessageJob.php b/includes/job/MassMessageJob.php index 655beef..a6bc565 100644 --- a/includes/job/MassMessageJob.php +++ b/includes/job/MassMessageJob.php @@ -308,6 +308,14 @@ } } + // Apply change tag for wikitext talk page edits + if ( $params['action'] === 'edit' ) { + $revId = $api->getResult()->getResultData()['edit']['newrevid']; + DeferredUpdates::addCallableUpdate( function() use ( $revId ) { + ChangeTags::addTags( 'massmessage-delivery', null, $revId, null ); + } ); + } + // Cleanup all the stuff we polluted $context->setUser( $oldCUser ); $context->setRequest( $oldCRequest ); -- To view, visit https://gerrit.wikimedia.org/r/284624 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0074b45e40779979c86b47a3b626710228db078f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add mediawiki/core back to #wikimedia-dev - change (labs...grrrit)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/283943 Change subject: Add mediawiki/core back to #wikimedia-dev .. Add mediawiki/core back to #wikimedia-dev Change-Id: I6b8ad9643c16e683829fec431fc8464a7dec6428 --- M config.yaml 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/labs/tools/grrrit refs/changes/43/283943/1 diff --git a/config.yaml b/config.yaml index db9081f..a282294 100644 --- a/config.yaml +++ b/config.yaml @@ -93,6 +93,8 @@ mediawiki/extensions/OOUIPlayground: mediawiki/extensions/Popups: oojs/oojs-ui: +# Sent to #wikimedia-codereview as well +mediawiki/core: "#wikimedia-design": mediawiki/skins/Blueprint: mediawiki/extensions/OOUIPlayground: -- To view, visit https://gerrit.wikimedia.org/r/283943 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6b8ad9643c16e683829fec431fc8464a7dec6428 Gerrit-PatchSet: 1 Gerrit-Project: labs/tools/grrrit Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Convert ext.MassMessage.create.js to formatversion=2 - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/283764 Change subject: Convert ext.MassMessage.create.js to formatversion=2 .. Convert ext.MassMessage.create.js to formatversion=2 Use new API response format for simpler code. Change-Id: Ic793ea686eade8958e597cf0455a26fdddb00078 --- M modules/ext.MassMessage.create.js 1 file changed, 12 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/64/283764/1 diff --git a/modules/ext.MassMessage.create.js b/modules/ext.MassMessage.create.js index 4a58599..736435d 100644 --- a/modules/ext.MassMessage.create.js +++ b/modules/ext.MassMessage.create.js @@ -21,9 +21,14 @@ ( new mw.Api() ).get( { action: 'query', prop: 'info', - titles: title + titles: title, + formatversion: 2 } ).done( function ( data ) { - if ( data && data.query && !data.query.pages[ '-1' ] ) { + if ( data && + data.query && + data.query.pages && + !data.query.pages[ 0 ].missing + ) { // Page with title already exists $titleStatus.addClass( 'invalid' ) .text( mw.message( 'massmessage-create-exists-short' ).text() ); @@ -44,7 +49,8 @@ ( new mw.Api() ).get( { action: 'query', prop: 'info|categoryinfo', - titles: source + titles: source, + formatversion: 2 } ).done( function ( data ) { if ( pageIsValidSource( data ) ) { // Clear validation error @@ -64,15 +70,14 @@ if ( !response || !response.query || !response.query.pages ) { return true; // ignore if the API acts up } - pages = response.query.pages; - if ( Object.keys( pages ).length !== 1 ) { + if ( response.query.pages.length !== 1 ) { return false; // there should be exactly one page } - page = pages[ Object.keys( pages )[ 0 ] ]; + page = response.query.pages[0]; if ( page.ns === 14 ) { return page.hasOwnProperty( 'categoryinfo' ); // non-empty category } else { - return !page.hasOwnProperty( 'missing' ) && + return !page.missing && ( page.contentmodel === 'wikitext' || page.contentmodel === 'MassMessageListContent' ); } -- To view, visit https://gerrit.wikimedia.org/r/283764 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic793ea686eade8958e597cf0455a26fdddb00078 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Improve source input checking - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/283695 Change subject: Improve source input checking .. Improve source input checking Handle categories properly by checking for empty categories and improve code readability. Change-Id: I25ed8a963ab23a147335c3818eccb287bd5af05c --- M modules/ext.MassMessage.create.js 1 file changed, 13 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/95/283695/1 diff --git a/modules/ext.MassMessage.create.js b/modules/ext.MassMessage.create.js index bc450fd..d63068e 100644 --- a/modules/ext.MassMessage.create.js +++ b/modules/ext.MassMessage.create.js @@ -43,7 +43,7 @@ if ( source ) { ( new mw.Api() ).get( { action: 'query', - prop: 'info', + prop: 'info|categoryinfo', titles: source } ).done( function ( data ) { if ( pageIsValidSource( data ) ) { @@ -60,21 +60,22 @@ }; pageIsValidSource = function ( response ) { - var i; - if ( !response || !response.query ) { + var i, pages, page; + if ( !response || !response.query || !response.query.pages ) { return true; // ignore if the API acts up } - if ( response.query.pages[ '-1' ] ) { - return false; + pages = response.query.pages; + if ( Object.keys( pages ).length !== 1 ) { + return false; // there should be exactly one page } - for ( i in response.query.pages ) { - if ( response.query.pages[ i ].contentmodel === 'wikitext' || - response.query.pages[ i ].contentmodel === 'MassMessageListContent' || - response.query.pages[ i ].ns === 14 ) { - return true; - } + page = pages[ Object.keys( pages )[0] ]; + if ( page.ns === 14 ) { + return 'categoryinfo' in page; // non-empty category + } else { + return !page.hasOwnProperty( 'missing' ) + && ( page.contentmodel === 'wikitext' + || page.contentmodel === 'MassMessageListContent' ); } - return false; }; // Set the correct field state on load. -- To view, visit https://gerrit.wikimedia.org/r/283695 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I25ed8a963ab23a147335c3818eccb287bd5af05c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Mention source when creating spamlist with imported targets - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/282989 Change subject: Mention source when creating spamlist with imported targets .. Mention source when creating spamlist with imported targets Link the source page/revision or category in the edit summary. Change-Id: Ic0f187d703bd9f4ae750e3cc5568add6b4eab84d --- M i18n/en.json M i18n/qqq.json M includes/SpecialCreateMassMessageList.php 3 files changed, 18 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/89/282989/1 diff --git a/i18n/en.json b/i18n/en.json index 0129b37..7789f43 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -82,6 +82,8 @@ "massmessage-create-import": "Import pages from an existing list or category", "massmessage-create-source": "Source:", "massmessage-create-editsummary": "Create mass message delivery list", + "massmessage-create-editsummary-import": "Create mass message delivery list with targets from [[{{#Special:Permalink}}/$2|$1]]", + "massmessage-create-editsummary-catimport": "Create mass message delivery list with targets from [[$1]]", "massmessage-create-invalidtitle": "The specified title is invalid.", "massmessage-create-exists": "A page already exists with the specified title.", "massmessage-create-nopermission": "You do not have permission to create a list with this title.", diff --git a/i18n/qqq.json b/i18n/qqq.json index ee52c5a..fb01efa 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -88,6 +88,8 @@ "massmessage-create-import": "Label for an option on [[Special:CreateMassMessageList]]", "massmessage-create-source": "Label for an inputbox on [[Special:CreateMassMessageList]]\n{{Identical|Source}}", "massmessage-create-editsummary": "Edit summary for creating a delivery list", + "massmessage-create-editsummary-import": "Edit summary for creating a delivery list with imported targets\n* $1 - title of source page containing targets\n* $2 - revision ID of source page", + "massmessage-create-editsummary-catimport": "Edit summary for creating a delivery list with targets imported from a category\n* $1 - name of source category", "massmessage-create-invalidtitle": "Error message shown on [[Special:CreateMassMessageList]] when the title is inavlid", "massmessage-create-exists": "Error message shown on [[Special:CreateMassMessageList]] when a page with the title already exists", "massmessage-create-nopermission": "Error message shown on [[Special:CreateMassMessageList]] when the user cannot create a page with the title", diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index 6fee05e..2307253 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -72,15 +72,28 @@ if ( $targets === null || count( $targets ) === 0 ) { return Status::newFatal( 'massmessage-create-invalidsource' ); } + if ( $source->inNamespace( NS_CATEGORY ) ) { + $editSummaryMsg = $this->msg( + 'massmessage-create-editsummary-catimport', + $source->getPrefixedText() + ); + } else { + $editSummaryMsg = $this->msg( + 'massmessage-create-editsummary-import', + $source->getPrefixedText(), + $source->getLatestRevID() + ); + } } else { $targets = array(); + $editSummaryMsg = $this->msg( 'massmessage-create-editsummary' ); } $result = MassMessageListContentHandler::edit( $title, $data['description'], $targets, - $this->msg( 'massmessage-create-editsummary' )->inContentLanguage()->plain(), + $editSummaryMsg->inContentLanguage()->text(), $this->getContext() ); -- To view, visit https://gerrit.wikimedia.org/r/282989 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic0f187d703bd9f4ae750e3cc5568add6b4eab84d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org
[MediaWiki-commits] [Gerrit] Require edicontentmodel to view Special:CreateMassMessageList - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/274583 Change subject: Require edicontentmodel to view Special:CreateMassMessageList .. Require edicontentmodel to view Special:CreateMassMessageList Change-Id: I69bf374237479b23be80688123dcca63b7b2575b --- M includes/SpecialCreateMassMessageList.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/83/274583/1 diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index eb04e04..6fee05e 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -3,7 +3,7 @@ class SpecialCreateMassMessageList extends FormSpecialPage { public function __construct() { - parent::__construct( 'CreateMassMessageList' ); + parent::__construct( 'CreateMassMessageList', 'editcontentmodel' ); } public function doesWrites() { -- To view, visit https://gerrit.wikimedia.org/r/274583 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I69bf374237479b23be80688123dcca63b7b2575b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Warn for empty summary when edit section used - change (mediawiki...VisualEditor)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/272312 Change subject: Warn for empty summary when edit section used .. Warn for empty summary when edit section used Warn the user about an empty edit summary when the "edit section" link is used to trigger VE. Untested because I don't have VE set up; would appreciate directions if this approach is incorrect. Thanks. Bug: T126562 Change-Id: I319c9c5bed47140a81eb409d490c9f82b89a49fe --- M modules/ve-mw/init/ve.init.mw.ArticleTarget.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/12/272312/1 diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js index fd77e0c..abf8c4f 100644 --- a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js +++ b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js @@ -1195,7 +1195,7 @@ if ( +mw.user.options.get( 'forceeditsummary' ) && - saveOptions.summary === '' && + ( saveOptions.summary === '' || saveOptions.summary === this.initialEditSummary ) && !this.saveDialog.messages.missingsummary ) { this.saveDialog.showMessage( -- To view, visit https://gerrit.wikimedia.org/r/272312 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I319c9c5bed47140a81eb409d490c9f82b89a49fe Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix link element - change (mediawiki...WikimediaPageViewInfo)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/271448 Change subject: Fix link element .. Fix link element Add an href attribute so that it's a proper link with the correct cursor type. Change-Id: I32dd9c21390c6a7fef997bef1f2724120c3f1bff --- M resources/ext.wmpageviewinfo.js 1 file changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaPageViewInfo refs/changes/48/271448/1 diff --git a/resources/ext.wmpageviewinfo.js b/resources/ext.wmpageviewinfo.js index e3600f4..a901271 100644 --- a/resources/ext.wmpageviewinfo.js +++ b/resources/ext.wmpageviewinfo.js @@ -4,10 +4,12 @@ count = $count.text(); // Turn it into an tag so it's obvious you can click on it - $count.html( mw.html.element( 'a', {}, count ) ); + $count.html( mw.html.element( 'a', { href: '#' }, count ) ); - $count.click( function () { + $count.click( function ( e ) { var myDialog, windowManager; + e.preventDefault(); + // A simple dialog window. function MyDialog( config ) { MyDialog.parent.call( this, config ); -- To view, visit https://gerrit.wikimedia.org/r/271448 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I32dd9c21390c6a7fef997bef1f2724120c3f1bff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikimediaPageViewInfo Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Change bug ID to Phabricator task ID - change (mediawiki/core)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/268336 Change subject: Change bug ID to Phabricator task ID .. Change bug ID to Phabricator task ID Change-Id: I8e1fc6ed9434a331eb7c66273305576eebed3125 --- M images/.htaccess 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/36/268336/1 diff --git a/images/.htaccess b/images/.htaccess index 3f3d41e..4e253b6 100644 --- a/images/.htaccess +++ b/images/.htaccess @@ -1,4 +1,4 @@ -# Protect against bug 28235 +# Protect against bug T30235 RewriteEngine On RewriteOptions inherit -- To view, visit https://gerrit.wikimedia.org/r/268336 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8e1fc6ed9434a331eb7c66273305576eebed3125 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Wctaiwan___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] [WIP] Handle revisions with different content models in Edit... - change (mediawiki/core)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/237988 Change subject: [WIP] Handle revisions with different content models in EditPage .. [WIP] Handle revisions with different content models in EditPage Disable editing and serialize using the default format if the revision has a different content model from the current one. Bug: T73163 Change-Id: If28de7a3612d414a4366e3d493598244c0754b90 --- M includes/EditPage.php M languages/i18n/en.json M languages/i18n/qqq.json 3 files changed, 36 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/88/237988/1 diff --git a/includes/EditPage.php b/includes/EditPage.php index 05e0ac0..66fda60 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -537,6 +537,15 @@ return; } + $revision = $this->mArticle->getRevisionFetched(); + if ( $revision && $revision->getContentModel() !== $this->contentModel ) { + $this->displayViewSourcePage( + $this->getContentObject(), + wfMessage( 'contentmodelediterror' )->plain() + ); + return; + } + $this->isConflict = false; // css / js subpages of user pages get a special treatment $this->isCssJsSubpage = $this->mTitle->isCssJsSubpage(); @@ -647,6 +656,20 @@ throw new PermissionsError( $action, $permErrors ); } + $this->displayViewSourcePage( + $content, + $wgOut->formatPermissionsErrorMessage( $permErrors, 'edit' ) + ); + } + + /** +* Display a read-only View Source page +* @param Content $content content object +* @param $errorMessage additional error message to display +*/ + protected function displayViewSourcePage( Content $content, $errorMessage = '' ) { + global $wgOut; + Hooks::run( 'EditPage::showReadOnlyForm:initial', array( $this, &$wgOut ) ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); @@ -658,8 +681,10 @@ $wgOut->addHTML( $this->editFormPageTop ); $wgOut->addHTML( $this->editFormTextTop ); - $wgOut->addWikiText( $wgOut->formatPermissionsErrorMessage( $permErrors, 'edit' ) ); - $wgOut->addHTML( "\n" ); + if ( $errorMessage !== '' ) { + $wgOut->addWikiText( $errorMessage ); + $wgOut->addHTML( "\n" ); + } # If the user made changes, preserve them when showing the markup # (This happens when a user is blocked during edit, for instance) @@ -667,7 +692,13 @@ $text = $this->textbox1; $wgOut->addWikiMsg( 'viewyourtext' ); } else { - $text = $this->toEditText( $content ); + try { + $text = $this->toEditText( $content ); + } catch ( MWException $e ) { + # Serialize using the default format if the content model is not supported + # (e.g. for an old revision with a different model) + $text = $content->serialize(); + } $wgOut->addWikiMsg( 'viewsourcetext' ); } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 5859365..6704afb 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -689,6 +689,7 @@ "permissionserrors": "Permission error", "permissionserrorstext": "You do not have permission to do that, for the following {{PLURAL:$1|reason|reasons}}:", "permissionserrorstext-withaction": "You do not have permission to $2, for the following {{PLURAL:$1|reason|reasons}}:", + "contentmodelediterror": "You cannot edit this revision because it has a content model different from that of the current revision.", "recreate-moveddeleted-warn": "Warning: You are recreating a page that was previously deleted.\n\nYou should consider whether it is appropriate to continue editing this page.\nThe deletion and move log for this page are provided here for convenience:", "moveddeleted-notice": "This page has been deleted.\nThe deletion and move log for the page are provided below for reference.", "log-fulllog": "View full log", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index d3b5a99..3652df8 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -862,6 +862,7 @@ "permissionserrors": "Used as title of error
[MediaWiki-commits] [Gerrit] Use wfGlobalCacheKey() - change (mediawiki...MassMessage)
Wctaiwan has submitted this change and it was merged. Change subject: Use wfGlobalCacheKey() .. Use wfGlobalCacheKey() Change-Id: Id37e0041f47b9fda583a953bb88ee1b45518cc56 --- M includes/MassMessage.php 1 file changed, 1 insertion(+), 2 deletions(-) Approvals: Wctaiwan: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/MassMessage.php b/includes/MassMessage.php index 20b4250..7ba3c33 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -99,8 +99,7 @@ global $wgConf, $wgMemc; static $mapping = null; if ( $mapping === null ) { - // Don't use wfMemcKey since it splits cache per wiki - $key = 'massmessage:urltodb'; + $key = wfGlobalCacheKey( 'massmessage:urltodb' ); $data = $wgMemc->get( $key ); if ( $data === false ) { $dbs = $wgConf->getLocalDatabases(); -- To view, visit https://gerrit.wikimedia.org/r/237019 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Id37e0041f47b9fda583a953bb88ee1b45518cc56 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: LegoktmGerrit-Reviewer: Wctaiwan Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix percent formatting - change (labs...extreg-wos)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/213001 Change subject: Fix percent formatting .. Fix percent formatting Change-Id: Ibe6980be184828c02ceb16362188332aec6c4bc7 --- M generate.py 1 file changed, 2 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/labs/tools/extreg-wos refs/changes/01/213001/1 diff --git a/generate.py b/generate.py index 75bc5c5..704c3c5 100644 --- a/generate.py +++ b/generate.py @@ -76,9 +76,8 @@ total = len(data) converted = sum(1 for info in data.values() if info['converted']) print(converted/total) -percent = str(converted/total)[2:5] -percent = percent[:2] + '.' + percent[2:] + '%' -superpowers = int(percent[:2]) = 50 +percent = '{:.2f}'.format(converted/total*100) + '%' +superpowers = converted/total = 0.5 s_text = 'superpowers' if superpowers else 'sadness' title = 'Extension registration wall of {s_text}'.format(s_text=s_text) excite = '!' if superpowers else ' :(' -- To view, visit https://gerrit.wikimedia.org/r/213001 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibe6980be184828c02ceb16362188332aec6c4bc7 Gerrit-PatchSet: 1 Gerrit-Project: labs/tools/extreg-wos Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use href attribute to calculate titles - change (mediawiki...Popups)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/199694 Change subject: Use href attribute to calculate titles .. Use href attribute to calculate titles This is needed for wikis that use LanguageConverter, since the title attribute is converted to the user's variant, and the canonical title is needed for the API unless converttitles is specified. For filtering, instead of comparing linkHref and expectedHref, filter out links that - have extra query parameters, or - contain colons, and the first colon is followed by something other than a space (i.e. not mainspace) There should be few links falsely filtered out (200 on enwiki). Bug: T93605 Change-Id: I5534753307ed5e1d4b27c52c616fd143b2a397e1 --- M resources/ext.popups.core.js M resources/ext.popups.renderer.article.js 2 files changed, 43 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups refs/changes/94/199694/1 diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js index dbb454f..fdfc7c5 100644 --- a/resources/ext.popups.core.js +++ b/resources/ext.popups.core.js @@ -154,15 +154,46 @@ return mw.popups.$content .find( 'a[href][title]:not(' + mw.popups.IGNORE_CLASSES.join(', ') + ')' ) .filter( function () { - var linkHref = new mw.Uri( this.href ), - expectedHref = new mw.Uri( mw.util.getUrl( this.title ) ); - - // don't compare fragment to display popups on anchored page links - linkHref.fragment = undefined; - return linkHref.toString() === expectedHref.toString(); + var title = mw.popups.getTitle( this.href ), colonPos; + if ( !title ) { + return false; + } + // Is title in mainspace? Approximate by checking if title contains no colons, + // or if the first colon is followed by a space. + colonPos = title.indexOf( ':' ); + return colonPos 0 || title.charAt( colonPos+1 ) === ' '; } ); }; + /** +* Given an href string for the local wiki, return the (URIencoded) title portion, or +* undefined if the link is external, has extra query parameters, or contains no title. +* +* @param string href +* @return string|undefined +*/ + mw.popups.getTitle = function ( href ) { + var linkHref = new mw.Uri( href ), title; + if ( linkHref.host !== window.location.hostname ) { // External links + return undefined; + } + if ( linkHref.path.substring( 0, 6 ) === '/wiki/' ) { + if ( !$.isEmptyObject( linkHref.query ) ) { + return undefined; + } + return linkHref.path.substring( 6 ); + } else if ( linkHref.path === '/w/index.php' ) { + title = linkHref.query.title; + linkHref.query.title = undefined; + if ( !title || !$.isEmptyObject( linkHref.query ) ) { + return undefined; + } + return title; + } else { + return undefined; + } + }; + mw.hook( 'wikipage.content').add( function ( $content ) { if ( mw.popups.enabled ) { mw.popups.$content = $content; diff --git a/resources/ext.popups.renderer.article.js b/resources/ext.popups.renderer.article.js index 728606b..b19eaa1 100644 --- a/resources/ext.popups.renderer.article.js +++ b/resources/ext.popups.renderer.article.js @@ -32,14 +32,15 @@ * @return {jQuery.Promise} */ article.init = function ( link ) { - var - href = link.attr( 'href' ), - title = link.data( 'title' ), - deferred = $.Deferred(); + var href = link.attr( 'href' ), + encodedTitle = mw.popups.getTitle( href ), + deferred = $.Deferred(), + title; - if ( !title ) { + if ( !encodedTitle ) { return deferred.reject().promise(); } + title = decodeURIComponent( encodedTitle ); mw.popups.render.currentRequest = mw.popups.api.get( { action: 'query', -- To view, visit
[MediaWiki-commits] [Gerrit] Fix strict standards warning in MassMessageServerSideJob - change (mediawiki...MassMessage)
Wctaiwan has submitted this change and it was merged. Change subject: Fix strict standards warning in MassMessageServerSideJob .. Fix strict standards warning in MassMessageServerSideJob Bug: T92650 Change-Id: I5d369f03ac6aa8be50d5b50254e691d6cdfef9c3 --- M MassMessage.i18n.magic.php M includes/job/MassMessageServerSideJob.php 2 files changed, 4 insertions(+), 3 deletions(-) Approvals: Wctaiwan: Looks good to me, approved diff --git a/MassMessage.i18n.magic.php b/MassMessage.i18n.magic.php index 967b59a..cc4e93e 100644 --- a/MassMessage.i18n.magic.php +++ b/MassMessage.i18n.magic.php @@ -2,6 +2,7 @@ /** * Internationalization file. */ +// @codingStandardsIgnoreFile $magicWords = array(); @@ -78,4 +79,4 @@ /** Simplified Chinese (中文(简体)) */ $magicWords['zh-hans'] = array( 'target' = array( 0, '目标' ), -); \ No newline at end of file +); diff --git a/includes/job/MassMessageServerSideJob.php b/includes/job/MassMessageServerSideJob.php index a5dd56e..fb5dad7 100644 --- a/includes/job/MassMessageServerSideJob.php +++ b/includes/job/MassMessageServerSideJob.php @@ -25,10 +25,10 @@ /** * Don't add any hidden comments -* +* @param $stripTildes bool ignored * @return string */ - function makeText() { + function makeText( $stripTildes = false ) { return $this-params['message']; } } -- To view, visit https://gerrit.wikimedia.org/r/196615 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5d369f03ac6aa8be50d5b50254e691d6cdfef9c3 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Legoktm legoktm.wikipe...@gmail.com Gerrit-Reviewer: Siebrand siebr...@kitano.nl Gerrit-Reviewer: Wctaiwan wctai...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] [WIP] Limit trigger for section anchors to text - change (mediawiki/core)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/191845 Change subject: [WIP] Limit trigger for section anchors to text .. [WIP] Limit trigger for section anchors to text Make it so that only hovering over the header text itself triggers section anchors, rather than anywhere on the line. I need help with updating the parser tests. Bug: T18691 Change-Id: I49aea8ffb8662b9c3e860b72cad77d33e9839d07 --- M includes/Linker.php M resources/src/mediawiki/mediawiki.sectionAnchor.css 2 files changed, 3 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/45/191845/1 diff --git a/includes/Linker.php b/includes/Linker.php index ae8695b..2d11d1b 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1751,6 +1751,7 @@ $link, $legacyAnchor = false ) { $ret = h$level$attribs + . span class=\mw-headline-wrapper\ . Html::element( 'a', array( 'href' = '#' . $anchor, @@ -1760,6 +1761,7 @@ wfMessage( 'section-symbol' )-text() ) . span class=\mw-headline\ id=\$anchor\$html/span + . /span . $link . /h$level; if ( $legacyAnchor !== false ) { diff --git a/resources/src/mediawiki/mediawiki.sectionAnchor.css b/resources/src/mediawiki/mediawiki.sectionAnchor.css index 1a8fe0a..730f383 100644 --- a/resources/src/mediawiki/mediawiki.sectionAnchor.css +++ b/resources/src/mediawiki/mediawiki.sectionAnchor.css @@ -42,18 +42,7 @@ color: #000; } -.mw-body h1:hover .mw-headline-anchor, -.mw-body h2:hover .mw-headline-anchor, -.mw-body h3:hover .mw-headline-anchor, -.mw-body h4:hover .mw-headline-anchor, -.mw-body h5:hover .mw-headline-anchor, -.mw-body h6:hover .mw-headline-anchor, -.mw-body h1:focus .mw-headline-anchor, -.mw-body h2:focus .mw-headline-anchor, -.mw-body h3:focus .mw-headline-anchor, -.mw-body h4:focus .mw-headline-anchor, -.mw-body h5:focus .mw-headline-anchor, -.mw-body h6:focus .mw-headline-anchor { +.mw-headline-wrapper:hover .mw-headline-anchor { filter: alpha(opacity=100); opacity: 1; } -- To view, visit https://gerrit.wikimedia.org/r/191845 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I49aea8ffb8662b9c3e860b72cad77d33e9839d07 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add top margin to notice - change (mediawiki...GlobalUserPage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/191528 Change subject: Add top margin to notice .. Add top margin to notice The value is taken from the default for the categories box in Vector. Change-Id: Iaa50a00794b21a4479cb98beb26d95f3ac83003d --- M ext.GlobalUserPage.css 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalUserPage refs/changes/28/191528/1 diff --git a/ext.GlobalUserPage.css b/ext.GlobalUserPage.css index ac3c4d0..6a6a850 100644 --- a/ext.GlobalUserPage.css +++ b/ext.GlobalUserPage.css @@ -4,6 +4,7 @@ .mw-globaluserpage-footer { clear: both; + margin-top: 1em; padding: 3px; border: 1px solid #aaa; font-size: 85%; -- To view, visit https://gerrit.wikimedia.org/r/191528 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaa50a00794b21a4479cb98beb26d95f3ac83003d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GlobalUserPage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make jquery.confirmable not clone title text - change (mediawiki/core)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/190742 Change subject: Make jquery.confirmable not clone title text .. Make jquery.confirmable not clone title text Don't clone the title text, if exists, from the original link when generating the yes / no buttons since it wouldn't make sense on the latter and is unnecessary for the former. Bug: T89572 Change-Id: I7e1e5c6ee78aa54a97205d6682f9520008cc11dd --- M resources/src/jquery/jquery.confirmable.js 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/42/190742/1 diff --git a/resources/src/jquery/jquery.confirmable.js b/resources/src/jquery/jquery.confirmable.js index 339e65a..9effb22 100644 --- a/resources/src/jquery/jquery.confirmable.js +++ b/resources/src/jquery/jquery.confirmable.js @@ -83,7 +83,8 @@ interfaceWidth = $interface.data( 'jquery-confirmable-width' ); elementWidth = $element.data( 'jquery-confirmable-width' ); } else { - $elementClone = $element.clone( true ); + // Clone the link element with the title text removed + $elementClone = $element.clone( true ).removeAttr( 'title' ); $element.addClass( 'jquery-confirmable-element' ); elementWidth = $element.width(); -- To view, visit https://gerrit.wikimedia.org/r/190742 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7e1e5c6ee78aa54a97205d6682f9520008cc11dd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add clear: both; to footer - change (mediawiki...GlobalUserPage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/189047 Change subject: Add clear: both; to footer .. Add clear: both; to footer Change-Id: Ia3c99fd78afd89e4a4f1bbcf93f4e57099496828 --- M ext.GlobalUserPage.css 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GlobalUserPage refs/changes/47/189047/1 diff --git a/ext.GlobalUserPage.css b/ext.GlobalUserPage.css index 21d9763..ac3c4d0 100644 --- a/ext.GlobalUserPage.css +++ b/ext.GlobalUserPage.css @@ -3,6 +3,7 @@ } .mw-globaluserpage-footer { + clear: both; padding: 3px; border: 1px solid #aaa; font-size: 85%; -- To view, visit https://gerrit.wikimedia.org/r/189047 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia3c99fd78afd89e4a4f1bbcf93f4e57099496828 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GlobalUserPage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Code order, whitespace, variable fixes - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/185398 Change subject: Code order, whitespace, variable fixes .. Code order, whitespace, variable fixes Move functions to the top to make them more obvious, fix some whitespaces and remove a variable that's only used twice. Change-Id: I1eaeaf3949210604142895021b9426f2b061e20e --- M modules/ext.MassMessage.create.js 1 file changed, 42 insertions(+), 43 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/98/185398/1 diff --git a/modules/ext.MassMessage.create.js b/modules/ext.MassMessage.create.js index c8fcdd3..c8f6427 100644 --- a/modules/ext.MassMessage.create.js +++ b/modules/ext.MassMessage.create.js @@ -3,52 +3,10 @@ /*global setTimeout, clearTimeout*/ 'use strict'; - var $formImport = $( '#mw-input-wpcontent-import'), - $formSource = $( '#mw-input-wpsource'), + var $formSource = $( '#mw-input-wpsource' ), $formSourceTr = $formSource.parent().parent(), checkSourceTimeout = -1, checkSource, pageIsValidSource, showCreateError, removeCreateError; - - // Set the correct field state on load. - if ( !$formImport.is( ':checked' ) ) { - $formSourceTr.hide(); // Progressive disclosure - } - - $( '#mw-input-wpcontent-new' ).click( function () { - $formSourceTr.hide(); - removeCreateError( 'massmessage-create-invalidsource' ); - } ); - - $formImport.click( function () { - $formSourceTr.show(); - } ); - - // Warn if page title is already in use - $( '#mw-input-wptitle' ).blur( function () { - ( new mw.Api() ).get( { - action: 'query', - prop: 'info', - titles: $( this ).val() - } ).done( function ( data ) { - if ( data data.query ) { - if ( !data.query.pages['-1'] ) { - // Page with title already exists - showCreateError( 'massmessage-create-exists' ); - } else { - removeCreateError( 'massmessage-create-exists' ); - } - } - } ); - } ); - - // Warn if delivery list source is invalid - $formSource.on( 'input autocompleteselect', function () { - // debouncing - don't want to make an API call per request, nor give an error - // when the user starts typing - removeCreateError( 'massmessage-create-invalidsource' ); - clearTimeout(checkSourceTimeout); - checkSourceTimeout = setTimeout(checkSource, 300); - } ); checkSource = function () { ( new mw.Api() ).get( { @@ -98,6 +56,47 @@ $( 'div.error[data-key=\'' + msgKey + '\']' ).remove(); }; + // Set the correct field state on load. + if ( !$( '#mw-input-wpcontent-import' ).is( ':checked' ) ) { + $formSourceTr.hide(); // Progressive disclosure + } + + $( '#mw-input-wpcontent-new' ).click( function () { + $formSourceTr.hide(); + removeCreateError( 'massmessage-create-invalidsource' ); + } ); + + $( '#mw-input-wpcontent-import' ).click( function () { + $formSourceTr.show(); + } ); + + // Warn if page title is already in use + $( '#mw-input-wptitle' ).blur( function () { + ( new mw.Api() ).get( { + action: 'query', + prop: 'info', + titles: $( this ).val() + } ).done( function ( data ) { + if ( data data.query ) { + if ( !data.query.pages['-1'] ) { + // Page with title already exists + showCreateError( 'massmessage-create-exists' ); + } else { + removeCreateError( 'massmessage-create-exists' ); +
[MediaWiki-commits] [Gerrit] Fix sending when $wgEmailConfirmToEdit is true - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/185608 Change subject: Fix sending when $wgEmailConfirmToEdit is true .. Fix sending when $wgEmailConfirmToEdit is true Bug: 73061 Change-Id: I410c5a760248a5b38bb90ac1052930017e18631d --- M MassMessage.hooks.php M MassMessageJob.php 2 files changed, 17 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/08/185608/1 diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index 5be2ba8..3073987 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -170,4 +170,17 @@ return true; } + /** +* Mark the messenger account's email as confirmed in job runs (bug 73061) +* @param User $user +* @param bool $confirmed +* @return bool +*/ + public static function onEmailConfirmed( User $user, $confirmed ) { + if ( $user-getId() === MassMessage::getMessengerUser()-getId() ) { + $confirmed = true; + return false; // Skip further checks + } + return true; + } } diff --git a/MassMessageJob.php b/MassMessageJob.php index 710f6b6..6ed369f 100644 --- a/MassMessageJob.php +++ b/MassMessageJob.php @@ -202,6 +202,10 @@ function makeAPIRequest( array $params ) { global $wgUser, $wgRequest; + // Add our hook function to make the MassMessage user email confirmed + // Done here so that it's not unnecessarily called on every page load + $wgHooks['EmailConfirmed'][] = 'MassMessageHooks::onEmailConfirmed'; + $oldRequest = $wgRequest; $oldUser = $wgUser; -- To view, visit https://gerrit.wikimedia.org/r/185608 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I410c5a760248a5b38bb90ac1052930017e18631d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: REL1_23 Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] [WIP] Make validation errors look consistent - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/185619 Change subject: [WIP] Make validation errors look consistent .. [WIP] Make validation errors look consistent Make it so that validation errors on Special:MassMessage and Special:CreateMassMessageList have the same styling. Change-Id: Id93584eccb0517ff333f10533d3a91bf9cc9cec7 --- M MassMessage.php M modules/ext.MassMessage.special.css A modules/ext.MassMessage.validation.css 3 files changed, 13 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/19/185619/1 diff --git a/MassMessage.php b/MassMessage.php index 3869bb3..28e7fbe 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -127,6 +127,7 @@ 'ext.MassMessage.special.js', 'ext.MassMessage.badhtml.js', ), + 'styles' = 'ext.MassMessage.validation.css', 'messages' = array( 'massmessage-badhtml', 'massmessage-parse-badpage' @@ -188,6 +189,7 @@ ); $wgResourceModules['ext.MassMessage.create'] = array( 'scripts' = 'ext.MassMessage.create.js', + 'styles' = 'ext.MassMessage.validation.css', 'messages' = array( 'massmessage-create-exists', 'massmessage-create-invalidsource', diff --git a/modules/ext.MassMessage.special.css b/modules/ext.MassMessage.special.css index ecfd4ec..0a7dc2b 100644 --- a/modules/ext.MassMessage.special.css +++ b/modules/ext.MassMessage.special.css @@ -1,21 +1,8 @@ /* Formats the Save/Preview buttons to show up on the same line -@author wctaiwan */ #mw-massmessage-form .mw-htmlform-field-HTMLSubmitField, #mw-massmessage-form .mw-htmlform-field-HTMLSubmitField .mw-label, #mw-massmessage-form .mw-htmlform-field-HTMLSubmitField .mw-input { display: inline; -} - -/* -Styles the invalid page warning - */ -#mw-massmessage-form-spamlist-status.invalid { - border: 1px solid #FF8080; - border-bottom-right-radius: 0.8em; - border-top-right-radius: 0.8em; - background-color: #FFC0C0; - color: black; - padding: 2px 1em; } diff --git a/modules/ext.MassMessage.validation.css b/modules/ext.MassMessage.validation.css new file mode 100644 index 000..85a35ef --- /dev/null +++ b/modules/ext.MassMessage.validation.css @@ -0,0 +1,11 @@ +/* +Styles inline validation warnings + */ +#mw-massmessage-form-spamlist-status.invalid { + border: 1px solid #FF8080; + border-bottom-right-radius: 0.8em; + border-top-right-radius: 0.8em; + background-color: #FFC0C0; + color: black; + padding: 2px 1em; +} -- To view, visit https://gerrit.wikimedia.org/r/185619 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id93584eccb0517ff333f10533d3a91bf9cc9cec7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Let subclasses specify content model in JsonContent - change (mediawiki/core)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/184111 Change subject: Let subclasses specify content model in JsonContent .. Let subclasses specify content model in JsonContent This is needed for extensions that subclass JsonContent. Follows up Ifed379ba4674a8289b55 Change-Id: I2f4f9cb343c2ab3ee802b584d3c79d0fafadf9e7 --- M includes/content/JsonContent.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/11/184111/1 diff --git a/includes/content/JsonContent.php b/includes/content/JsonContent.php index ff3b25b..df90f22 100644 --- a/includes/content/JsonContent.php +++ b/includes/content/JsonContent.php @@ -25,8 +25,8 @@ /** * @param string $text JSON */ - public function __construct( $text ) { - parent::__construct( $text, CONTENT_MODEL_JSON ); + public function __construct( $text, $modelId = CONTENT_MODEL_JSON ) { + parent::__construct( $text, $modelId ); } /** -- To view, visit https://gerrit.wikimedia.org/r/184111 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2f4f9cb343c2ab3ee802b584d3c79d0fafadf9e7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use getData() instead of getJsonData() - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/184117 Change subject: Use getData() instead of getJsonData() .. Use getData() instead of getJsonData() wfObjectToArray() is used for targets, since the code as written expects targets to be associative arrays. Change-Id: I22f5bff6fb6133b1a0e94b9df7801416e0c05375 --- M includes/content/MassMessageListContent.php 1 file changed, 16 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/17/184117/1 diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index da33c81..67b8aa0 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -134,11 +134,22 @@ if ( $this-decoded ) { return; } - $data = $this-getJsonData(); - if ( is_array( $data ) ) { - $this-description = array_key_exists( 'description', $data ) ? - $data['description'] : null; - $this-targets = array_key_exists( 'targets', $data ) ? $data['targets'] : null; + $jsonParse = $this-getData(); + $data = $jsonParse-isGood() ? $jsonParse-getValue() : null; + if ( $data ) { + $this-description = isset( $data-description ) ? $data-description : null; + if ( isset( $data-targets ) is_array( $data-targets ) ) { + $this-targets = array(); + foreach ( $data-targets as $target ) { + if ( !is_object( $target ) ) { // There is a malformed target. + $this-targets = null; + break; + } + $this-targets[] = wfObjectToArray( $target ); // Convert target to associative array. + } + } else { + $this-targets = null; + } } $this-decoded = true; } -- To view, visit https://gerrit.wikimedia.org/r/184117 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I22f5bff6fb6133b1a0e94b9df7801416e0c05375 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix embed URL - change (mediawiki...PageDisqus)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/182199 Change subject: Fix embed URL .. Fix embed URL Add missing / to URLs for Disqus JS files. Not sure why it used to work in the first place... Change-Id: I6712b4344a436e88e3347030cc815cb49fd4f618 --- M PageDisqus.body.php 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageDisqus refs/changes/99/182199/1 diff --git a/PageDisqus.body.php b/PageDisqus.body.php index 4873706..f16d8f6 100755 --- a/PageDisqus.body.php +++ b/PageDisqus.body.php @@ -35,8 +35,8 @@ /script br / div id=disqus_thread/div - script type=text/javascript src=http://disqus.com/forums' . $wgPageDisqusShortname . '/embed.js/script - noscripta href=http://disqus.com/forums' . $wgPageDisqusShortname . '/?url=ref' . $noscript . '/a/noscript'; + script type=text/javascript src=http://disqus.com/forums/' . $wgPageDisqusShortname . '/embed.js/script + noscripta href=http://disqus.com/forums/' . $wgPageDisqusShortname . '/?url=ref' . $noscript . '/a/noscript'; return true; } @@ -75,4 +75,4 @@ /script; return true; } -} \ No newline at end of file +} -- To view, visit https://gerrit.wikimedia.org/r/182199 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6712b4344a436e88e3347030cc815cb49fd4f618 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/PageDisqus Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add JSON to docs/contenthandler.txt - change (mediawiki/core)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/182335 Change subject: Add JSON to docs/contenthandler.txt .. Add JSON to docs/contenthandler.txt Bug: T85580 Change-Id: I70edfbe4e50fec0701484d5004a5c673c0dd69b7 --- M docs/contenthandler.txt 1 file changed, 1 insertion(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/35/182335/1 diff --git a/docs/contenthandler.txt b/docs/contenthandler.txt index 3f0fca2..5f9a0b0 100644 --- a/docs/contenthandler.txt +++ b/docs/contenthandler.txt @@ -8,6 +8,7 @@ * wikitext - wikitext, as usual * javascript - user provided javascript code +* json - simple implementation for use by extensions, etc. * css - user provided css code * text - plain text -- To view, visit https://gerrit.wikimedia.org/r/182335 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I70edfbe4e50fec0701484d5004a5c673c0dd69b7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Rename Hooks.php - change (mediawiki...GoogleAppEngine)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/181266 Change subject: Rename Hooks.php .. Rename Hooks.php The extension specifies GoogleAppEngineHooks.php Change-Id: Ic283dccb963761ce0e2eda1454a77fbc3656ee89 --- R GoogleAppEngineHooks.php 1 file changed, 0 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GoogleAppEngine refs/changes/66/181266/1 diff --git a/Hooks.php b/GoogleAppEngineHooks.php similarity index 100% rename from Hooks.php rename to GoogleAppEngineHooks.php -- To view, visit https://gerrit.wikimedia.org/r/181266 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic283dccb963761ce0e2eda1454a77fbc3656ee89 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GoogleAppEngine Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add Special:SkinDistributor to dev tools group - change (mediawiki...ExtensionDistributor)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/175942 Change subject: Add Special:SkinDistributor to dev tools group .. Add Special:SkinDistributor to dev tools group Also add missing i18n string for specialpages-group-developer. Change-Id: I859a23caee23c07c4d1898645d62ca6cbd2bfb03 --- M ExtensionDistributor.php M i18n/en.json M i18n/qqq.json 3 files changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ExtensionDistributor refs/changes/42/175942/1 diff --git a/ExtensionDistributor.php b/ExtensionDistributor.php index 5d2fdbc..81f0f58 100644 --- a/ExtensionDistributor.php +++ b/ExtensionDistributor.php @@ -69,6 +69,7 @@ $wgSpecialPages['ExtensionDistributor'] = 'SpecialExtensionDistributor'; $wgSpecialPages['SkinDistributor'] = 'SpecialSkinDistributor'; $wgSpecialPageGroups['ExtensionDistributor'] = 'developer'; +$wgSpecialPageGroups['SkinDistributor'] = 'developer'; $wgAutoloadClasses['SpecialBaseDistributor'] = $dir . 'SpecialBaseDistributor.php'; $wgAutoloadClasses['SpecialExtensionDistributor'] = $dir . 'SpecialExtensionDistributor.php'; $wgAutoloadClasses['SpecialSkinDistributor'] = $dir . 'SpecialSkinDistributor.php'; diff --git a/i18n/en.json b/i18n/en.json index 60c5274..8edb947 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -26,6 +26,7 @@ extdist-want-more-skins: Get another skin, extdist-tar-error: Unable to fetch archive URL from archive API., extdist-no-branches: Unable to fetch information about any branches., + specialpages-group-developer: Developer tools, apihelp-query+extdistrepos-description: Returns the list of repositories supported by ExtensionDistributor, apihelp-query+extdistrepos-example-1: List repositories } diff --git a/i18n/qqq.json b/i18n/qqq.json index 5953763..e073bd0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -33,6 +33,7 @@ extdist-want-more-skins: Used as link text in [[Special:SkinDistributor]].\n\nThis message follows the Download icon., extdist-tar-error: Used as error message in [[Special:ExtensionDistributor]], when downloading an extension., extdist-no-branches: Error message shown if it can't find any information about any branches, + specialpages-group-developer: {{doc-special-group|that=are related to tools for developers}}, apihelp-query+extdistrepos-description: {{doc-apihelp-description|query+extdistrepos}}, apihelp-query+extdistrepos-example-1: {{doc-apihelp-example|query+extdistrepos}} } -- To view, visit https://gerrit.wikimedia.org/r/175942 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I859a23caee23c07c4d1898645d62ca6cbd2bfb03 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ExtensionDistributor Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add specialpages-group-developer i18n string - change (mediawiki/core)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/175943 Change subject: Add specialpages-group-developer i18n string .. Add specialpages-group-developer i18n string Per discussion at I0db24fcbc7c Change-Id: I56f92ac8f6918a196b0c146f314eaf9a0508aceb --- M languages/i18n/en.json M languages/i18n/qqq.json 2 files changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/43/175943/1 diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 45c7105..a6b20b5 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3323,6 +3323,7 @@ specialpages-group-wiki: Data and tools, specialpages-group-redirects: Redirecting special pages, specialpages-group-spam: Spam tools, + specialpages-group-developer: Developer tools, blankpage: Blank page, intentionallyblankpage: This page is intentionally left blank., external_image_whitelist: #Leave this line exactly as it ispre\n#Put regular expression fragments (just the part that goes between the //) below\n#These will be matched with the URLs of external (hotlinked) images\n#Those that match will be displayed as images, otherwise only a link to the image will be shown\n#Lines beginning with # are treated as comments\n#This is case-insensitive\n\n#Put all regex fragments above this line. Leave this line exactly as it is/pre, diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 9ca2f88..5a181c7 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -3487,6 +3487,7 @@ specialpages-group-wiki: {{doc-special-group|like=[[Special:Version]], [[Special:Statistics]], [[Special:LockDB]], etc}}, specialpages-group-redirects: {{doc-special-group|that=redirect to another location|like=[[Special:Randompage]], [[Special:Mypage]], [[Special:Mytalk]], etc}}, specialpages-group-spam: {{doc-special-group}}, + specialpages-group-developer: {{doc-special-group|that=are related to tools for developers}}, blankpage: {{doc-special|BlankPage|unlisted=1}}\nSee also:\n* {{msg-mw|Intentionallyblankpage|text}}, intentionallyblankpage: Text displayed in [[Special:BlankPage]].\n\nSee also:\n* {{msg-mw|Intentionallyblankpage|page title}}, external_image_whitelist: As usual please leave all the wiki markup, including the spaces, as they are. You can translate the text, including 'Leave this line exactly as it is'. The first line of this messages has one (1) leading space.\n\nSee definition of [[w:Regular_expression|regular expression]] on Wikipedia., -- To view, visit https://gerrit.wikimedia.org/r/175943 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I56f92ac8f6918a196b0c146f314eaf9a0508aceb Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove specialpages-group-developer message - change (mediawiki...CodeReview)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/175946 Change subject: Remove specialpages-group-developer message .. Remove specialpages-group-developer message The message is now part of core. This is a follow-up to I56f92ac8f6918 Change-Id: I0db5c6919da4e309f4433b9d0d49bce8bf3c6fc8 --- M i18n/en.json M i18n/qqq.json 2 files changed, 0 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeReview refs/changes/46/175946/1 diff --git a/i18n/en.json b/i18n/en.json index ae51863..42d1249 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -189,7 +189,6 @@ action-codereview-link-user: link authors to wiki users, action-codereview-associate: manage revision associations, action-codereview-review-own: mark your own revisions as \{{int:code-status-ok}}\ or \{{int:code-status-resolved}}\, - specialpages-group-developer: Developer tools, group-svnadmins: SVN admins, group-svnadmins-member: {{GENDER:$1|SVN admin}}, grouppage-svnadmins: {{ns:project}}:SVN admins, diff --git a/i18n/qqq.json b/i18n/qqq.json index b552e10..9049a9c 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -214,7 +214,6 @@ action-codereview-link-user: {{doc-action|codereview-link-user}}, action-codereview-associate: {{doc-action|codereview-associate}}, action-codereview-review-own: {{doc-action|codereview-review-own}}\nRefers to {{msg-mw|Code-status-ok}} and {{msg-mw|Code-status-resolved}}., - specialpages-group-developer: {{doc-special-group|that=are related to the extensions CodeReview and ExtensionDistributor|like=[[Special:Code]], [[Special:RepoAdmin]], [[Special:ExtensionDistributor]]}}, group-svnadmins: {{doc-group|svnadmins}}, group-svnadmins-member: {{doc-group|svnadmins|member}}, grouppage-svnadmins: {{doc-group|svnadmins|page}}, -- To view, visit https://gerrit.wikimedia.org/r/175946 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0db5c6919da4e309f4433b9d0d49bce8bf3c6fc8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CodeReview Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix inaccurate comment and indentation - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/172016 Change subject: Fix inaccurate comment and indentation .. Fix inaccurate comment and indentation Change-Id: Iedaebb9491b6700bd51cecbbcc4483612ea49be4 --- M modules/ext.MassMessage.special.js 1 file changed, 20 insertions(+), 20 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/16/172016/1 diff --git a/modules/ext.MassMessage.special.js b/modules/ext.MassMessage.special.js index ddfbca8..1f31c1b 100644 --- a/modules/ext.MassMessage.special.js +++ b/modules/ext.MassMessage.special.js @@ -22,27 +22,27 @@ 'prop': 'info', 'indexpageids': true } ).done( function ( data ) { - if ( data data.query - // If the page exists and has a supported content model - ( data.query.pageids[0] !== '-1' - data.query.pages[data.query.pageids[0]].contentmodel === 'wikitext' || - data.query.pages[data.query.pageids[0]].contentmodel === 'MassMessageListContent' ) || - // Or if the text refers to a category - data.query.pages[data.query.pageids[0]].ns === 14 - ) { - // No error message is displayed - $spamliststatus - .removeClass( 'invalid' ) - .text( '' ); - } else { - // Otherwise, display an error notice - $spamliststatus - .addClass( 'invalid' ) - .text( mw.message( 'massmessage-parse-badpage', pagetitle ).text() ); - } - } ); + if ( data data.query + // If the page exists and has a supported content model + ( data.query.pageids[0] !== '-1' + data.query.pages[data.query.pageids[0]].contentmodel === 'wikitext' || + data.query.pages[data.query.pageids[0]].contentmodel === 'MassMessageListContent' ) || + // Or if the text refers to a category + data.query.pages[data.query.pageids[0]].ns === 14 + ) { + // No error message is displayed + $spamliststatus + .removeClass( 'invalid' ) + .text( '' ); + } else { + // Otherwise, display an error notice + $spamliststatus + .addClass( 'invalid' ) + .text( mw.message( 'massmessage-parse-badpage', pagetitle ).text() ); + } + } ); } else { - // If no text is entered or if the text refers to a category, don't display any warning + // If no text is entered, don't display any warning $spamliststatus .removeClass( 'invalid' ) .text( '' ); -- To view, visit https://gerrit.wikimedia.org/r/172016 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iedaebb9491b6700bd51cecbbcc4483612ea49be4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list
[MediaWiki-commits] [Gerrit] Fix sending when $wgEmailConfirmToEdit is true - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/171483 Change subject: Fix sending when $wgEmailConfirmToEdit is true .. Fix sending when $wgEmailConfirmToEdit is true Bug: 73061 Change-Id: I410c5a760248a5b38bb90ac1052930017e18631d --- M MassMessage.hooks.php M MassMessage.php 2 files changed, 18 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/83/171483/1 diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index c81ab21..0389ec8 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -239,4 +239,21 @@ } return true; } + + /** +* Mark the messenger account's email as confirmed if needed (bug 73061) +* @param User $user +* @param bool $confirmed +* @return bool +*/ + public static function onEmailConfirmed( $user, $confirmed ) { + global $wgEmailConfirmToEdit; + if ( $wgEmailConfirmToEdit +$user-getId() === MassMessage::getMessengerUser()-getId() + ) { + $confirmed = true; + return false; // Skip further checks + } + return true; + } } diff --git a/MassMessage.php b/MassMessage.php index c22bdb7..959e402 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -109,6 +109,7 @@ $wgHooks['BeforeEchoEventInsert'][] = 'MassMessageHooks::onBeforeEchoEventInsert'; $wgHooks['SkinTemplateNavigation'][] = 'MassMessageHooks::onSkinTemplateNavigation'; $wgHooks['BeforePageDisplay'][] = 'MassMessageHooks::onBeforePageDisplay'; +$wgHooks['EmailConfirmed'][] = 'MassMessageHooks::onEmailConfirmed'; // Special pages $wgSpecialPages['MassMessage'] = 'SpecialMassMessage'; -- To view, visit https://gerrit.wikimedia.org/r/171483 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I410c5a760248a5b38bb90ac1052930017e18631d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Hide EditMassMessageList in Special:SpecialPages - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/169313 Change subject: Hide EditMassMessageList in Special:SpecialPages .. Hide EditMassMessageList in Special:SpecialPages Change-Id: I2a864807b778a53065ace32e8d6fa3380fe9835b --- M includes/SpecialEditMassMessageList.php 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/13/169313/1 diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 2b643cc..2908abb 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -288,4 +288,8 @@ } return $result; } + + public function isListed() { + return false; + } } -- To view, visit https://gerrit.wikimedia.org/r/169313 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2a864807b778a53065ace32e8d6fa3380fe9835b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Make MassMessageJob methods protected - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/162528 Change subject: Make MassMessageJob methods protected .. Make MassMessageJob methods protected Add explicit access modifiers. Change-Id: I58f225599a5c780ec6e2bce5ce782be42e8302a6 --- M includes/job/MassMessageJob.php 1 file changed, 27 insertions(+), 31 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/28/162528/1 diff --git a/includes/job/MassMessageJob.php b/includes/job/MassMessageJob.php index 1cee03b..f7ed124 100644 --- a/includes/job/MassMessageJob.php +++ b/includes/job/MassMessageJob.php @@ -30,33 +30,11 @@ */ public function run() { $status = $this-sendMessage(); - if ( $status !== true ) { $this-setLastError( $status ); - return false; } - return true; - } - - /** -* Normalizes the title according to $wgNamespacesToConvert and $wgNamespacesToPostIn -* @param Title $title -* @return Title|null null if we shouldn't post on that title -*/ - function normalizeTitle( Title $title ) { - global $wgNamespacesToPostIn, $wgNamespacesToConvert; - if ( isset( $wgNamespacesToConvert[$title-getNamespace()] ) ) { - $title = Title::makeTitle( $wgNamespacesToConvert[$title-getNamespace()], $title-getText() ); - } - $title = MassMessage::followRedirect( $title ) ?: $title; // Try to follow redirects - if ( !$title-isTalkPage() !in_array( $title-getNamespace(), $wgNamespacesToPostIn ) ) { - $this-logLocalSkip( 'skipbadns'); - $title = null; - } - - return $title; } /** @@ -78,11 +56,30 @@ } /** +* Normalizes the title according to $wgNamespacesToConvert and $wgNamespacesToPostIn +* @param Title $title +* @return Title|null null if we shouldn't post on that title +*/ + protected function normalizeTitle( Title $title ) { + global $wgNamespacesToPostIn, $wgNamespacesToConvert; + if ( isset( $wgNamespacesToConvert[$title-getNamespace()] ) ) { + $title = Title::makeTitle( $wgNamespacesToConvert[$title-getNamespace()], $title-getText() ); + } + $title = MassMessage::followRedirect( $title ) ?: $title; // Try to follow redirects + if ( !$title-isTalkPage() !in_array( $title-getNamespace(), $wgNamespacesToPostIn ) ) { + $this-logLocalSkip( 'skipbadns'); + $title = null; + } + + return $title; + } + + /** * Log any skips on the target site * * @param $reason string log subtype */ - function logLocalSkip( $reason ) { + protected function logLocalSkip( $reason ) { $logEntry = new ManualLogEntry( 'massmessage', $reason ); $logEntry-setPerformer( MassMessage::getMessengerUser() ); $logEntry-setTarget( $this-title ); @@ -100,7 +97,7 @@ * * @param $reason string */ - function logLocalFailure( $reason ) { + protected function logLocalFailure( $reason ) { $logEntry = new ManualLogEntry( 'massmessage', 'failure' ); $logEntry-setPerformer( MassMessage::getMessengerUser() ); @@ -126,7 +123,7 @@ * * @return bool */ - function sendMessage() { + protected function sendMessage() { $title = $this-normalizeTitle( $this-title ); if ( $title === null ) { return true; // Skip it @@ -163,7 +160,7 @@ return true; } - function editPage() { + protected function editPage() { $user = MassMessage::getMessengerUser(); $params = array( 'action' = 'edit', @@ -179,7 +176,7 @@ $this-makeAPIRequest( $params ); } - function addLQTThread() { + protected function addLQTThread() { $user = MassMessage::getMessengerUser(); $params = array( 'action' = 'threadaction', @@ -193,7 +190,7 @@ $this-makeAPIRequest( $params ); } - function addFlowTopic() { + protected function addFlowTopic() { $user = MassMessage::getMessengerUser(); $params = array( 'action' = 'flow', @@ -211,13 +208,13 @@ * Add some stuff to the end of the message * @return string */ - function makeText() { + protected
[MediaWiki-commits] [Gerrit] Strip signatures for Flow and LQT - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/162533 Change subject: Strip signatures for Flow and LQT .. Strip signatures for Flow and LQT Change-Id: I04689ba74f2c02b034be2665572d553fb99d2b21 --- M includes/job/MassMessageJob.php 1 file changed, 12 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/33/162533/1 diff --git a/includes/job/MassMessageJob.php b/includes/job/MassMessageJob.php index f7ed124..bf91b30 100644 --- a/includes/job/MassMessageJob.php +++ b/includes/job/MassMessageJob.php @@ -167,7 +167,7 @@ 'title' = $this-title-getPrefixedText(), 'section' = 'new', 'summary' = $this-params['subject'], - 'text' = $this-makeText(), + 'text' = $this-makeText( false ), 'notminor' = true, 'bot' = true, 'token' = $user-getEditToken() @@ -183,7 +183,7 @@ 'threadaction' = 'newthread', 'talkpage' = $this-title, 'subject' = $this-params['subject'], - 'text' = $this-makeText(), + 'text' = $this-makeText( true ), 'token' = $user-getEditToken() ); // LQT will automatically mark the edit as bot if we're a bot @@ -197,7 +197,7 @@ 'page' = $this-title-getPrefixedText(), 'submodule' = 'new-topic', 'nttopic' = $this-params['subject'], - 'ntcontent' = $this-makeText(), + 'ntcontent' = $this-makeText( true ), 'token' = $user-getEditToken(), ); @@ -206,10 +206,17 @@ /** * Add some stuff to the end of the message +* @param bool $stripTildes Whether to strip trailing '' * @return string */ - protected function makeText() { - $text = $this-params['message']; + protected function makeText( $stripTildes ) { + $text = rtrim( $this-params['message'] ); + if ( $stripTildes +substr( $text, -4 ) === '' +substr( $text, -5 ) !== '~' + ) { + $text = substr( $text, 0, -4 ); + } $text .= \n . wfMessage( 'massmessage-hidden-comment' )-params( $this-params['comment'] )-text(); return $text; } -- To view, visit https://gerrit.wikimedia.org/r/162533 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I04689ba74f2c02b034be2665572d553fb99d2b21 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Cache non-category targets - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/161887 Change subject: Cache non-category targets .. Cache non-category targets Category targets are not cached because the cache key scheme doesn't work for them and parser function targets are the expensive ones. Change-Id: Id74e240e898e2fa5c027ebd438b149a67db6a19b --- M includes/MassMessageTargets.php 1 file changed, 21 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/87/161887/1 diff --git a/includes/MassMessageTargets.php b/includes/MassMessageTargets.php index cc46bcc..42b341f 100644 --- a/includes/MassMessageTargets.php +++ b/includes/MassMessageTargets.php @@ -14,13 +14,29 @@ * wiki: The ID of the wiki (wfWikiID() for the local wiki) * site: The hostname and port (if exists) of the wiki * +* Normalized targets are briefly cached because it can be expensive to parse PF targets on both +* preview and save in SpecialMassMessage. +* * @param Title $spamlist * @param $normalize Whether to normalize and deduplicate the targets * @return array|null */ public static function getTargets( Title $spamlist, $normalize = true ) { + global $wgMemc; + if ( !$spamlist-exists() !$spamlist-inNamespace( NS_CATEGORY ) ) { return null; + } + + // Try to lookup cached targets + $cacheKey = null; + if ( !$spamlist-inNamespace( NS_CATEGORY ) ) { + $cacheKey = wfMemcKey( 'massmessage', 'targets', $spamlist-getLatestRevId(), + $spamlist-getTouched() ); + $cacheTargets = $wgMemc-get( $cacheKey ); + if ( $cacheTargets !== false ) { + return $cacheTargets; + } } if ( $spamlist-inNamespace( NS_CATEGORY ) ) { @@ -38,7 +54,11 @@ } if ( $normalize ) { - return self::normalizeTargets( $targets ); + $normalized = self::normalizeTargets( $targets ); + if ( $cacheKey ) { // $spamlist is not a category + $wgMemc-set( $cacheKey, $normalized, 60 * 20 ); + } + return $normalized; } else { return $targets; } -- To view, visit https://gerrit.wikimedia.org/r/161887 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id74e240e898e2fa5c027ebd438b149a67db6a19b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use __DIR__ directly - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/161890 Change subject: Use __DIR__ directly .. Use __DIR__ directly Change-Id: Id743071c52563954d13e7591f0cd54991c3cd774 --- M MassMessage.php 1 file changed, 31 insertions(+), 32 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/90/161890/1 diff --git a/MassMessage.php b/MassMessage.php index 77ac57b..6728190 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -57,33 +57,32 @@ 'descriptionmsg' = 'massmessage-desc', 'version' = '0.2.0', ); -$dir = __DIR__; // Messages -$wgMessagesDirs['MassMessage'] = $dir/i18n; -$wgExtensionMessagesFiles['MassMessageAlias'] = $dir/MassMessage.alias.php; -$wgExtensionMessagesFiles['MassMessageMagic'] = $dir/MassMessage.i18n.magic.php; +$wgMessagesDirs['MassMessage'] = __DIR__ . '/i18n'; +$wgExtensionMessagesFiles['MassMessageAlias'] = __DIR__ . '/MassMessage.alias.php'; +$wgExtensionMessagesFiles['MassMessageMagic'] = __DIR__ . '/MassMessage.i18n.magic.php'; // Classes -$wgAutoloadClasses['MassMessageHooks'] = $dir/MassMessage.hooks.php; -$wgAutoloadClasses['ApiMassMessage'] = $dir/includes/ApiMassMessage.php; -$wgAutoloadClasses['ApiEditMassMessageList'] = $dir/includes/ApiEditMassMessageList.php; -$wgAutoloadClasses['ApiQueryMMSites'] = $dir/includes/ApiQueryMMSites.php; -$wgAutoloadClasses['MassMessage'] = $dir/includes/MassMessage.php; -$wgAutoloadClasses['MassMessageTargets'] = $dir/includes/MassMessageTargets.php; -$wgAutoloadClasses['SpecialMassMessage'] = $dir/includes/SpecialMassMessage.php; -$wgAutoloadClasses['SpecialCreateMassMessageList'] = $dir/includes/SpecialCreateMassMessageList.php; -$wgAutoloadClasses['SpecialEditMassMessageList'] = $dir/includes/SpecialEditMassMessageList.php; -$wgAutoloadClasses['MassMessageJob'] = $dir/includes/job/MassMessageJob.php; -$wgAutoloadClasses['MassMessageSubmitJob'] = $dir/includes/job/MassMessageSubmitJob.php; -$wgAutoloadClasses['MassMessageFailureLogFormatter'] = $dir/includes/logging/MassMessageFailureLogFormatter.php; -$wgAutoloadClasses['MassMessageSendLogFormatter'] = $dir/includes/logging/MassMessageSendLogFormatter.php; -$wgAutoloadClasses['MassMessageSkipLogFormatter'] = $dir/includes/logging/MassMessageSkipLogFormatter.php; -$wgAutoloadClasses['MassMessageListContent'] = $dir/includes/content/MassMessageListContent.php; -$wgAutoloadClasses['MassMessageListContentHandler'] = $dir/includes/content/MassMessageListContentHandler.php; -$wgAutoloadClasses['MassMessageListDiffEngine'] = $dir/includes/content/MassMessageListDiffEngine.php; -$wgAutoloadClasses['MassMessageTestCase'] = $dir/tests/MassMessageTestCase.php; -$wgAutoloadClasses['MassMessageApiTestCase'] = $dir/tests/MassMessageApiTestCase.php; +$wgAutoloadClasses['MassMessageHooks'] = __DIR__ . '/MassMessage.hooks.php'; +$wgAutoloadClasses['ApiMassMessage'] = __DIR__ . '/includes/ApiMassMessage.php'; +$wgAutoloadClasses['ApiEditMassMessageList'] = __DIR__ . '/includes/ApiEditMassMessageList.php'; +$wgAutoloadClasses['ApiQueryMMSites'] = __DIR__ . '/includes/ApiQueryMMSites.php'; +$wgAutoloadClasses['MassMessage'] = __DIR__ . '/includes/MassMessage.php'; +$wgAutoloadClasses['MassMessageTargets'] = __DIR__ . '/includes/MassMessageTargets.php'; +$wgAutoloadClasses['SpecialMassMessage'] = __DIR__ . '/includes/SpecialMassMessage.php'; +$wgAutoloadClasses['SpecialCreateMassMessageList'] = __DIR__ . '/includes/SpecialCreateMassMessageList.php'; +$wgAutoloadClasses['SpecialEditMassMessageList'] = __DIR__ . '/includes/SpecialEditMassMessageList.php'; +$wgAutoloadClasses['MassMessageJob'] = __DIR__ . '/includes/job/MassMessageJob.php'; +$wgAutoloadClasses['MassMessageSubmitJob'] = __DIR__ . '/includes/job/MassMessageSubmitJob.php'; +$wgAutoloadClasses['MassMessageFailureLogFormatter'] = __DIR__ . '/includes/logging/MassMessageFailureLogFormatter.php'; +$wgAutoloadClasses['MassMessageSendLogFormatter'] = __DIR__ . '/includes/logging/MassMessageSendLogFormatter.php'; +$wgAutoloadClasses['MassMessageSkipLogFormatter'] = __DIR__ . '/includes/logging/MassMessageSkipLogFormatter.php'; +$wgAutoloadClasses['MassMessageListContent'] = __DIR__ . '/includes/content/MassMessageListContent.php'; +$wgAutoloadClasses['MassMessageListContentHandler'] = __DIR__ . '/includes/content/MassMessageListContentHandler.php'; +$wgAutoloadClasses['MassMessageListDiffEngine'] = __DIR__ . '/includes/content/MassMessageListDiffEngine.php'; +$wgAutoloadClasses['MassMessageTestCase'] = __DIR__ . '/tests/MassMessageTestCase.php'; +$wgAutoloadClasses['MassMessageApiTestCase'] = __DIR__ . '/tests/MassMessageApiTestCase.php'; // ContentHandler $wgContentHandlers['MassMessageListContent'] = 'MassMessageListContentHandler'; @@ -118,7 +117,7 @@ $wgResourceModules['ext.MassMessage.autocomplete'] = array( 'scripts' =
[MediaWiki-commits] [Gerrit] Integrate normalizeTargets into getTargets - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/161683 Change subject: Integrate normalizeTargets into getTargets .. Integrate normalizeTargets into getTargets Change-Id: Ie2c3813c916df51a06140b3d5fd532047debe210 --- M includes/MassMessage.php M includes/MassMessageTargets.php M includes/SpecialCreateMassMessageList.php M includes/SpecialMassMessage.php M tests/MassMessageTargetsTest.php 5 files changed, 22 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/83/161683/1 diff --git a/includes/MassMessage.php b/includes/MassMessage.php index 215bdda..a5f915c 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -316,9 +316,7 @@ $spamlist = self::getSpamlist( $data['spamlist'] ); // Get the array of pages to deliver to. - $pages = MassMessageTargets::normalizeTargets( - MassMessageTargets::getTargets( $spamlist ) - ); + $pages = MassMessageTargets::getTargets( $spamlist ); // Log it. self::logToWiki( $spamlist, $user, $data['subject'] ); diff --git a/includes/MassMessageTargets.php b/includes/MassMessageTargets.php index 714a4ff..cc46bcc 100644 --- a/includes/MassMessageTargets.php +++ b/includes/MassMessageTargets.php @@ -15,30 +15,41 @@ * site: The hostname and port (if exists) of the wiki * * @param Title $spamlist +* @param $normalize Whether to normalize and deduplicate the targets * @return array|null */ -public static function getTargets( Title $spamlist ) { +public static function getTargets( Title $spamlist, $normalize = true ) { if ( !$spamlist-exists() !$spamlist-inNamespace( NS_CATEGORY ) ) { return null; } if ( $spamlist-inNamespace( NS_CATEGORY ) ) { - return self::getCategoryTargets( $spamlist ); + $targets = self::getCategoryTargets( $spamlist ); } elseif ( $spamlist-hasContentModel( 'MassMessageListContent' ) ) { - return self::getMassMessageListContentTargets( $spamlist ); + $targets = self::getMassMessageListContentTargets( $spamlist ); } elseif ( $spamlist-hasContentModel( CONTENT_MODEL_WIKITEXT ) ) { - return self::getParserFunctionTargets( $spamlist ); + $targets = self::getParserFunctionTargets( $spamlist ); } else { - return null; + $targets = null; + } + + if ( !$targets ) { + return $targets; // null or empty array + } + + if ( $normalize ) { + return self::normalizeTargets( $targets ); + } else { + return $targets; } } /** * Get array of normalized targets with duplicates removed -* @param array $data +* @param array $data * @return array */ - public static function normalizeTargets( array $data ) { + protected static function normalizeTargets( array $data ) { global $wgNamespacesToConvert; foreach ( $data as $target ) { diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index cfa1afe..60386e8 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -113,7 +113,7 @@ * @return array|null */ protected function getTargets( Title $source ) { - $pages = MassMessageTargets::getTargets( $source ); + $pages = MassMessageTargets::getTargets( $source, /* $normalize = */ false ); if ( $pages === null ) { return null; } diff --git a/includes/SpecialMassMessage.php b/includes/SpecialMassMessage.php index e53f328..08d084e 100644 --- a/includes/SpecialMassMessage.php +++ b/includes/SpecialMassMessage.php @@ -264,9 +264,7 @@ // Output the number of recipients $spamlist = MassMessage::getSpamlist( $data['spamlist'] ); - $targets = MassMessageTargets::normalizeTargets( - MassMessageTargets::getTargets( $spamlist ) - ); + $targets = MassMessageTargets::getTargets( $spamlist ); $infoFieldset = Xml::fieldset( $this-msg( 'massmessage-fieldset-info' )-text(), $this-msg( 'massmessage-preview-count' )-numParams( count( $targets ) )-parse() diff --git a/tests/MassMessageTargetsTest.php
[MediaWiki-commits] [Gerrit] Use Title::hasContentModel() instead of a direct comparison - change (mediawiki...Thanks)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/160873 Change subject: Use Title::hasContentModel() instead of a direct comparison .. Use Title::hasContentModel() instead of a direct comparison Change-Id: Icbc78e38548fbd7f23fdf84a140b205668a80a86 --- M Thanks.hooks.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Thanks refs/changes/73/160873/1 diff --git a/Thanks.hooks.php b/Thanks.hooks.php index 2b91c7a..1f46164 100644 --- a/Thanks.hooks.php +++ b/Thanks.hooks.php @@ -281,7 +281,7 @@ * @return bool */ public static function onBeforePageDisplay( OutputPage $out, $skin ) { - if ( $out-getTitle()-getContentModel() === 'flow-board' ) { + if ( $out-getTitle()-hasContentModel( 'flow-board' ) ) { $out-addModules( 'ext.thanks.flowthank' ); } return true; -- To view, visit https://gerrit.wikimedia.org/r/160873 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icbc78e38548fbd7f23fdf84a140b205668a80a86 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Thanks Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com Gerrit-Reviewer: Legoktm legoktm.wikipe...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Output the number of recipients on preview - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/160787 Change subject: Output the number of recipients on preview .. Output the number of recipients on preview This is basically a rebase of Ia052b3deba0b4d463e9cbaca7338b64865f101ea Bug: 57472 Change-Id: I342f1e61bbb0254027de173c534ab064e6e89fca --- M i18n/en.json M i18n/qqq.json M includes/SpecialMassMessage.php 3 files changed, 17 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/87/160787/1 diff --git a/i18n/en.json b/i18n/en.json index 2a6867e..2e450fc 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -15,6 +15,8 @@ massmessage-form-preview: Preview, massmessage-form-submit: Send, massmessage-fieldset-preview: Preview, + massmessage-fieldset-info: Information, + massmessage-preview-count: Your message will be sent to {{PLURAL:$1|$1 page|$1 pages}}., massmessage-submitted: Your message delivery to {{PLURAL:$1|$1 page|$1 pages}} has been queued., massmessage-just-preview: This is just a preview. Press \{{int:massmessage-form-submit}}\ to send the message., massmessage-spamlist-doesnotexist: The specified delivery list page or category does not exist., diff --git a/i18n/qqq.json b/i18n/qqq.json index 33c0dbf..c1ea39d 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -17,6 +17,8 @@ massmessage-form-preview: Label for the preview button on [[Special:MassMessage]].\n{{Identical|Preview}}, massmessage-form-submit: Label for the submit button on [[Special:MassMessage]].\n\nUsed in {{msg-mw|Massmessage-just-preview}}.\n{{Identical|Send}}, massmessage-fieldset-preview: Label for the fieldset box around the page preview.\n{{Identical|Preview}}, + massmessage-fieldset-info: Label for the fieldset box around the delivery information, + massmessage-preview-count: Text indicating how many pages the message will be sent to\n* $1 is the number of pages., massmessage-submitted: Confirmation message the user sees after the form is submitted successfully and the request is queued in the job queue.\n\nParameters:\n* $1 - the number of deliveries that have been queued, massmessage-just-preview: Warning to user that what they are seeing is just a preview, and they should hit the send button to actually submit it.\n\nRefers to {{msg-mw|Massmessage-form-submit}}., massmessage-spamlist-doesnotexist: Error message the user sees if the delivery list page or category they entered does not exist., diff --git a/includes/SpecialMassMessage.php b/includes/SpecialMassMessage.php index f616cef..85a79da 100644 --- a/includes/SpecialMassMessage.php +++ b/includes/SpecialMassMessage.php @@ -261,6 +261,19 @@ * @return Status */ protected function preview( array $data ) { + $this-getOutput()-addWikiMsg( 'massmessage-just-preview' ); + + // Output the number of recipients + $spamlist = MassMessage::getSpamlist( $data['spamlist'] ); + $targets = MassMessageTargets::normalizeTargets( + MassMessageTargets::getTargets( $spamlist, $this-getContext() ) + ); + $infoFieldset = Xml::fieldset( + $this-msg( 'massmessage-fieldset-info' )-text(), + $this-msg( 'massmessage-preview-count' )-numParams( count( $targets ) )-parse() + ); + $this-getOutput()-addHTML( $infoFieldset ); + // Use a mock target as the context for rendering the preview $mockTarget = Title::newFromText( 'Project:Example' ); $wikipage = WikiPage::factory( $mockTarget ); @@ -281,7 +294,6 @@ $content = $content-preSaveTransform( $mockTarget, MassMessage::getMessengerUser(), $parserOptions ); $parserOutput = $content-getParserOutput( $mockTarget, null, $parserOptions ); $previewHTML = $parserOutput-getText(); - $this-getOutput()-addWikiMsg( 'massmessage-just-preview' ); $fieldsetMessage = $this-msg( 'massmessage-fieldset-preview' )-text(); $wrapFieldset = Xml::fieldset( $fieldsetMessage, $previewHTML ); $this-getOutput()-addHTML( $wrapFieldset ); -- To view, visit https://gerrit.wikimedia.org/r/160787 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I342f1e61bbb0254027de173c534ab064e6e89fca Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Clean up SpecialMassMessage - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/160792 Change subject: Clean up SpecialMassMessage .. Clean up SpecialMassMessage Minor refactor of some logic and clean up some comments. Should not change actual behaviour. Change-Id: I7a92825edf24de0ad3c01f5b91b16982e79faa62 --- M includes/SpecialMassMessage.php 1 file changed, 12 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/92/160792/1 diff --git a/includes/SpecialMassMessage.php b/includes/SpecialMassMessage.php index 85a79da..217b1a8 100644 --- a/includes/SpecialMassMessage.php +++ b/includes/SpecialMassMessage.php @@ -166,11 +166,10 @@ /** * Callback function * Does some basic verification of data -* Decides whether to show the preview screen -* or the submitted message +* Decides whether to show the preview screen or the submitted message * * @param $data Array -* @return Status +* @return Status|bool */ public function callback( array $data ) { @@ -179,7 +178,6 @@ // Die on errors. if ( !$this-status-isOK() ) { $this-state = 'form'; - return $this-status; } @@ -187,7 +185,8 @@ $this-count = MassMessage::submit( $this-getContext(), $data ); return $this-status; } else { // $this-state can only be 'preview' here - return $this-preview( $data ); + $this-preview( $data ); + return false; // No submission attempted } } @@ -256,9 +255,9 @@ /** * A preview/confirmation screen +* The preview generation code was hacked up from EditPage.php * * @param $data Array -* @return Status */ protected function preview( array $data ) { $this-getOutput()-addWikiMsg( 'massmessage-just-preview' ); @@ -278,8 +277,6 @@ $mockTarget = Title::newFromText( 'Project:Example' ); $wikipage = WikiPage::factory( $mockTarget ); - // Hacked up from EditPage.php - // Convert into a content object $content = ContentHandler::makeContent( $data['message'], $mockTarget ); // Parser stuff. Taken from EditPage::getPreviewText() @@ -291,12 +288,14 @@ // Hooks not being run: EditPageGetPreviewContent, EditPageGetPreviewText - $content = $content-preSaveTransform( $mockTarget, MassMessage::getMessengerUser(), $parserOptions ); + $content = $content-preSaveTransform( $mockTarget, MassMessage::getMessengerUser(), + $parserOptions ); $parserOutput = $content-getParserOutput( $mockTarget, null, $parserOptions ); - $previewHTML = $parserOutput-getText(); - $fieldsetMessage = $this-msg( 'massmessage-fieldset-preview' )-text(); - $wrapFieldset = Xml::fieldset( $fieldsetMessage, $previewHTML ); - $this-getOutput()-addHTML( $wrapFieldset ); + $previewFieldset = Xml::fieldset( + $this-msg( 'massmessage-fieldset-preview' )-text(), + $parserOutput-getText() + ); + $this-getOutput()-addHTML( $previewFieldset ); // Check if we have unescaped langlinks (Bug 54846) if ( $parserOutput-getLanguageLinks() ) { @@ -317,7 +316,5 @@ if ( !preg_match( MassMessage::getTimestampRegex(), $content-getNativeData() ) ) { $this-status-fatal( 'massmessage-no-timestamp' ); } - - return false; } } -- To view, visit https://gerrit.wikimedia.org/r/160792 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7a92825edf24de0ad3c01f5b91b16982e79faa62 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Reject empty categories as import sources - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/158940 Change subject: Reject empty categories as import sources .. Reject empty categories as import sources Don't allow empty categories to be used as sources for importing target pages in Special:CreateMassMessageList Bug: 70522 Change-Id: I329fec8b56e5ea25a27d770382bbf2c286c1a82d --- M includes/SpecialCreateMassMessageList.php 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/40/158940/1 diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index 782aac8..e8f2147 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -58,7 +58,10 @@ if ( $data['content'] === 'import' ) { // Importing from an existing list $source = Title::newFromText( $data['source'] ); - if ( !$source ) { + if ( !$source + || ( $source-inNamespace( NS_CATEGORY ) +Category::newFromTitle( $source )-getPageCount() === 0 ) + ) { return Status::newFatal( 'massmessage-create-invalidsource' ); } -- To view, visit https://gerrit.wikimedia.org/r/158940 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I329fec8b56e5ea25a27d770382bbf2c286c1a82d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Improve title checking in extractTarget - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/158882 Change subject: Improve title checking in extractTarget .. Improve title checking in extractTarget Block titles containing only a fragment (e.g. #Example) and pages in NS_MEDIA. Change-Id: I7e01e63717b99fe6937fa8598fdaffe8fdfe4527 --- M includes/content/MassMessageListContentHandler.php 1 file changed, 5 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/82/158882/1 diff --git a/includes/content/MassMessageListContentHandler.php b/includes/content/MassMessageListContentHandler.php index acfe224..36bf8cd 100644 --- a/includes/content/MassMessageListContentHandler.php +++ b/includes/content/MassMessageListContentHandler.php @@ -147,7 +147,11 @@ $result = array(); $title = Title::newFromText( $titleText ); - if ( !$title || $title-isSpecialPage() || $title-isExternal() ) { + if ( !$title + || $title-getText() === '' + || !$title-canExist() + || $title-isExternal() + ) { $result['errors'] = array( 'invalidtitle' ); } else { $result['title'] = $title-getPrefixedText(); // Use the canonical form. -- To view, visit https://gerrit.wikimedia.org/r/158882 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7e01e63717b99fe6937fa8598fdaffe8fdfe4527 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix determination of $revId - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/158849 Change subject: Fix determination of $revId .. Fix determination of $revId Change-Id: I75cb898dcd20db8052688152d55a8f3d63e9e241 --- M MassMessage.hooks.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/49/158849/1 diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index f788938..bb0589b 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -162,7 +162,7 @@ $request = $sktemplate-getRequest(); $direction = $request-getVal( 'direction' ); $diff = $request-getVal( 'diff' ); - $oldid = $request-getInt( 'oldid' ); + $oldid = $request-getInt( 'oldid' ); // Guaranteed to be an integer, 0 if invalid if ( $direction === 'next' $oldid 0 ) { $next = $title-getNextRevisionId( $oldid ); $revId = ( $next ) ? $next : $oldid; @@ -174,7 +174,7 @@ $revId = (int)$diff; } elseif ( $diff === 'next' $oldid 0 ) { $next = $title-getNextRevisionId( $oldid ); - $revId = ( $next ) ? $next : $revId; + $revId = ( $next ) ? $next : $oldid; } else { // diff is 'prev' or gibberish $revId = $oldid; } -- To view, visit https://gerrit.wikimedia.org/r/158849 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I75cb898dcd20db8052688152d55a8f3d63e9e241 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Merge branch 'contenthandler' - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/157332 Change subject: Merge branch 'contenthandler' .. Merge branch 'contenthandler' Change-Id: I9e4edb664506660a02eaa0373eaa00602fe741b6 --- M MassMessage.alias.php M i18n/en.json 2 files changed, 1 insertion(+), 44 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/32/157332/1 diff --git a/MassMessage.alias.php b/MassMessage.alias.php index a819b8e..3a704c4 100644 --- a/MassMessage.alias.php +++ b/MassMessage.alias.php @@ -114,4 +114,4 @@ /** Traditional Chinese (中文(繁體)) */ $specialPageAliases['zh-hant'] = array( 'MassMessage' = array( '大量資訊' ), -); +); \ No newline at end of file diff --git a/i18n/en.json b/i18n/en.json index 94b16ee..2677921 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -1,48 +1,6 @@ { @metadata: { authors: [ - HEAD (e6e7fb Merge Remove deprecated getResultProperties (since 1.24)) - Kunal Mehta - ] - }, - massmessage: Send mass message, - massmessage-desc: Allows users to easily send a message to a list of users, - massmessage-form-spamlist: Page or category containing list of pages to leave a message on:, - massmessage-form-subject: Subject of the message (also used as the edit summary):, - massmessage-form-message: Body of the message:, - massmessage-form-preview: Preview, - massmessage-form-submit: Send, - massmessage-fieldset-preview: Preview, - massmessage-submitted: Your message delivery to {{PLURAL:$1|$1 page|$1 pages}} has been queued., - massmessage-just-preview: This is just a preview. Press \{{int:massmessage-form-submit}}\ to send the message., - massmessage-spamlist-doesnotexist: The specified page-list page does not exist., - massmessage-empty-subject: The subject line is empty., - massmessage-empty-message: The message body is empty., - massmessage-unescaped-langlinks: Warning: There are unescaped language links in your message., - massmessage-no-timestamp: Warning: Your message does not include a timestamp or signature., - massmessage-form-header: Use the form below to send messages to a specified list. All fields are required ([https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Extension:MassMessage more information])., - massmessage-target: [//$1$2?title={{urlencode:$3|WIKI}} $3], - massmessage-queued-count: Queued [[Special:MassMessage|mass messages]], - massmessage-hidden-comment: !-- Message sent by User:$1@$2 using the list at $3 --, - massmessage-optout-category: Opted-out of message delivery, - massmessage-badhtml: Your message may have {{PLURAL:$2|an unclosed HTML tag|unclosed HTML tags}}: $1., - massmessage-parse-badurl: \$1\ is not a valid site., - massmessage-parse-badpage: \$1\ is not a valid page title., - massmessage-global-disallowed: Messages can only be sent to local pages., - right-massmessage: Send a message to multiple users at once, - action-massmessage: send a message to multiple users at once, - log-name-massmessage: Mass message log, - log-description-massmessage: These events track users sending messages., - logentry-massmessage-send: $1 {{GENDER:$2|sent a message}} to $3, - logentry-massmessage-failure: Delivery of \$4\ to $3 failed with an error code of code$5/code, - logentry-massmessage-skipbadns: Delivery of \$4\ to $3 was skipped because target was in a namespace that cannot be posted in, - logentry-massmessage-skipoptout: Delivery of \$4\ to $3 was skipped because target has opted-out of message delivery, - logentry-massmessage-skipnouser: Delivery of \$4\ to $3 was skipped because user account does not exist, - massmessage-cannot-rename: This is a system account and cannot be renamed., - massmessage-message-footer: , - massmessage-nextsteps: [[Special:MassMessage|Send another message]] or [[Special:Statistics|view how many messages are queued]]. -} -=== Kunal Mehta, wctaiwan ] @@ -146,4 +104,3 @@ massmessage-list-category: MassMessage delivery lists, massmessage-list-category-desc: The page is a delivery list for the [[Special:MassMessage|MassMessage]] extension. } - BRANCH (a3ae50 Add tests to Database group) -- To view, visit https://gerrit.wikimedia.org/r/157332 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9e4edb664506660a02eaa0373eaa00602fe741b6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing
[MediaWiki-commits] [Gerrit] Fix retrieval of query modules - change (mediawiki...ApiSandbox)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/156500 Change subject: Fix retrieval of query modules .. Fix retrieval of query modules Bug: 69872 Change-Id: I79bd2901c92c2afd3b294aa3c52f4cc35a6cf4d8 --- M SpecialApiSandbox.php 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ApiSandbox refs/changes/00/156500/1 diff --git a/SpecialApiSandbox.php b/SpecialApiSandbox.php index d25d3f8..f091f32 100644 --- a/SpecialApiSandbox.php +++ b/SpecialApiSandbox.php @@ -129,9 +129,9 @@ */ private function getQueryModules( $type ) { $options = array(); - $params = $this-apiQuery-getAllowedParams(); - sort( $params[$type][ApiBase::PARAM_TYPE] ); - foreach ( $params[$type][ApiBase::PARAM_TYPE] as $module ) { + $modules = $this-apiQuery-getModuleManager()-getNames( $type ); + sort( $modules ); + foreach ( $modules as $module ) { $options[$type=$module] = $type=$module; } -- To view, visit https://gerrit.wikimedia.org/r/156500 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I79bd2901c92c2afd3b294aa3c52f4cc35a6cf4d8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/ApiSandbox Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move call to onUserGetRights - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/156307 Change subject: Move call to onUserGetRights .. Move call to onUserGetRights Move it inside MassMessageJob so it's not called on every page load. Bug: 69381 Change-Id: I3a955526f1bc613d4eb79c5003012eda0a221fa1 --- M MassMessage.hooks.php M MassMessage.php M includes/job/MassMessageJob.php 3 files changed, 6 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/07/156307/1 diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index 432874a..afe8d26 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -156,6 +156,7 @@ /** * Makes the messenger sender exempt from IP blocks no matter what +* Called only if the context is a MassMessage job (bug 69381) * @see bug 58237 * @param User $user * @param array $rights diff --git a/MassMessage.php b/MassMessage.php index 0225dc3..ca6c0c9 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -88,7 +88,6 @@ $wgHooks['RenameUserPreRename'][] = 'MassMessageHooks::onRenameUserPreRename'; $wgHooks['UserGetReservedNames'][] = 'MassMessageHooks::onUserGetReservedNames'; $wgHooks['UnitTestsList'][] = 'MassMessageHooks::onUnitTestsList'; -$wgHooks['UserGetRights'][] = 'MassMessageHooks::onUserGetRights'; $wgHooks['BeforeEchoEventInsert'][] = 'MassMessageHooks::onBeforeEchoEventInsert'; $wgResourceModules['ext.MassMessage.special.js'] = array( diff --git a/includes/job/MassMessageJob.php b/includes/job/MassMessageJob.php index 68841c5..b57db78 100644 --- a/includes/job/MassMessageJob.php +++ b/includes/job/MassMessageJob.php @@ -202,6 +202,10 @@ function makeAPIRequest( array $params ) { global $wgUser, $wgRequest; + // Add our hook function to make the MassMessage user IP block-exempt + // Done here so that it's not unnecessarily called on every page load + $wgHooks['UserGetRights'][] = 'MassMessageHooks::onUserGetRights'; + $oldRequest = $wgRequest; $oldUser = $wgUser; @@ -213,6 +217,7 @@ // New user objects will use $wgRequest, so we set that // to our DerivativeRequest, so we don't run into any issues $wgUser = MassMessage::getMessengerUser(); + $wgUser-clearInstanceCache(); // Force rights reload (for IP block exemption) $context = RequestContext::getMain(); // All further internal API requests will use the main -- To view, visit https://gerrit.wikimedia.org/r/156307 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3a955526f1bc613d4eb79c5003012eda0a221fa1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add tests to Database group - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/156498 Change subject: Add tests to Database group .. Add tests to Database group Change-Id: I2f03d5c1a842d5faf2013ab50c0626c5ad8f34fc --- M tests/ApiEditMassMessageListTest.php M tests/ApiMassMessageTest.php M tests/MassMessageContentHandlerTest.php 3 files changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/98/156498/1 diff --git a/tests/ApiEditMassMessageListTest.php b/tests/ApiEditMassMessageListTest.php index e67e84d..1743d2d 100644 --- a/tests/ApiEditMassMessageListTest.php +++ b/tests/ApiEditMassMessageListTest.php @@ -3,6 +3,7 @@ /** * Tests for the API module to edit a MassMessage delivery list * @group API + * @group Database * @group medium */ class ApiEditMassMessageListTest extends MassMessageApiTestCase { diff --git a/tests/ApiMassMessageTest.php b/tests/ApiMassMessageTest.php index 14b3e3c..9998883 100644 --- a/tests/ApiMassMessageTest.php +++ b/tests/ApiMassMessageTest.php @@ -3,6 +3,7 @@ /** * Tests for the API module to send messages * @group API + * @group Database * @group medium */ class ApiMassMessageTest extends MassMessageApiTestCase { diff --git a/tests/MassMessageContentHandlerTest.php b/tests/MassMessageContentHandlerTest.php index 25b6c01..fca688a 100644 --- a/tests/MassMessageContentHandlerTest.php +++ b/tests/MassMessageContentHandlerTest.php @@ -3,6 +3,8 @@ /** * This inherits ApiTestCase because MassMessageListContentHandler::edit goes through * the Edit API. + * @group API + * @group Database * @group medium */ class MassMessageListContentHandlerTest extends MassMessageApiTestCase { -- To view, visit https://gerrit.wikimedia.org/r/156498 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2f03d5c1a842d5faf2013ab50c0626c5ad8f34fc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Remove manual resets of mContentModel - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/155695 Change subject: Remove manual resets of mContentModel .. Remove manual resets of mContentModel Made unnecessary with I94f06baf406afa538cd2b10139598442f9fc6759 Change-Id: If3798c484fb0e908de8106a50a9606943e1ab547 --- M tests/ApiEditMassMessageListTest.php M tests/MassMessageTargetsTest.php 2 files changed, 0 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/95/155695/1 diff --git a/tests/ApiEditMassMessageListTest.php b/tests/ApiEditMassMessageListTest.php index 104f51e..e67e84d 100644 --- a/tests/ApiEditMassMessageListTest.php +++ b/tests/ApiEditMassMessageListTest.php @@ -15,11 +15,6 @@ $page = WikiPage::factory( $title ); $content = ContentHandler::getForModelID( 'MassMessageListContent' )-makeEmptyContent(); $page-doEditContent( $content, 'summary' ); - - // The title object may be cached; force a LinkCache lookup for the updated - // content model the next time it is checked. - $title-mContentModel = false; - $this-doLogin(); } diff --git a/tests/MassMessageTargetsTest.php b/tests/MassMessageTargetsTest.php index 604ceea..0dbe7e7 100644 --- a/tests/MassMessageTargetsTest.php +++ b/tests/MassMessageTargetsTest.php @@ -96,7 +96,6 @@ $title = Title::newFromText( 'MassMessageListContent_spamlist' ); $page = WikiPage::factory( $title ); $page-doEditContent( $content, 'summary' ); - $title-mContentModel = false; // Force the updated model to be read from LinkCache $targets = MassMessageTargets::getTargets( $title, RequestContext::getMain() ); $this-assertEquals( 2, count( $targets ) ); $this-assertEquals( 'A', $targets[0]['title'] ); -- To view, visit https://gerrit.wikimedia.org/r/155695 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If3798c484fb0e908de8106a50a9606943e1ab547 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Set and get object copies in MapCacheLRU - change (mediawiki/core)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/155292 Change subject: Set and get object copies in MapCacheLRU .. Set and get object copies in MapCacheLRU Instead of object references, which seems to be the current behaviour. As far as I can see, only the Title class uses MapCacheLRU in core; not sure if this would break extensions. Bug: 69788 Bug: 69789 Change-Id: I49ad5b3d46921a576cfb86c3c8bc415297ca996e --- M includes/cache/MapCacheLRU.php 1 file changed, 10 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/92/155292/1 diff --git a/includes/cache/MapCacheLRU.php b/includes/cache/MapCacheLRU.php index a22d802..563b9d1 100644 --- a/includes/cache/MapCacheLRU.php +++ b/includes/cache/MapCacheLRU.php @@ -64,7 +64,11 @@ $evictKey = key( $this-cache ); unset( $this-cache[$evictKey] ); } - $this-cache[$key] = $value; + if ( is_object( $value ) ) { + $this-cache[$key] = clone $value; + } else { + $this-cache[$key] = $value; + } } /** @@ -88,7 +92,11 @@ public function get( $key ) { if ( isset( $this-cache[$key] ) ) { $this-ping( $key ); // push to top - return $this-cache[$key]; + if ( is_object( $this-cache[$key] ) ) { + return clone $this-cache[$key]; + } else { + return $this-cache[$key]; + } } else { return null; } -- To view, visit https://gerrit.wikimedia.org/r/155292 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I49ad5b3d46921a576cfb86c3c8bc415297ca996e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add test cases for extractTarget - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/154988 Change subject: Add test cases for extractTarget .. Add test cases for extractTarget Test situation where the local domain is specified. Change-Id: Ic27c3c8b1bd80b7f60bf90b1f20238420b43dbff --- M tests/MassMessageContentHandlerTest.php 1 file changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/88/154988/1 diff --git a/tests/MassMessageContentHandlerTest.php b/tests/MassMessageContentHandlerTest.php index e174f9a..25b6c01 100644 --- a/tests/MassMessageContentHandlerTest.php +++ b/tests/MassMessageContentHandlerTest.php @@ -126,8 +126,12 @@ public static function provideExtractTarget() { return array( array( 'A', array( 'title' = 'A' ) ), + array( 'a...@test.wikipedia.org', array( 'title' = 'A' ) ), + array( 'a...@domain.org@test.wikipedia.org', array( 'title' = 'a...@domain.org' ) ), array( 'a...@en.wikipedia.org', array( 'title' = 'A', 'site' = 'en.wikipedia.org' ) ), array( 'a...@en.wikipedia.org', array( 'title' = 'A', 'site' = 'en.wikipedia.org' ) ), + array( 'a...@domain.org@en.wikipedia.org', + array( 'title' = 'a...@domain.org', 'site' = 'en.wikipedia.org' ) ), array( '_', array( 'errors' = array('invalidtitle' ) ) ), array( 'a...@invalid.org', array( 'title' = 'A', 'errors' = array( 'invalidsite' ) ) ), array( '_...@invalid.org', array( 'errors' = array( 'invalidtitle', 'invalidsite' ) ) ) @@ -141,6 +145,8 @@ * @param array $expected Parsed target */ public function testExtractTarget( $targetString, $expected ) { + // Temporarily set $wgCanonicalServer for this test so its value is predictable. + $this-setMwGlobals( 'wgCanonicalServer', 'http://test.wikipedia.org' ); $this-assertEquals( $expected, MassMessageListContentHandler::extractTarget( $targetString ) -- To view, visit https://gerrit.wikimedia.org/r/154988 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic27c3c8b1bd80b7f60bf90b1f20238420b43dbff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix MassMessage::getMessengerUser() after Password API changes - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/154449 Change subject: Fix MassMessage::getMessengerUser() after Password API changes .. Fix MassMessage::getMessengerUser() after Password API changes Bug: 68843 Change-Id: I840c98dca02efc047c0657647f434d921ae73e45 --- M includes/MassMessage.php M tests/MassMessageTest.php 2 files changed, 6 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/49/154449/1 diff --git a/includes/MassMessage.php b/includes/MassMessage.php index 59e8afc..926d8f7 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -41,8 +41,10 @@ global $wgMassMessageAccountUsername; // Function kinda copied from the AbuseFilter $user = User::newFromName( $wgMassMessageAccountUsername ); - $user-load(); - if ( $user-getId() $user-mPassword == '' $user-mNewpassword == '' ) { + + if ( $user-getId() $user-getPassword() instanceof InvalidPassword +$user-getTemporaryPassword() instanceof InvalidPassword + ) { // We've already stolen the account return $user; } diff --git a/tests/MassMessageTest.php b/tests/MassMessageTest.php index c70ebfa..3977fc4 100644 --- a/tests/MassMessageTest.php +++ b/tests/MassMessageTest.php @@ -78,14 +78,11 @@ * @param $name */ public function testGetMessengerUser( $name ) { - global $wgMassMessageAccountUsername; - $wgMassMessageAccountUsername = $name; + $this-setMwGlobals( 'wgMassMessageAccountUsername', $name ); $user = MassMessage::getMessengerUser(); $this-assertEquals( $user-getName(), $name ); $this-assertTrue( in_array( 'bot' , $user-getGroups() ) ); - // FIXME: temporarily disabled to not block ongoing - // development, see bug 68843 - //$this-assertEquals( $user-mPassword, '' ); + $this-assertInstanceOf( 'InvalidPassword', $user-getPassword() ); } /** -- To view, visit https://gerrit.wikimedia.org/r/154449 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I840c98dca02efc047c0657647f434d921ae73e45 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com Gerrit-Reviewer: Legoktm legoktm.wikipe...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Update token handling for core API change - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/154450 Change subject: Update token handling for core API change .. Update token handling for core API change Core change I2793a3f2 changes API handling in a way that needs updates to extensions for proper operation: * needsToken() now returns a string * Most custom token types are being replaced with a 'csrf' token (the former 'edit' token); any others need a new hook. * All tokens must use a static salt. Compat with web UI using non-static tokens is supported and also serves to handle the now-deprecated token fetching. * Documentation in getParamDescription() should return a string (not array) for 'token', as the signal to core that it should be replaced with a standardized message. When compatibility with earlier versions of MediaWiki is no longer maintained, the entry for 'token' from getAllowedParams() and getParamDescription() may be removed, as may getTokenSalt(). This patch leaves them in place. Note this is intended to be compatible with earlier versions of MediaWiki, and so should be safe to merge before the core change. Change-Id: I75835b743c047a926c90d021b43441d2627350ec (cherry picked from commit 0e822e6d7d34f671a7e45753c6cdb89a818677b7) --- M includes/ApiMassMessage.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/50/154450/1 diff --git a/includes/ApiMassMessage.php b/includes/ApiMassMessage.php index 8127e0f..bf2c23c 100644 --- a/includes/ApiMassMessage.php +++ b/includes/ApiMassMessage.php @@ -83,7 +83,7 @@ public function needsToken() { - return true; + return 'csrf'; } public function getTokenSalt() { -- To view, visit https://gerrit.wikimedia.org/r/154450 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I75835b743c047a926c90d021b43441d2627350ec Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com Gerrit-Reviewer: Anomie bjor...@wikimedia.org ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Subclass JSONContent - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/154451 Change subject: Subclass JSONContent .. Subclass JSONContent Change-Id: I766e7c3c443c84367d301204deed3fda61d7e73f --- M includes/content/MassMessageListContent.php M includes/content/MassMessageListContentHandler.php 2 files changed, 9 insertions(+), 32 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/51/154451/1 diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index 15f9630..c207ac3 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -1,6 +1,6 @@ ?php -class MassMessageListContent extends TextContent { +class MassMessageListContent extends JSONContent { /** * Description wikitext @@ -69,20 +69,6 @@ } /** -* Returns a list content object with pre-save transformations applied. -* The implementation normalizes the JSON data. -* @param Title $title -* @param User $user -* @param ParserOptions $popts -* @return MassMessageListContent -*/ - public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) { - $text = $this-getNativeData(); - $pst = FormatJson::encode( FormatJson::decode( $text ) ); - return ( $text === $pst ) ? $this : new static( $pst ); - } - - /** * @return string|null */ public function getDescription() { @@ -147,7 +133,7 @@ if ( $this-decoded ) { return; } - $data = FormatJson::decode( $this-getNativeData(), true ); + $data = $this-getJsonData(); if ( is_array( $data ) ) { $this-description = array_key_exists( 'description', $data ) ? $data['description'] : null; diff --git a/includes/content/MassMessageListContentHandler.php b/includes/content/MassMessageListContentHandler.php index 4ecdda1..02ff1a8 100644 --- a/includes/content/MassMessageListContentHandler.php +++ b/includes/content/MassMessageListContentHandler.php @@ -1,26 +1,17 @@ ?php -class MassMessageListContentHandler extends TextContentHandler { +class MassMessageListContentHandler extends JSONContentHandler { + + /** +* @var string +*/ + protected $contentClass = 'MassMessageListContent'; /** * @param string $modelId */ public function __construct( $modelId = 'MassMessageListContent' ) { - parent::__construct( $modelId, array( CONTENT_FORMAT_JSON ) ); - } - - /** -* @param string $text -* @param string $format -* @return MassMessageListContent -*/ - public function unserializeContent( $text, $format = null ) { - $this-checkFormat( $format ); - $content = new MassMessageListContent( $text ); - if ( !$content-isValid() ) { - throw new MWContentSerializationException( 'The delivery list content is invalid.' ); - } - return $content; + parent::__construct( $modelId ); } /** -- To view, visit https://gerrit.wikimedia.org/r/154451 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I766e7c3c443c84367d301204deed3fda61d7e73f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix whitespace - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/154717 Change subject: Fix whitespace .. Fix whitespace Followup to I75f132f4ea6c411cacd0e1813311d75655ceb7ae Change-Id: I5f6ea97fe2cce4d5d4eab7d41f4da1eddd64a35a --- M tests/ApiEditMassMessageListTest.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/17/154717/1 diff --git a/tests/ApiEditMassMessageListTest.php b/tests/ApiEditMassMessageListTest.php index 0e40cf5..104f51e 100644 --- a/tests/ApiEditMassMessageListTest.php +++ b/tests/ApiEditMassMessageListTest.php @@ -41,7 +41,7 @@ array( '*' = '_...@invalid.org', 'invalidtitle' = '', 'invalidsite' = '' ) ) ) ); - $this-assertEquals( $expected, $result[0] ); + $this-assertEquals( $expected, $result[0] ); } public function testRemove() { -- To view, visit https://gerrit.wikimedia.org/r/154717 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5f6ea97fe2cce4d5d4eab7d41f4da1eddd64a35a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] [WIP] Unit tests - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/154009 Change subject: [WIP] Unit tests .. [WIP] Unit tests Also fix bugs found while writing tests. Change-Id: I75f132f4ea6c411cacd0e1813311d75655ceb7ae --- M includes/ApiEditMassMessageList.php A tests/ApiEditMassMessageListTest.php M tests/ApiMassMessageTest.php A tests/ApiQueryMMSitesTest.php A tests/MassMessageContentHandlerTest.php A tests/MassMessageContentTest.php 6 files changed, 120 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/09/154009/1 diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php index 2ab243f..8d57973 100644 --- a/includes/ApiEditMassMessageList.php +++ b/includes/ApiEditMassMessageList.php @@ -70,11 +70,15 @@ if ( isset( $data['add'] ) ) { $added = array_values( array_udiff( $newTargets, $targets, 'MassMessageListContentHandler::compareTargets' ) ); + } else { + $added = array(); } if ( isset( $data['remove'] ) ) { $removed = array_values( array_udiff( $targets, $newTargets, 'MassMessageListContentHandler::compareTargets' ) ); + } else { + $removed = array(); } // Make an edit only if there are added or removed pages @@ -88,7 +92,7 @@ $this // APIs implement IContextSource ); if ( !$editResult-isGood() ) { - $this-dieStatus( $result ); + $this-dieStatus( $editResult ); } } diff --git a/tests/ApiEditMassMessageListTest.php b/tests/ApiEditMassMessageListTest.php new file mode 100644 index 000..61cd42c --- /dev/null +++ b/tests/ApiEditMassMessageListTest.php @@ -0,0 +1,43 @@ +?php + +/** + * Tests for the API module to edit a MassMessage delivery list + * @group API + * @group medium + */ +class ApiEditMassMessageListTest extends ApiTestCase { + + protected static $spamlist = 'TestMMSpamlist'; + + protected function setUp() { + parent::setUp(); + $this-doLogin(); + $page = WikiPage::factory( Title::newFromText( self::$spamlist ) ); + $content = ContentHandler::getForModelID( 'MassMessageListContent' )-makeEmptyContent(); + $page-doEditContent( $content, 'summary' ); + } + + public function testAdd() { + $result = $this-doApiRequestWithToken( array( + 'action' = 'editmassmessagelist', + 'spamlist' = self::$spamlist, + 'add' = 'A' + ) ); + $this-assertEquals( + $result[0], + array( 'editmassmessagelist' = array( 'added' = array( 'title' = 'A' ) ) ) + ); + } + + public function testRemove() { + } + + public function testInvalidAdd() { + } + + public function testInvalidRemove() { + } + + public function testMixed() { + } +} diff --git a/tests/ApiMassMessageTest.php b/tests/ApiMassMessageTest.php index cff677c..8f5e0af 100644 --- a/tests/ApiMassMessageTest.php +++ b/tests/ApiMassMessageTest.php @@ -1,7 +1,7 @@ ?php /** - * Tests for API module + * Tests for the API module to send messages * @group API * @group medium */ diff --git a/tests/ApiQueryMMSitesTest.php b/tests/ApiQueryMMSitesTest.php new file mode 100644 index 000..54120b4 --- /dev/null +++ b/tests/ApiQueryMMSitesTest.php @@ -0,0 +1,38 @@ +?php + +/** + * Tests for the API module to serve autocomplete requests for the site field + * @group API + * @group medium + */ +class ApiQueryMMSitesTest extends ApiTestCase { + + protected function setUp() { + // Taken from MassMessageTestCase::setUp() + global $wgConf, $wgLocalDatabases; + $wgConf = new SiteConfiguration; + $wgConf-wikis = array( 'enwiki', 'dewiki', 'frwiki', 'wiki' ); + $wgConf-suffixes = array( 'wiki' ); + $wgConf-settings = array( + 'wgServer' = array( + 'enwiki' = '//en.wikipedia.org', + 'dewiki' = '//de.wikipedia.org', + 'frwiki' = '//fr.wikipedia.org', + ), + ); + $wgLocalDatabases = $wgConf-getLocalDatabases(); + parent::setUp(); + } + + public function testQuery() { + $result = $this-doApiRequest( array( + 'action' =
[MediaWiki-commits] [Gerrit] Use addBacklinkSubtitle - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/153068 Change subject: Use addBacklinkSubtitle .. Use addBacklinkSubtitle Made possible in If6145b5512657bbd9e165b0c614e5061615c294d Change-Id: I0c1ac28ebb9cc88cc19a24590a1e249496e8d144 --- M includes/SpecialEditMassMessageList.php 1 file changed, 3 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/68/153068/1 diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 98c8e1a..986189b 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -95,10 +95,7 @@ } else { $query = array(); } - // Modified from OutputPage::addBacklinkSubtitle() - $out-addSubtitle( $this-msg( 'backlinksubtitle' )-rawParams( - Linker::link( $this-title, null, array(), $query ) - ) ); + $out-addBacklinkSubtitle( $this-title, $query ); // Edit notices; modified from EditPage::showHeader() if ( $this-rev ) { @@ -224,6 +221,7 @@ return Status::newFatal( 'massmessage-edit-invalidtitle' ); } + // Parse input into target array. $parseResult = self::parseInput( $data['content'] ); if ( !$parseResult-isGood() ) { // Wikitext list of escaped invalid target strings @@ -233,6 +231,7 @@ count( $parseResult-value ), $invalidList ) ); } + // Blank edit summary warning if ( $data['summary'] === '' $this-getUser()-getOption( 'forceeditsummary' ) $this-getRequest()-getVal( 'summarywarned' ) === null -- To view, visit https://gerrit.wikimedia.org/r/153068 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0c1ac28ebb9cc88cc19a24590a1e249496e8d144 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Implement warning for blank edit summaries - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/152861 Change subject: Implement warning for blank edit summaries .. Implement warning for blank edit summaries Change-Id: Id4983749e49a8d4f09df73d8c858cccab449368b --- M i18n/en.json M i18n/qqq.json M includes/SpecialEditMassMessageList.php 3 files changed, 12 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/61/152861/1 diff --git a/i18n/en.json b/i18n/en.json index b23d16c..2677921 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -92,6 +92,7 @@ massmessage-edit-headermulti: Use the form below to modify the list description or edit the list of target pages. For target pages, list one title per line and use title@domain (e.g. User_talk:exam...@en.wikipedia.org) to specify a page on a different wiki., massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., massmessage-edit-invalidtargets: The following {{PLURAL:$1|page is|pages are}} invalid:\n$2, + massmessage-edit-missingsummary: You have not provided an edit summary. If you click \{{int:htmlform-submit}}\ again, your edit will be saved without one., massmessage-edit-nopermission: You do not have permission to edit the list., massmessage-summary-addremove: Added $1 {{PLURAL:$1|page|pages}} and removed $2 {{PLURAL:$2|page|pages}}, massmessage-summary-add: Added [[:$1]], diff --git a/i18n/qqq.json b/i18n/qqq.json index e2d31af..1e02b27 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -93,6 +93,7 @@ massmessage-edit-headermulti: Instructions for [[Special:EditMassMessageList]] if cross-wiki delivery is enabled, massmessage-edit-invalidtitle: Error message shown on [[Special:EditMassMessageList]] when the title is invalid, massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid\n* $1 is the number of invalid targets\n* $2 is a formatted list of invalid target strings., + massmessage-edit-missingsummary: Warning shown on [[Special:EditMassMessageList]] to users who have chosen to be prompted about blank edit summaries, massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list, massmessage-summary-addremove: Edit summary when an API request both adds and removes target pages\n* $1 is the number of pages added\n* $2 is the number of pages removed, massmessage-summary-add: Edit summary for adding a target page\n* $1 is the title of the page, diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index fc3ac47..98c8e1a 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -216,9 +216,10 @@ /** * @param array $data +* @param HTMLForm $form * @return Status */ - public function onSubmit( array $data ) { + public function onSubmit( array $data, HTMLForm $form = null ) { if ( !$this-title ) { return Status::newFatal( 'massmessage-edit-invalidtitle' ); } @@ -232,6 +233,14 @@ count( $parseResult-value ), $invalidList ) ); } + if ( $data['summary'] === '' +$this-getUser()-getOption( 'forceeditsummary' ) +$this-getRequest()-getVal( 'summarywarned' ) === null + ) { + $form-addHiddenField( 'summarywarned', 'true' ); + return Status::newFatal( $this-msg( 'massmessage-edit-missingsummary' ) ); + } + $editResult = MassMessageListContentHandler::edit( $this-title, $data['description'], -- To view, visit https://gerrit.wikimedia.org/r/152861 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id4983749e49a8d4f09df73d8c858cccab449368b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Improve tracking category description - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/152245 Change subject: Improve tracking category description .. Improve tracking category description Followup to I5fd351b6074c1c0036738d34b586088a6d8cb9d3 Change-Id: I8956d4779299747f47479b409b30850e81374be5 --- M i18n/en.json 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/45/152245/1 diff --git a/i18n/en.json b/i18n/en.json index 9b1f2ab..97b737c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -98,5 +98,5 @@ massmessage-summary-removeonsite: Removed $1 on $2, massmessage-summary-removemulti: Removed $1 {{PLURAL:$1|pages}}, massmessage-list-category: MassMessage delivery lists, - massmessage-list-category-desc: The page is a delivery list for [[Special:MassMessage]]. + massmessage-list-category-desc: The page is a delivery list for the [[Special:MassMessage|MassMessage]] extension. } -- To view, visit https://gerrit.wikimedia.org/r/152245 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8956d4779299747f47479b409b30850e81374be5 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use jquery.confirmable for remove links - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/152268 Change subject: Use jquery.confirmable for remove links .. Use jquery.confirmable for remove links :D Change-Id: I298cefd7e9a0cbc622fd00ee869705a85e20355f --- M MassMessage.php M i18n/en.json M i18n/qqq.json M modules/ext.MassMessage.content.js 4 files changed, 29 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/68/152268/1 diff --git a/MassMessage.php b/MassMessage.php index 2e8ec91..3b8c6ec 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -154,6 +154,9 @@ 'massmessage-content-emptylist', 'massmessage-content-addeditem', 'massmessage-content-removeerror', + 'massmessage-content-removeconf', + 'massmessage-content-removeyes', + 'massmessage-content-removeno', 'massmessage-content-alreadyinlist', 'massmessage-content-invalidtitlesite', 'massmessage-content-invalidtitle', @@ -162,6 +165,7 @@ ), 'dependencies' = array( 'ext.MassMessage.autocomplete', + 'jquery.confirmable', 'mediawiki.api', 'mediawiki.util', 'mediawiki.jqueryMsg', diff --git a/i18n/en.json b/i18n/en.json index 97b737c..b23d16c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -49,6 +49,9 @@ massmessage-content-localpages: Pages on this wiki:, massmessage-content-remove: remove, massmessage-content-removeerror: Removing the page failed with error code $1., + massmessage-content-removeconf: Remove this page from the list?, + massmessage-content-removeyes: Remove, + massmessage-content-removeno: Cancel, massmessage-content-empty: There are no pages in this list., massmessage-content-invalidtargets: This list contains invalid targets., massmessage-content-emptylist: (none), diff --git a/i18n/qqq.json b/i18n/qqq.json index 432227f..e2d31af 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -50,6 +50,9 @@ massmessage-content-localpages: Subheading for the list of pages on the local wiki, massmessage-content-remove: Label for the link to remove a page from a delivery list, massmessage-content-removeerror: Error message shown when removing a page using the link next to each item failed, + massmessage-content-removeconf: Confirmation message for removing a page from a delivery list, + massmessage-content-removeyes: Label for button to confirm removal, + massmessage-content-removeno: Label for button to cancel removal, massmessage-content-empty: Message shown when viewing a delivery list if it is completely empty, massmessage-content-invalidtargets: Warning shown when viewing a delivery list that contains invalid targets, massmessage-content-emptylist: Message that replaces a section of a delivery list (e.g. pages on a particular wiki) when all pages in the section are removed, diff --git a/modules/ext.MassMessage.content.js b/modules/ext.MassMessage.content.js index 1b556da..612008f 100644 --- a/modules/ext.MassMessage.content.js +++ b/modules/ext.MassMessage.content.js @@ -55,6 +55,9 @@ .html( '(' + removeLink + ')' ) ).hide().fadeIn() ); + + // Register the remove link handler again so it works on the new item. + $list.find( '.mw-massmessage-removelink a' ).confirmable( confirmableParams ); }; // Return a target page in title or title@site (if site is not empty) form. @@ -74,12 +77,10 @@ }; // Handle remove links next to targets. - $( '#mw-content-text' ).on( 'click', '.mw-massmessage-removelink a', function ( e ) { + var removeHandler = function ( e ) { var param, $link = $( this ); e.preventDefault(); - - // TODO: Use jquery.confirmable once it's available. param = getApiParam( $link.attr( 'data-title' ), @@ -108,7 +109,17 @@ .fail( function ( errorCode ) { alert( mw.message( 'massmessage-content-removeerror', errorCode ).text() ); } ); - } ); + }; + + // Parameters for jquery.confirmable (remove links) + var confirmableParams = { + handler: removeHandler, + i18n: { + confirm: mw.message( 'massmessage-content-removeconf' ).escaped(), +
[MediaWiki-commits] [Gerrit] Add edit notices and protection warnings - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/152840 Change subject: Add edit notices and protection warnings .. Add edit notices and protection warnings Change how page state is determined to support this: If $this-title is set, the title is a valid delivery list; if $this-rev is set, the user can edit the delivery list. Change-Id: I3a9b89b778c4d3db7cb29c65e83a362220e22c5b --- M includes/SpecialEditMassMessageList.php 1 file changed, 47 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/40/152840/1 diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index a32be96..81453cc 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -45,25 +45,27 @@ || !$title-hasContentModel( 'MassMessageListContent' ) ) { $this-errorMsgKey = 'massmessage-edit-invalidtitle'; - } else if ( !$title-userCan( 'edit' ) ) { - $this-errorMsgKey = 'massmessage-edit-nopermission'; } else { $this-title = $title; - $revId = $this-getRequest()-getInt( 'oldid' ); - if ( $revId 0 ) { - $rev = Revision::newFromId( $revId ); - if ( $rev -$rev-getTitle()-equals( $title ) -$rev-getContentModel() === 'MassMessageListContent' -$rev-userCan( Revision::DELETED_TEXT, $this-getUser() ) - ) { - $this-rev = $rev; - } else { // Use the latest revision for the title if $rev is invalid. + if ( !$title-userCan( 'edit' ) ) { + $this-errorMsgKey = 'massmessage-edit-nopermission'; + } else { + $revId = $this-getRequest()-getInt( 'oldid' ); + if ( $revId 0 ) { + $rev = Revision::newFromId( $revId ); + if ( $rev + $rev-getTitle()-equals( $title ) + $rev-getContentModel() === 'MassMessageListContent' +$rev-userCan( Revision::DELETED_TEXT, $this-getUser() ) + ) { + $this-rev = $rev; + } else { // Use the latest revision for the title if $rev is invalid. + $this-rev = Revision::newFromTitle( $title ); + } + } else { $this-rev = Revision::newFromTitle( $title ); } - } else { - $this-rev = Revision::newFromTitle( $title ); } } } @@ -83,13 +85,35 @@ ); // Backlink - $revId = $this-rev-getId(); - $query = ( $revId !== $this-title-getLatestRevId() ) ? - array( 'oldid' = $revId ) : array(); + if ( $this-rev ) { + $revId = $this-rev-getId(); + $query = ( $revId !== $this-title-getLatestRevId() ) ? + array( 'oldid' = $revId ) : array(); + } else { + $query = array(); + } // Modified from OutputPage::addBacklinkSubtitle() $out-addSubtitle( $this-msg( 'backlinksubtitle' )-rawParams( Linker::link( $this-title, null, array(), $query ) ) ); + + // Edit notices and protection warnings; modified from EditPage::showHeader() + if ( $this-rev ) { + $out-addHTML( + implode( \n, $this-title-getEditNotices( $this-rev-getId() ) ) +
[MediaWiki-commits] [Gerrit] Improve Special:EditMassMessageList - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/152000 Change subject: Improve Special:EditMassMessageList .. Improve Special:EditMassMessageList * Rewrite instructions and use separate message for when cross-wiki delivery is enabled * Add copyright disclaimer * Add link back to list view * Add some comments to the code Change-Id: I9817ba85b0250e44c0c3b30d0552d1c7770ec5d5 --- M i18n/en.json M i18n/qqq.json M includes/SpecialEditMassMessageList.php 3 files changed, 58 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/00/152000/1 diff --git a/i18n/en.json b/i18n/en.json index a3f80f0..d2fee3c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -80,11 +80,13 @@ massmessage-create-nopermission: You do not have permission to create a list at this title., massmessage-create-invalidsource: The specified source is not a valid delivery list or category., editmassmessagelist-legend: Edit mass message delivery list, + massmessage-edit-pagetitle: Editing $1, massmessage-edit-title: Title:, massmessage-edit-description: Description:, - massmessage-edit-content: Content:, + massmessage-edit-content: Target pages:, massmessage-edit-summary: Edit summary:, - massmessage-edit-header: List one title per line, and use title@domain (e.g. User talk:exam...@en.wikipedia.org) to specify a page on a different wiki, if cross-wiki delivery is enabled., + massmessage-edit-header: Use the form below to modify the list description or edit the list of target pages. For target pages, list one title per line., + massmessage-edit-headermulti: Use the form below to modify the list description or edit the list of target pages. For target pages, list one title per line and use title@domain (e.g. User talk:exam...@en.wikipedia.org) to specify a page on a different wiki., massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., massmessage-edit-invalidtargets: The following {{PLURAL:$1|page is|pages are}} invalid:\n$2, massmessage-edit-nopermission: You do not have permission to edit the list., diff --git a/i18n/qqq.json b/i18n/qqq.json index abcd896..a891e35 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -81,11 +81,13 @@ massmessage-create-nopermission: Error message shown on [[Special:CreateMassMessageList]] when the user cannot create a page with the title, massmessage-create-invalidsource: Error message shown on [[Special:CreateMassMessageList]] when the source from which to import targets is invalid, editmassmessagelist-legend: Form legend for [[Special:EditMassMessageList]], + massmessage-edit-pagetitle: Page title for [[Special:EditMassMessageList]]\n* $1 is the title of the delivery list being edited, massmessage-edit-title: Label for an inputbox on [[Special:EditMassMessageList]], massmessage-edit-description: Label for a textarea on [[Special:EditMassMessageList]], massmessage-edit-content: Label for a textarea on [[Special:EditMassMessageList]], massmessage-edit-summary: Label for an inputbox on [[Special:EditMassMessageList]], massmessage-edit-header: Instructions for [[Special:EditMassMessageList]], + massmessage-edit-headermulti: Instructions for [[Special:EditMassMessageList]] if cross-wiki delivery is enabled, massmessage-edit-invalidtitle: Error message shown on [[Special:EditMassMessageList]] when the title is invalid, massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid\n* $1 is the number of invalid targets\n* $2 is a formatted list of invalid target strings., massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list, diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 09f9a22..a32be96 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -70,6 +70,30 @@ } /** +* Override the parent implementation to modify the page title and add a backlink. +*/ + public function setHeaders() { + parent::setHeaders(); + if ( $this-title ) { + $out = $this-getOutput(); + + // Page title + $out-setPageTitle( + $this-msg( 'massmessage-edit-pagetitle', $this-title-getPrefixedText() ) + ); + + // Backlink + $revId = $this-rev-getId(); + $query = ( $revId !== $this-title-getLatestRevId() ) ? +
[MediaWiki-commits] [Gerrit] Implement basic support for transclusion. - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/152014 Change subject: Implement basic support for transclusion. .. Implement basic support for transclusion. Implement getWikitextForTransclusion so that transclusions don't show up as raw JSON. Because there is no way to customise transclusion, only the target list is returned (with no h2), as it's possible that one would want to transclude the target list without the description, and including the latter by default would make it impossible. Change-Id: Ie87bb96becdf12f06536911f94330a399c28c42e --- M includes/content/MassMessageListContent.php 1 file changed, 44 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/14/152014/1 diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index 9da0b71..12293d8 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -199,6 +199,49 @@ } /** +* Return the list of targets (with no heading) in wikitext format. +* Modified from getTargetsHtml(). +* @return string +*/ + public function getWikitextForTransclusion() { + global $wgScript; + + $sites = $this-getTargetsBySite(); + + // If the list is empty + if ( count( $sites ) === 0 ) { + return wfMessage( 'massmessage-content-empty' )-text(); + } + + // Determine whether there are targets on external wikis. + $printSites = ( count( $sites ) === 1 array_key_exists( 'local', $sites ) ) ? + false : true; + + $wikitext = ''; + foreach ( $sites as $site = $targets ) { + if ( $printSites ) { + if ( $site === 'local' ) { + $wikitext .= wfMessage( 'massmessage-content-localpages' )-text() . \n; + } else { + $wikitext .= wfMessage( 'massmessage-content-pagesonsite', $site )-text() + . \n; + } + } + + foreach ( $targets as $target ) { + $title = Title::newFromText( $target ); + if ( $site === 'local' ) { + $wikitext .= '* [[' . $title-getPrefixedText() . ]]\n; + } else { + $wikitext .= * [//$site$wgScript?title= . $title-getPrefixedURL() + . ' ' . $title-getPrefixedText() . ]\n; + } + } + } + return $wikitext; + } + + /** * Helper function for fillParserOutput; return HTML for displaying the list of pages. * Note that the function assumes that the contents are valid. * @return string @@ -279,8 +322,7 @@ } /** -* Helper function for getTargetsHtml; return the array of targets sorted by site. -* Note that the function assumes that the contents are valid. +* Return the array of targets sorted by site. * @return array */ protected function getTargetsBySite() { -- To view, visit https://gerrit.wikimedia.org/r/152014 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie87bb96becdf12f06536911f94330a399c28c42e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move Add pages and add tracking category - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/152067 Change subject: Move Add pages and add tracking category .. Move Add pages and add tracking category Move Add pages form to the top so that scrolling isn't needed to reach it in long lists; add tracking category for delivery lists. Change-Id: I5fd351b6074c1c0036738d34b586088a6d8cb9d3 --- M MassMessage.php M i18n/en.json M i18n/qqq.json M includes/content/MassMessageListContent.php 4 files changed, 12 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/67/152067/1 diff --git a/MassMessage.php b/MassMessage.php index 32f9543..2e8ec91 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -204,3 +204,6 @@ // User rights $wgAvailableRights[] = 'massmessage'; // Local messaging $wgGroupPermissions['sysop']['massmessage'] = true; + +// Tracking category for spamlists +$wgTrackingCategories[] = 'massmessage-list-category'; diff --git a/i18n/en.json b/i18n/en.json index 788f7f2..9b1f2ab 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -96,5 +96,7 @@ massmessage-summary-addmulti: Added $1 {{PLURAL:$1|pages}}, massmessage-summary-remove: Removed [[:$1]], massmessage-summary-removeonsite: Removed $1 on $2, - massmessage-summary-removemulti: Removed $1 {{PLURAL:$1|pages}} + massmessage-summary-removemulti: Removed $1 {{PLURAL:$1|pages}}, + massmessage-list-category: MassMessage delivery lists, + massmessage-list-category-desc: The page is a delivery list for [[Special:MassMessage]]. } diff --git a/i18n/qqq.json b/i18n/qqq.json index a891e35..432227f 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -97,5 +97,7 @@ massmessage-summary-addmulti: Edit summary for adding multiple target pages\n* $1 is the number of pages added, massmessage-summary-remove: Edit summary for removing a target page\n* $1 is the title of the page, massmessage-summary-removeonsite: Edit summary for removing a target page on another wiki\n* $1 is the title of the page\n* $2 is the domain of the wiki, - massmessage-summary-removemulti: Edit summary for removing multiple target pages\n* $1 is the number of pages removed + massmessage-summary-removemulti: Edit summary for removing multiple target pages\n* $1 is the number of pages removed, + massmessage-list-category: Name for the tracking category containing all MassMessage delivery lists, + massmessage-list-category-desc: Description for the tracking category containing delivery lists } diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index 12293d8..56a8ddf 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -171,6 +171,7 @@ // Parse the description text. $output = $wgParser-parse( $this-getDescription(), $title, $options, true, true, $revId ); + $wgParser-addTrackingCategory( 'massmessage-list-category' ); // Generate output HTML, if needed. if ( $generateHtml ) { @@ -180,8 +181,8 @@ } else { $warning = ''; } - $output-setText( $warning . $output-getText() . $this-getTargetsHtml() - . self::getAddForm() ); + $output-setText( $warning . $output-getText() . self::getAddForm() + . $this-getTargetsHtml() ); } else { $output-setText( '' ); } -- To view, visit https://gerrit.wikimedia.org/r/152067 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5fd351b6074c1c0036738d34b586088a6d8cb9d3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix creation edit summary - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/151595 Change subject: Fix creation edit summary .. Fix creation edit summary Also add a colon to wikilinks in summaries to make it clear they would not lead to transclusions. Followup to I33ab09d783b2607b466d77fb027179ec845eb08a Change-Id: I1194b9b327f7c1080a6e3e9e54eb46c9f4b5de54 --- M i18n/en.json M includes/SpecialCreateMassMessageList.php 2 files changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/95/151595/1 diff --git a/i18n/en.json b/i18n/en.json index e619451..480e01d 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -89,10 +89,10 @@ massmessage-edit-invalidtargets: The following pages are invalid:\n$1, massmessage-edit-nopermission: You do not have permission to edit the list., massmessage-summary-addremove: Added $1 {{PLURAL:$1|page|pages}} and removed $2 {{PLURAL:$2|page|pages}}, - massmessage-summary-add: Added [[$1]], + massmessage-summary-add: Added [[:$1]], massmessage-summary-addonsite: Added $1 on $2, massmessage-summary-addmulti: Added $1 {{PLURAL:$1|pages}}, - massmessage-summary-remove: Removed [[$1]], + massmessage-summary-remove: Removed [[:$1]], massmessage-summary-removeonsite: Removed $1 on $2, massmessage-summary-removemulti: Removed $1 {{PLURAL:$1|pages}} } diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index 18688af..ca85072 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -74,7 +74,7 @@ $title, $data['description'], $targets, - 'massmessage-create-editsummary', + $this-msg( 'massmessage-create-editsummary' )-inContentLanguage()-plain(), $this-getContext() ); -- To view, visit https://gerrit.wikimedia.org/r/151595 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1194b9b327f7c1080a6e3e9e54eb46c9f4b5de54 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Escape invalid target strings in message - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/151665 Change subject: Escape invalid target strings in message .. Escape invalid target strings in message Prevent wikitext in invalid target strings from being parsed in the special page error message. Also add plural handling. Change-Id: I3a59686092b247aeddc7ee21eee4d5558911827a --- M i18n/en.json M i18n/qqq.json M includes/SpecialEditMassMessageList.php 3 files changed, 6 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/65/151665/1 diff --git a/i18n/en.json b/i18n/en.json index 480e01d..a3f80f0 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -86,7 +86,7 @@ massmessage-edit-summary: Edit summary:, massmessage-edit-header: List one title per line, and use title@domain (e.g. User talk:exam...@en.wikipedia.org) to specify a page on a different wiki, if cross-wiki delivery is enabled., massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., - massmessage-edit-invalidtargets: The following pages are invalid:\n$1, + massmessage-edit-invalidtargets: The following {{PLURAL:$1|page is|pages are}} invalid:\n$2, massmessage-edit-nopermission: You do not have permission to edit the list., massmessage-summary-addremove: Added $1 {{PLURAL:$1|page|pages}} and removed $2 {{PLURAL:$2|page|pages}}, massmessage-summary-add: Added [[:$1]], diff --git a/i18n/qqq.json b/i18n/qqq.json index 4d4218b..abcd896 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -87,7 +87,7 @@ massmessage-edit-summary: Label for an inputbox on [[Special:EditMassMessageList]], massmessage-edit-header: Instructions for [[Special:EditMassMessageList]], massmessage-edit-invalidtitle: Error message shown on [[Special:EditMassMessageList]] when the title is invalid, - massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid\n* $1 is a formatted list of invalid target strings., + massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid\n* $1 is the number of invalid targets\n* $2 is a formatted list of invalid target strings., massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list, massmessage-summary-addremove: Edit summary when an API request both adds and removes target pages\n* $1 is the number of pages added\n* $2 is the number of pages removed, massmessage-summary-add: Edit summary for adding a target page\n* $1 is the title of the page, diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 40f8b01..09f9a22 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -153,10 +153,11 @@ $parseResult = self::parseInput( $data['content'] ); if ( !$parseResult-isGood() ) { - // wikitext list of invalid target strings - $invalidList = '* ' . implode( \n* , $parseResult-value ); + // Wikitext list of escaped invalid target strings + $invalidList = '* ' . implode( \n* , array_map( 'wfEscapeWikiText', + $parseResult-value ) ); return Status::newFatal( $this-msg( 'massmessage-edit-invalidtargets', - $invalidList ) ); + count( $parseResult-value ), $invalidList ) ); } $editResult = MassMessageListContentHandler::edit( -- To view, visit https://gerrit.wikimedia.org/r/151665 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3a59686092b247aeddc7ee21eee4d5558911827a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Don't allow interwikis or special pages as targets - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/151666 Change subject: Don't allow interwikis or special pages as targets .. Don't allow interwikis or special pages as targets Change-Id: I8ad8ddf15b07d2998055b42f70032809a713ce94 --- M includes/content/MassMessageListContentHandler.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/66/151666/1 diff --git a/includes/content/MassMessageListContentHandler.php b/includes/content/MassMessageListContentHandler.php index 2e41f55..4ecdda1 100644 --- a/includes/content/MassMessageListContentHandler.php +++ b/includes/content/MassMessageListContentHandler.php @@ -131,7 +131,7 @@ $result = array(); $title = Title::newFromText( $titleText ); - if ( !$title ) { + if ( !$title || $title-isSpecialPage() || $title-isExternal() ) { $result['errors'] = array( 'invalidtitle' ); } else { $result['title'] = $title-getPrefixedText(); // Use the canonical form. -- To view, visit https://gerrit.wikimedia.org/r/151666 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8ad8ddf15b07d2998055b42f70032809a713ce94 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Improve edit summaries - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/151390 Change subject: Improve edit summaries .. Improve edit summaries Allow the user to type their own summary when editing via special page; calculate a descriptive edit summary when editing via API. Change-Id: I33ab09d783b2607b466d77fb027179ec845eb08a --- M i18n/en.json M i18n/qqq.json M includes/ApiEditMassMessageList.php M includes/SpecialEditMassMessageList.php M includes/content/MassMessageListContentHandler.php 5 files changed, 101 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/90/151390/1 diff --git a/i18n/en.json b/i18n/en.json index 2dc3eb9..f9cdb80 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -83,10 +83,16 @@ massmessage-edit-title: Title:, massmessage-edit-description: Description:, massmessage-edit-content: Content:, + massmessage-edit-summary: Edit summary:, massmessage-edit-header: List one title per line, and use title@domain (e.g. User talk:exam...@en.wikipedia.org) to specify a page on a different wiki, if cross-wiki delivery is enabled., - massmessage-edit-editsummary: Update mass message delivery list, massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., massmessage-edit-invalidtargets: The following pages are invalid:\n$1, massmessage-edit-nopermission: You do not have permission to edit the list., - massmessage-api-editsummary: Update mass message delivery list + massmessage-summary-addremove: Added $1 {{PLURAL:$1|page|pages}} and removed $2 {{PLURAL:$2|page|pages}}, + massmessage-summary-add: Add [[$1]], + massmessage-summary-addonsite: Add $1 on $2, + massmessage-summary-addmulti: Add $1 pages, + massmessage-summary-remove: Remove [[$1]], + massmessage-summary-removeonsite: Remove $1 on $2, + massmessage-summary-removemulti: Remove $1 pages } diff --git a/i18n/qqq.json b/i18n/qqq.json index 31821de..405bd26 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -84,10 +84,16 @@ massmessage-edit-title: Label for an inputbox on [[Special:EditMassMessageList]], massmessage-edit-description: Label for a textarea on [[Special:EditMassMessageList]], massmessage-edit-content: Label for a textarea on [[Special:EditMassMessageList]], + massmessage-edit-summary: Label for an inputbox on [[Special:EditMassMessageList]], massmessage-edit-header: Instructions for [[Special:EditMassMessageList]], - massmessage-edit-editsummary: Edit summary for editing a delivery list, massmessage-edit-invalidtitle: Error message shown on [[Special:EditMassMessageList]] when the title is invalid, massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid\n* $1 is a formatted list of invalid target strings., massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list, - massmessage-api-editsummary: Edit summary for editing a delivery list using the API + massmessage-summary-addremove: Edit summary when an API request both adds and removes target pages\n* $1 is the number of pages added\n* $2 is the number of pages removed, + massmessage-summary-add: Edit summary for adding a target page\n* $1 is the title of the page, + massmessage-summary-addonsite: Edit summary for adding a target page on another wiki\n* $1 is the title of the page\n* $2 is the domain of the wiki, + massmessage-summary-addmulti: Edit summary for adding multiple target pages\n* $1 is the number of pages added, + massmessage-summary-remove: Edit summary for removing a target page\n* $1 is the title of the page, + massmessage-summary-removeonsite: Edit summary for removing a target page on another wiki\n* $1 is the title of the page\n* $2 is the domain of the wiki, + massmessage-summary-removemulti: Edit summary for removing multiple target pages\n* $1 is the number of pages removed } diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php index 886caa0..adc7ec0 100644 --- a/includes/ApiEditMassMessageList.php +++ b/includes/ApiEditMassMessageList.php @@ -67,23 +67,36 @@ 'MassMessageListContentHandler::compareTargets' ) ); } - $editResult = MassMessageListContentHandler::edit( - $spamlist, - $description, - $newTargets, - 'massmessage-api-editsummary', - $this // APIs implement IContextSource - ); - if ( !$editResult-isGood() ) { - $this-dieStatus(
[MediaWiki-commits] [Gerrit] Descriptive error on special page - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/151380 Change subject: Descriptive error on special page .. Descriptive error on special page List the invalid target strings in the error message, as opposed to just saying that some strings are invalid. Change-Id: I13469fb41f1e676acbb0a39110b193dc0e33cf5e --- M i18n/en.json M i18n/qqq.json M includes/SpecialEditMassMessageList.php 3 files changed, 25 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/80/151380/1 diff --git a/i18n/en.json b/i18n/en.json index 4d57abe..2dc3eb9 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -86,7 +86,7 @@ massmessage-edit-header: List one title per line, and use title@domain (e.g. User talk:exam...@en.wikipedia.org) to specify a page on a different wiki, if cross-wiki delivery is enabled., massmessage-edit-editsummary: Update mass message delivery list, massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., - massmessage-edit-invalidtargets: One of more of the entries in the list are invalid., + massmessage-edit-invalidtargets: The following pages are invalid:\n$1, massmessage-edit-nopermission: You do not have permission to edit the list., massmessage-api-editsummary: Update mass message delivery list } diff --git a/i18n/qqq.json b/i18n/qqq.json index 04c7f42..31821de 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -87,7 +87,7 @@ massmessage-edit-header: Instructions for [[Special:EditMassMessageList]], massmessage-edit-editsummary: Edit summary for editing a delivery list, massmessage-edit-invalidtitle: Error message shown on [[Special:EditMassMessageList]] when the title is invalid, - massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid, + massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid\n* $1 is a formatted list of invalid target strings., massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list, massmessage-api-editsummary: Edit summary for editing a delivery list using the API } diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index bd3d855..bd27ac9 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -138,21 +138,24 @@ return Status::newFatal( 'massmessage-edit-invalidtitle' ); } - $targets = self::parseInput( $data['content'] ); - if ( $targets === null ) { - return Status::newFatal( 'massmessage-edit-invalidtargets' ); + $parseResult = self::parseInput( $data['content'] ); + if ( !$parseResult-isGood() ) { + // wikitext list of invalid target strings + $invalidList = '* ' . implode( \n* , $parseResult-value ); + return Status::newFatal( $this-msg( 'massmessage-edit-invalidtargets', + $invalidList ) ); } - $result = MassMessageListContentHandler::edit( + $editResult = MassMessageListContentHandler::edit( $this-title, $data['description'], - $targets, + $parseResult-value, 'massmessage-edit-editsummary', $this-getContext() ); - if ( !$result-isGood() ) { - return $result; + if ( !$editResult-isGood() ) { + return $editResult; } $this-getOutput()-redirect( $this-title-getFullUrl() ); } @@ -162,21 +165,30 @@ } /** -* Parse user input into targets array. Returns null if input contains invalid data. +* Parse user input into an array of targets and return it as the value of a Status object. +* If input contains invalid data, the value is the array of invalid target strings. * @param string $input -* @return array|null +* @return Status */ protected static function parseInput( $input ) { $lines = array_filter( explode( \n, $input ), 'trim' ); // Array of non-empty lines $targets = array(); + $invalidTargets = array(); foreach ( $lines as $line ) { $target = MassMessageListContentHandler::extractTarget( $line ); if ( array_key_exists( 'errors', $target ) ) { -
[MediaWiki-commits] [Gerrit] Allow valid lists to contain invalid sites - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/151053 Change subject: Allow valid lists to contain invalid sites .. Allow valid lists to contain invalid sites Change MassMessageTargets::getMassMessageListContentTargets to filter invalid targets and show a warning when viewing lists with invalid targets. This prevents configuration changes from suddenly making pages and revisions inaccessible. Change-Id: If45a0ef56c2f92fd8a7debceea0e39c4dd532ba8 --- M i18n/en.json M i18n/qqq.json M includes/MassMessageTargets.php M includes/content/MassMessageListContent.php M includes/content/MassMessageListContentHandler.php 5 files changed, 50 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/53/151053/1 diff --git a/i18n/en.json b/i18n/en.json index 9e2f0ff..4d57abe 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -50,6 +50,7 @@ massmessage-content-remove: remove, massmessage-content-removeerror: Removing the page failed with error code $1., massmessage-content-empty: There are no pages in this list., + massmessage-content-invalidtargets: This list contains invalid targets., massmessage-content-emptylist: (none), massmessage-content-addheading: Add pages, massmessage-content-addtitle: Title:, diff --git a/i18n/qqq.json b/i18n/qqq.json index aaecf42..7d7a505 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -51,6 +51,7 @@ massmessage-content-remove: Label for the link to remove a page from a delivery list, massmessage-content-removeerror: Error message shown when removing a page using the link next to each item failed, massmessage-content-empty: Message shown when viewing a delivery list if it is completely empty, + massmessage-content-invalidtargets: Message shown when viewing a delivery list that contains invalid targets, massmessage-content-emptylist: Message that replaces a section of a delivery list (e.g. pages on a particular wiki) when all pages in the section are removed, massmessage-content-addheading: Heading for the form for adding pages when viewing delivery lists, massmessage-content-addtitle: Label for the title field in the form for adding pages, diff --git a/includes/MassMessageTargets.php b/includes/MassMessageTargets.php index a6bf3f7..d867e75 100644 --- a/includes/MassMessageTargets.php +++ b/includes/MassMessageTargets.php @@ -92,18 +92,31 @@ * @return array */ public static function getMassMessageListContentTargets ( Title $spamlist ) { - global $wgCanonicalServer; + global $wgAllowGlobalMessaging, $wgCanonicalServer; $targets = Revision::newFromTitle( $spamlist )-getContent()-getTargets(); - foreach ( $targets as $target ) { + $validTargets = array(); + foreach ( $targets as $target ) { if ( array_key_exists( 'site', $target ) ) { - $target['wiki'] = MassMessage::getDBName( $target['site'] ); + if ( $wgAllowGlobalMessaging ) { + $wiki = MassMessage::getDBName( $target['site'] ); + if ( $wiki !== null ) { + $validTargets[] = array( + 'title' = $target['title'], + 'site' = $target['site'], + 'wiki' = $wiki + ); + } + } } else { - $target['wiki'] = wfWikiID(); - $target['site'] = MassMessage::getBaseUrl( $wgCanonicalServer ); + $validTargets[] = array( + 'title' = $target['title'], + 'site' = MassMessage::getBaseUrl( $wgCanonicalServer ), + 'wiki' = wfWikiID() + ); } } - return $targets; + return $validTargets; } /** diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index 1252e93..0af4a4b 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -30,12 +30,9 @@ /** * Decode and validate the contents. -* * @return bool Whether the contents are valid */ public function isValid() { - global
[MediaWiki-commits] [Gerrit] [WIP] More readable diff - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/150809 Change subject: [WIP] More readable diff .. [WIP] More readable diff Subclass DifferenceEngine. Move parsing of target array into target strings from SpecialEditMassMessageList into MassMessageListContent and use target strings for diff. This approach has the advantage of being simple and consistent with wikitext, but maybe we should instead show two lists of wikilinked targets, one for added pages and one for removed pages. TODO: Headings for description diff and target diff in the UI Bug: 68600 Change-Id: Ic74008270e5f0b61c458eaae0b48d3af559baa80 --- M MassMessage.php M includes/SpecialEditMassMessageList.php M includes/content/MassMessageListContent.php M includes/content/MassMessageListContentHandler.php A includes/content/MassMessageListDiffEngine.php 5 files changed, 77 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/09/150809/1 diff --git a/MassMessage.php b/MassMessage.php index 2f074bc..8660fde 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -82,6 +82,7 @@ $wgAutoloadClasses['MassMessageSkipLogFormatter'] = $dir/includes/logging/MassMessageSkipLogFormatter.php; $wgAutoloadClasses['MassMessageListContent'] = $dir/includes/content/MassMessageListContent.php; $wgAutoloadClasses['MassMessageListContentHandler'] = $dir/includes/content/MassMessageListContentHandler.php; +$wgAutoloadClasses['MassMessageListDiffEngine'] = $dir/includes/content/MassMessageListDiffEngine.php; $wgAutoloadClasses['MassMessageTestCase'] = $dir/tests/MassMessageTestCase.php; // ContentHandler diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 87434fe..bd3d855 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -73,7 +73,7 @@ $content = $this-rev-getContent( Revision::FOR_THIS_USER, $this-getUser() ); $description = $content-getDescription(); - $targets = $content-getTargets(); + $targets = $content-getTargetStrings(); return array( 'title' = array( @@ -90,7 +90,7 @@ ), 'content' = array( 'type' = 'textarea', - 'default' = ( $targets !== null ) ? self::parseTargets( $targets ) : '', + 'default' = ( $targets !== null ) ? implode( \n, $targets ) : '', 'label-message' = 'massmessage-edit-content', ), ); @@ -159,28 +159,6 @@ public function onSuccess() { // No-op: We have already redirected. - } - - /** -* Parse array of targets for editing. -* @var array $targets -* @return string -*/ - protected static function parseTargets( $targets ) { - global $wgCanonicalServer; - - $lines = array(); - foreach ( $targets as $target ) { - if ( array_key_exists( 'site', $target ) ) { - $lines[] = $target['title'] . '@' . $target['site']; - } elseif ( strpos( $target['title'], '@' ) !== false ) { - // List the site if it'd otherwise be ambiguous - $lines[] = $target['title'] . '@' . MassMessage::getBaseUrl( $wgCanonicalServer ); - } else { - $lines[] = $target['title']; - } - } - return implode( \n, $lines ); } /** diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index e266557..1252e93 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -90,6 +90,32 @@ } /** +* Return targets as an array of title or title@site strings. +* @return array|null +*/ + public function getTargetStrings() { + global $wgCanonicalServer; + + $targets = $this-getTargets(); + if ( $targets === null ) { + return null; + } + + $targetStrings = array(); + foreach ( $targets as $target ) { + if ( array_key_exists( 'site', $target ) ) { + $targetStrings[] = $target['title'] . '@' . $target['site']; + } elseif ( strpos( $target['title'], '@' ) !== false ) { + // List the site if it'd otherwise be ambiguous + $targetStrings[] = $target['title'] . '@' .
[MediaWiki-commits] [Gerrit] [WIP] Autocomplete - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/150509 Change subject: [WIP] Autocomplete .. [WIP] Autocomplete Split title autocomplete into its own module and add it to list creation and list view. Add autocomplete for site name to list view. TODO: Handle 'localhost' for site autocomplete; evaluate performance. Change-Id: I1fa1c811d55c0d631a8d57a046f40cda8b854e5f --- M MassMessage.php M includes/ApiEditMassMessageList.php A includes/ApiQueryMMSites.php M includes/MassMessage.php M modules/ext.MassMessage.autocomplete.js M modules/ext.MassMessage.content.js M modules/ext.MassMessage.create.js M modules/ext.MassMessage.special.js 8 files changed, 185 insertions(+), 74 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/09/150509/1 diff --git a/MassMessage.php b/MassMessage.php index c6bb176..6bd9289 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -69,6 +69,7 @@ $wgAutoloadClasses['MassMessageHooks'] = $dir/MassMessage.hooks.php; $wgAutoloadClasses['ApiMassMessage'] = $dir/includes/ApiMassMessage.php; $wgAutoloadClasses['ApiEditMassMessageList'] = $dir/includes/ApiEditMassMessageList.php; +$wgAutoloadClasses['ApiQueryMMSites'] = $dir/includes/ApiQueryMMSites.php; $wgAutoloadClasses['MassMessage'] = $dir/includes/MassMessage.php; $wgAutoloadClasses['MassMessageTargets'] = $dir/includes/MassMessageTargets.php; $wgAutoloadClasses['SpecialMassMessage'] = $dir/includes/SpecialMassMessage.php; @@ -89,6 +90,7 @@ // API modules $wgAPIModules['massmessage'] = 'ApiMassMessage'; $wgAPIModules['editmassmessagelist'] = 'ApiEditMassMessageList'; +$wgAPIListModules['mmsites'] = 'ApiQueryMMSites'; // Job classes $wgJobClasses['MassMessageJob'] = 'MassMessageJob'; @@ -111,10 +113,14 @@ $wgSpecialPages['EditMassMessageList'] = 'SpecialEditMassMessageList'; // ResourceLoader +$wgResourceModules['ext.MassMessage.autocomplete'] = array( + 'scripts' = 'ext.MassMessage.autocomplete.js', + 'localBasePath' = $dir . '/modules', + 'remoteExtPath' = 'MassMessage/modules', +); $wgResourceModules['ext.MassMessage.special.js'] = array( 'scripts' = array( 'ext.MassMessage.special.js', - 'ext.MassMessage.autocomplete.js', 'ext.MassMessage.badhtml.js', ), 'messages' = array( @@ -122,6 +128,7 @@ 'massmessage-parse-badpage' ), 'dependencies' = array( + 'ext.MassMessage.autocomplete', 'jquery.byteLimit', 'jquery.ui.autocomplete', 'jquery.throttle-debounce', @@ -154,9 +161,11 @@ 'massmessage-content-adderror', ), 'dependencies' = array( + 'ext.MassMessage.autocomplete', 'mediawiki.api', 'mediawiki.util', 'mediawiki.jqueryMsg', + 'jquery.ui.autocomplete', ), 'localBasePath' = $dir . '/modules', 'remoteExtPath' = 'MassMessage/modules', @@ -173,6 +182,10 @@ ); $wgResourceModules['ext.MassMessage.create'] = array( 'scripts' = 'ext.MassMessage.create.js', + 'dependencies' = array( + 'ext.MassMessage.autocomplete', + 'jquery.ui.autocomplete', + ), 'localBasePath' = $dir . '/modules', 'remoteExtPath' = 'MassMessage/modules', ); diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php index 7e8aa97..886caa0 100644 --- a/includes/ApiEditMassMessageList.php +++ b/includes/ApiEditMassMessageList.php @@ -1,5 +1,9 @@ ?php - +/** + * API module to edit a MassMessage delivery list + * + * @ingroup API + */ class ApiEditMassMessageList extends ApiBase { public function execute() { diff --git a/includes/ApiQueryMMSites.php b/includes/ApiQueryMMSites.php new file mode 100644 index 000..503beec --- /dev/null +++ b/includes/ApiQueryMMSites.php @@ -0,0 +1,54 @@ +?php +/** + * API module to serve autocomplete requests for the site field in MassMessage + * + * @ingroup API + */ +class ApiQueryMMSites extends ApiQueryBase { + + public function execute() { + $params = $this-extractRequestParams(); + $term = strtolower( $params['term'] ); + + $sites = array_keys( MassMessage::getDatabases() ); + $matches = array(); + foreach ( $sites as $site ) { + if ( strpos( $site, $term ) === 0 ) { + $matches[] = $site; + if ( count( $matches ) = 10 ) { + break; + } + } + } + + $result = $this-getResult(); + $result-setIndexedTagName( $matches, site ); + $result-addValue(
[MediaWiki-commits] [Gerrit] Don't reuse $result - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/150481 Change subject: Don't reuse $result .. Don't reuse $result Fix repurposing of variable. Change-Id: Ie565a190ff1ea7d47633cba464bac555be80bb8a --- M includes/ApiEditMassMessageList.php 1 file changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/81/150481/1 diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php index b879894..7e8aa97 100644 --- a/includes/ApiEditMassMessageList.php +++ b/includes/ApiEditMassMessageList.php @@ -63,14 +63,14 @@ 'MassMessageListContentHandler::compareTargets' ) ); } - $result = MassMessageListContentHandler::edit( + $editResult = MassMessageListContentHandler::edit( $spamlist, $description, $newTargets, 'massmessage-api-editsummary', $this // APIs implement IContextSource ); - if ( !$result-isGood() ) { + if ( !$editResult-isGood() ) { $this-dieStatus( $result ); } -- To view, visit https://gerrit.wikimedia.org/r/150481 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie565a190ff1ea7d47633cba464bac555be80bb8a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Enable editing of old revisions - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/149525 Change subject: Enable editing of old revisions .. Enable editing of old revisions Clicking 'Edit' when viewing an old revision correctly switches to editing an old revision. Change-Id: Ib63702d06daf7088dcd4cadb20538053dbbe86ef --- M MassMessage.hooks.php M includes/SpecialEditMassMessageList.php 2 files changed, 34 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/25/149525/1 diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index 6f12f6d..39683fc 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -145,9 +145,11 @@ if ( $title-hasContentModel( 'MassMessageListContent' ) array_key_exists( 'edit', $links['views'] ) ) { + $revId = $sktemplate-getRequest()-getInt( 'oldid' ); + $query = ( $revId 0 ) ? 'oldid=' . $revId : ''; $links['views']['edit']['href'] = SpecialPage::getTitleFor( 'EditMassMessageList', $title - )-getFullUrl(); + )-getFullUrl( $query ); } return true; } diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index f5af8ae..55e7aaf 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -8,6 +8,12 @@ protected $title; /** +* The revision ID to edit. +* @var int|null +*/ + protected $revId; + + /** * The message key for the error encountered while parsing the title, if any. * @var string|null */ @@ -35,6 +41,19 @@ $this-errorMsgKey = 'massmessage-edit-nopermission'; } else { $this-title = $title; + + // Set $revId if editing an old revision. + $revId = $this-getRequest()-getInt( 'oldid' ); + if ( $revId 0 ) { + $rev = Revision::newFromId( $revId ); + if ( $rev +$rev-getTitle()-equals( $title ) +$rev-getContentModel() === 'MassMessageListContent' +$rev-getId() !== $title-getLatestRevID() + ) { + $this-revId = $revId; + } + } } } } @@ -49,7 +68,11 @@ return array(); } - $content = Revision::newFromTitle( $this-title )-getContent(); + if ( $this-revId ) { // Editing an old revision + $content = Revision::newFromId( $this-revId )-getContent(); + } else { + $content = Revision::newFromTitle( $this-title )-getContent(); + } $description = $content-getDescription(); $targets = $content-getTargets(); @@ -90,11 +113,15 @@ */ protected function preText() { if ( $this-title ) { - $msgKey = 'massmessage-edit-header'; + $html = Html::rawElement( 'p', array(), + $this-msg( 'massmessage-edit-header' )-parse() ); + if ( $this-revId ) { + $html .= Html::rawElement( 'p', array(), $this-msg( 'editingold' )-parse() ); + } } else { - $msgKey = $this-errorMsgKey; + $html = Html::rawElement( 'p', array(), $this-msg( $this-errorMsgKey )-parse() ); } - return 'p' . $this-msg( $msgKey )-parse() . '/p'; + return $html; } /** -- To view, visit https://gerrit.wikimedia.org/r/149525 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib63702d06daf7088dcd4cadb20538053dbbe86ef Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Replace list with (Empty) when all items are removed - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/149273 Change subject: Replace list with (Empty) when all items are removed .. Replace list with (Empty) when all items are removed Change-Id: I2c5aa75d3445e2362211b8ed6b3b51565526faa3 --- M MassMessage.php M i18n/en.json M i18n/qqq.json M modules/ext.MassMessage.content.css M modules/ext.MassMessage.content.js 5 files changed, 27 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/73/149273/1 diff --git a/MassMessage.php b/MassMessage.php index f0044eb..c6bb176 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -144,6 +144,7 @@ 'scripts' = 'ext.MassMessage.content.js', 'messages' = array( 'massmessage-content-remove', + 'massmessage-content-emptylist', 'massmessage-content-addeditem', 'massmessage-content-removeerror', 'massmessage-content-alreadyinlist', diff --git a/i18n/en.json b/i18n/en.json index 1f17808..e75e688 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -50,6 +50,7 @@ massmessage-content-remove: remove, massmessage-content-removeerror: Removing the page failed with error code $1., massmessage-content-empty: There are no pages in this list., + massmessage-content-emptylist: (Empty), massmessage-content-addheading: Add pages, massmessage-content-addtitle: Title:, massmessage-content-addsite: Site:, diff --git a/i18n/qqq.json b/i18n/qqq.json index 4cd6cde..c727ea6 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -50,7 +50,8 @@ massmessage-content-localpages: Subheading for the list of pages on the local wiki, massmessage-content-remove: Label for the link to remove a page from a delivery list, massmessage-content-removeerror: Error message shown when removing a page using the link next to each item failed, - massmessage-content-empty: Message shown when viewing a delivery list if it is empty, + massmessage-content-empty: Message shown when viewing a delivery list if it is completely empty, + massmessage-content-emptylist, Message that replaces a section of a delivery list (e.g. pages on a particular wiki) when all pages in the section are removed, massmessage-content-addheading: Heading for the form for adding pages when viewing delivery lists, massmessage-content-addtitle: Label for the title field in the form for adding pages, massmessage-content-addsite: Label for the site field in the form for adding pages, diff --git a/modules/ext.MassMessage.content.css b/modules/ext.MassMessage.content.css index 64bfbae..58a5062 100644 --- a/modules/ext.MassMessage.content.css +++ b/modules/ext.MassMessage.content.css @@ -8,6 +8,10 @@ margin-left: 20px; } +.mw-massmessage-emptylist { + font-style: italic; +} + #mw-massmessage-addpages label { margin-right: 2px; } diff --git a/modules/ext.MassMessage.content.js b/modules/ext.MassMessage.content.js index a74ace3..5c57dd5 100644 --- a/modules/ext.MassMessage.content.js +++ b/modules/ext.MassMessage.content.js @@ -7,7 +7,7 @@ // Append an added page to the displayed list. var appendAdded = function ( title, site, missing ) { - var targetAttribs, targetLink, removeLink; + var targetAttribs, targetLink, removeLink, $list = $( '#mw-massmessage-addedlist ul' ); if ( !listShown ) { $( '#mw-massmessage-addedlist' ).show(); @@ -43,7 +43,12 @@ href: '#' }, mw.message( 'massmessage-content-remove' ).text() ); - $( '#mw-massmessage-addedlist ul' ).append( + // If the list was empty, remove the message saying so. + if ( $list.children( ':visible' ).length === 0 ) { + $list.prev( '.mw-massmessage-emptylist' ).remove(); + } + + $list.append( $( 'li/li' ).append( $( 'span/span' ).addClass( 'mw-massmessage-targetlink' ).html( targetLink ), $( 'span/span' ).addClass( 'mw-massmessage-removelink' ) @@ -87,8 +92,18 @@ remove: param } ) .done( function () { - // Treat as success if the page being removed could not be found. - $link.closest( 'li' ).fadeOut(); + $link.closest( 'li' ).fadeOut( 400, function () { // 400 is the default duration. + var $list =
[MediaWiki-commits] [Gerrit] Normalize JSON in preSaveTransform - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/149499 Change subject: Normalize JSON in preSaveTransform .. Normalize JSON in preSaveTransform Change-Id: I5bfa4a26a50b893afa26681bd501ff560a3e94e8 --- M includes/content/MassMessageListContent.php 1 file changed, 16 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/99/149499/1 diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index 0cd1651..e266557 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -58,6 +58,22 @@ } /** +* Returns a list content object with pre-save transformations applied. +* The implementation normalizes the JSON data. +* +* @param Title $title +* @param User $user +* @param ParserOptions $popts +* +* @return MassMessageListContent +*/ + public function preSaveTransform( Title $title, User $user, ParserOptions $popts ) { + $text = $this-getNativeData(); + $pst = FormatJson::encode( FormatJson::decode( $text ) ); + return ( $text === $pst ) ? $this : new static( $pst ); + } + + /** * @return string|null */ public function getDescription() { -- To view, visit https://gerrit.wikimedia.org/r/149499 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5bfa4a26a50b893afa26681bd501ff560a3e94e8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Handle redlinks and change placeholder - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/148702 Change subject: Handle redlinks and change placeholder .. Handle redlinks and change placeholder Correctly display redlinks when adding new pages. Change placeholder from this wiki to domain of local wiki to make the input format clearer. Change-Id: I168117707c87e0dab4950692549cd944e196 --- M i18n/en.json M i18n/qqq.json M includes/ApiEditMassMessageList.php M includes/content/MassMessageListContent.php M modules/ext.MassMessage.content.js 5 files changed, 31 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/02/148702/1 diff --git a/i18n/en.json b/i18n/en.json index d9efae3..c1ff72a 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -53,7 +53,6 @@ massmessage-content-addheading: Add pages, massmessage-content-addtitle: Title:, massmessage-content-addsite: Site:, - massmessage-content-thiswiki: This wiki, massmessage-content-addsubmit: Add page, massmessage-content-addedlistheading: Pages added:, massmessage-content-addeditem: $1 on $2, diff --git a/i18n/qqq.json b/i18n/qqq.json index 7b71d69..17333fb 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -54,7 +54,6 @@ massmessage-content-addheading: Heading for the form for adding pages when viewing delivery lists, massmessage-content-addtitle: Label for the title field in the form for adding pages, massmessage-content-addsite: Label for the site field in the form for adding pages, - massmessage-content-thiswiki: Placeholder text for the site field (site defaults to the local wiki if left blank), massmessage-content-addsubmit: Label for the button to add the entered page, massmessage-content-addedlistheading: Subheading for the list of pages just added, massmessage-content-addeditem: A target on another wiki in the list of pages just added\n* $1 is a link to the target\n* 2 is the domain of the wiki, diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php index a4eec4f..06cddb8 100644 --- a/includes/ApiEditMassMessageList.php +++ b/includes/ApiEditMassMessageList.php @@ -76,6 +76,16 @@ if ( isset( $data['add'] ) ) { $resultArray['added'] = array_values( array_udiff( $newTargets, $targets, 'MassMessageListContentHandler::compareTargets' ) ); + + // Add an empty missing attribute to new local targets that do not exist + foreach ( $resultArray['added'] as $target ) { + if ( !isset( $target['site'] ) +!Title::newFromText( $target['title'] )-exists() + ) { + $target['missing'] = ''; + } + } + $result-setIndexedTagName( $resultArray['added'], 'page' ); if ( !empty( $invalidAdd ) ) { diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index 3176fdb..a62e12c 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -219,7 +219,7 @@ * @return string */ protected static function getAddForm() { - global $wgAllowGlobalMessaging; + global $wgAllowGlobalMessaging, $wgCanonicalServer; $html = Html::openElement( 'div', array( 'id' = 'mw-massmessage-addpages' ) ); $html .= Html::element( 'h2', array(), @@ -235,7 +235,7 @@ wfMessage( 'massmessage-content-addsite' )-text() ); $html .= Html::input( 'site', '', 'text', array( 'id' = 'mw-massmessage-addsite', - 'placeholder' = wfMessage( 'massmessage-content-thiswiki' )-text() + 'placeholder' = MassMessage::getBaseUrl( $wgCanonicalServer ) ) ); } $html .= Html::input( 'submit', wfMessage( 'massmessage-content-addsubmit' )-escaped(), diff --git a/modules/ext.MassMessage.content.js b/modules/ext.MassMessage.content.js index 9eca1ab..c6ef862 100644 --- a/modules/ext.MassMessage.content.js +++ b/modules/ext.MassMessage.content.js @@ -6,8 +6,8 @@ var listShown = false; // Append an added page to the displayed list. - var appendAdded = function ( title, site ) { - var targetLink, removeLink; + var appendAdded = function ( title, site, missing ) { + var targetAttribs, targetLink, removeLink;
[MediaWiki-commits] [Gerrit] Differentiate invalid title and invalid site - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/148950 Change subject: Differentiate invalid title and invalid site .. Differentiate invalid title and invalid site Make the error message on adding a page more descriptive. Change-Id: Ic194c3f94e27cfb1d31b6f7c88584aa3f2e05ee4 --- M MassMessage.php M i18n/en.json M i18n/qqq.json M includes/ApiEditMassMessageList.php M includes/SpecialEditMassMessageList.php M includes/content/MassMessageListContentHandler.php M modules/ext.MassMessage.content.js 7 files changed, 45 insertions(+), 27 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/50/148950/1 diff --git a/MassMessage.php b/MassMessage.php index 7bda48b..f0044eb 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -147,7 +147,9 @@ 'massmessage-content-addeditem', 'massmessage-content-removeerror', 'massmessage-content-alreadyinlist', - 'massmessage-content-invalidadd', + 'massmessage-content-invalidtitlesite', + 'massmessage-content-invalidtitle', + 'massmessage-content-invalidsite', 'massmessage-content-adderror', ), 'dependencies' = array( diff --git a/i18n/en.json b/i18n/en.json index c1ff72a..1f17808 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -57,7 +57,9 @@ massmessage-content-addedlistheading: Pages added:, massmessage-content-addeditem: $1 on $2, massmessage-content-alreadyinlist: The page is already in the list., - massmessage-content-invalidadd: The page is invalid., + massmessage-content-invalidtitlesite: The title and site are invalid., + massmessage-content-invalidtitle: The title is invalid., + massmessage-content-invalidsite: The site is invalid., massmessage-content-adderror: API Error: $1, massmessage-ch-tojsonerror: The list could not be encoded for storage., massmessage-ch-apierror: Editing the list through the API failed with error code $1., diff --git a/i18n/qqq.json b/i18n/qqq.json index 17333fb..4cd6cde 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -58,7 +58,9 @@ massmessage-content-addedlistheading: Subheading for the list of pages just added, massmessage-content-addeditem: A target on another wiki in the list of pages just added\n* $1 is a link to the target\n* 2 is the domain of the wiki, massmessage-content-alreadyinlist: Error message shown next to form for adding pages when the page is already in the list, - massmessage-content-invalidadd: Error message shown next to the form for adding pages when the title or site is invalid, + massmessage-content-invalidtitlesite: Error message shown next to the form for adding pages when the title and site are both invalid, + massmessage-content-invalidtitle: Error message shown next to the form for adding pages when the title is invalid, + massmessage-content-invalidsite: Error message shown next to the form for adding pages when the site is invalid, massmessage-content-adderror: Error message shown next to the form for adding pages when the API request failed\n* $1 is the error code, massmessage-ch-tojsonerror: Error message shown when the input could not be successfully encoded as a delivery list, massmessage-ch-apierror: Error message shown when a request to the edit API to update a delivery list failed, diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php index 6129f63..b879894 100644 --- a/includes/ApiEditMassMessageList.php +++ b/includes/ApiEditMassMessageList.php @@ -26,8 +26,12 @@ foreach ( $data['add'] as $page ) { $target = MassMessageListContentHandler::extractTarget( $page ); - if ( $target === null ) { - $invalidAdd[] = $page; + if ( isset( $target['errors'] ) ) { + $item = array( '*' = $page ); + foreach( $target['errors'] as $error ) { + $item[$error] = ''; + } + $invalidAdd[] = $item; } else { $newTargets[] = $target; } @@ -44,7 +48,7 @@ foreach ( $data['remove'] as $page ) { $target = MassMessageListContentHandler::extractTarget( $page ); - if ( $target === null || !in_array( $target, $newTargets ) ) { + if ( isset( $target['errors'] ) || !in_array( $target,
[MediaWiki-commits] [Gerrit] Handle titles containing @ in JS - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/148342 Change subject: Handle titles containing @ in JS .. Handle titles containing @ in JS Correctly handle titles containing @ on the local site. Change-Id: I8733e09aea661625bcb8d5716e5d496d605d1e52 --- M modules/ext.MassMessage.content.js 1 file changed, 7 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/42/148342/1 diff --git a/modules/ext.MassMessage.content.js b/modules/ext.MassMessage.content.js index 0898220..2171a0c 100644 --- a/modules/ext.MassMessage.content.js +++ b/modules/ext.MassMessage.content.js @@ -90,7 +90,7 @@ // Handle add pages form. $( '#mw-massmessage-addform' ).submit( function( e ) { - var title, site, param; + var title, site, wgServer, param; e.preventDefault(); @@ -104,7 +104,12 @@ $( '#mw-massmessage-addform .error' ).remove(); if ( site === '' ) { - param = title; + if ( title.indexOf( '@' ) = 0 ) { // Handle titles containing '@' + wgServer = mw.config.get( 'wgServer' ); + param = title + '@' + wgServer.substr( wgServer.indexOf( '//' ) + 2 ); + } else { + param = title; + } } else { param = title + '@' + site; } -- To view, visit https://gerrit.wikimedia.org/r/148342 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8733e09aea661625bcb8d5716e5d496d605d1e52 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Change API to allow partially invalid requests - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/148416 Change subject: Change API to allow partially invalid requests .. Change API to allow partially invalid requests Have API return arrays of successfully added / removed pages and invalid titles; change JS to use the new API (and show normalized titles); remove getResultProperties from API. Change-Id: Ia9b450324df2f5d2481c09c08b7408d1dc4606ec --- M includes/ApiEditMassMessageList.php M modules/ext.MassMessage.content.js 2 files changed, 58 insertions(+), 49 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/16/148416/1 diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php index 2129eb6..a4eec4f 100644 --- a/includes/ApiEditMassMessageList.php +++ b/includes/ApiEditMassMessageList.php @@ -22,31 +22,38 @@ $newTargets = $targets; // Create a copy. if ( isset( $data['add'] ) ) { + $invalidAdd = array(); + foreach ( $data['add'] as $page ) { $target = MassMessageListContentHandler::extractTarget( $page ); if ( $target === null ) { - $this-dieUsage( 'One of the pages to be added is invalid', 'invalidadd' ); + $invalidAdd[] = $page; + } else { + $newTargets[] = $target; } - $newTargets[] = $target; } + // Remove duplicates $newTargets = MassMessageListContentHandler::normalizeTargetArray( $newTargets ); + $invalidAdd = array_unique( $invalidAdd ); } if ( isset( $data['remove'] ) ) { $toRemove = array(); + $invalidRemove = array(); + foreach ( $data['remove'] as $page ) { $target = MassMessageListContentHandler::extractTarget( $page ); if ( $target === null || !in_array( $target, $newTargets ) ) { - $this-dieUsage( - 'One of the pages to be removed is invalid or not in the spamlist', - 'invalidremove' - ); + $invalidRemove[] = $page; + } else { + $toRemove[] = $target; } - $toRemove[] = $target; } + // In case there are duplicates within the provided list $toRemove = MassMessageListContentHandler::normalizeTargetArray( $toRemove ); + $invalidRemove = array_unique( $invalidRemove ); $newTargets = array_values( array_udiff( $newTargets, $toRemove, 'MassMessageListContentHandler::compareTargets' ) ); @@ -63,16 +70,34 @@ $this-dieStatus( $result ); } + $result = $this-getResult(); $resultArray = array( 'result' = 'Success' ); + if ( isset( $data['add'] ) ) { - $resultArray['added'] = count( array_udiff( $newTargets, $targets, + $resultArray['added'] = array_values( array_udiff( $newTargets, $targets, 'MassMessageListContentHandler::compareTargets' ) ); + $result-setIndexedTagName( $resultArray['added'], 'page' ); + + if ( !empty( $invalidAdd ) ) { + $resultArray['result'] = 'Done'; + $resultArray['invalidadd'] = $invalidAdd; + $result-setIndexedTagName( $resultArray['invalidadd'], 'item' ); + } } + if ( isset( $data['remove'] ) ) { - $resultArray['removed'] = count( array_udiff( $targets, $newTargets, + $resultArray['removed'] = array_values( array_udiff( $targets, $newTargets, 'MassMessageListContentHandler::compareTargets' ) ); + $result-setIndexedTagName( $resultArray['removed'], 'page' ); + + if ( !empty( $invalidRemove ) ) { + $resultArray['result'] = 'Done'; + $resultArray['invalidremove'] = $invalidRemove; +
[MediaWiki-commits] [Gerrit] [WIP] Add ability to add pages to spamlist view - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/146705 Change subject: [WIP] Add ability to add pages to spamlist view .. [WIP] Add ability to add pages to spamlist view Also change some Html::rawElement to Html::element Change-Id: I9c1eb5370f0b7e44bb6b1afebed0922a8641a663 --- M i18n/en.json M includes/content/MassMessageListContent.php M modules/ext.MassMessage.content.css M modules/ext.MassMessage.content.js M modules/ext.MassMessage.content.noedit.css M modules/ext.MassMessage.content.nojs.css 6 files changed, 70 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/05/146705/1 diff --git a/i18n/en.json b/i18n/en.json index e6d8a08..3ce5964 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -49,7 +49,11 @@ massmessage-content-localpages: Pages on this wiki:, massmessage-content-remove: remove, massmessage-content-empty: There are no pages in this list., - massmessage-content-removeerror: Removing the page failed with the following error: $1, + massmessage-content-addheading: Add pages, + massmessage-content-addtitle: Title:, + massmessage-content-addsite: Site:, + massmessage-content-addsubmit: Add page, + massmessage-content-removeerror: Removing the page failed with errror code $1., massmessage-ch-tojsonerror: The list could not be encoded for storage., massmessage-ch-apierror: Editing the list through the API failed with errror code $1., createmassmessagelist-legend: Create mass message delivery list, diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index 9f4f409..7fd893b 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -105,6 +105,13 @@ // Parse the description text. $output = $wgParser-parse( $this-getDescription(), $title, $options, true, true, $revId ); + // Generate output HTML, if needed. + if ( $generateHtml ) { + $output-setText( $output-getText() . $this-getTargetsHtml() . self::getAddForm() ); + } else { + $output-setText( '' ); + } + // Update the links table. $targets = $this-getTargets(); foreach ( $targets as $target ) { @@ -114,13 +121,6 @@ $output-addExternalLink( '//' . $target['site'] . $wgScript . '?title=' . Title::newFromText( $target['title'] )-getPrefixedURL() ); } - } - - // Add the list content to the output, if needed. - if ( $generateHtml ) { - $output-setText( $output-getText() . $this-getTargetsHtml() ); - } else { - $output-setText( '' ); } } @@ -132,15 +132,14 @@ protected function getTargetsHtml() { global $wgScript; - $html = Html::rawElement( 'h2', array(), - wfMessage( 'massmessage-content-pages' )-parse() ); + $html = Html::element( 'h2', array(), wfMessage( 'massmessage-content-pages' )-text() ); $sites = $this-getTargetsBySite(); // If the list is empty if ( count( $sites ) === 0 ) { - $html .= Html::rawElement( 'p', array(), - wfMessage( 'massmessage-content-empty' )-parse() ); + $html .= Html::element( 'p', array(), + wfMessage( 'massmessage-content-empty' )-text() ); return $html; } @@ -151,11 +150,11 @@ foreach ( $sites as $site = $targets ) { if ( $printSites ) { if ( $site === 'local' ) { - $html .= Html::rawElement( 'p', array(), - wfMessage( 'massmessage-content-localpages' )-parse() ); + $html .= Html::element( 'p', array(), + wfMessage( 'massmessage-content-localpages' )-text() ); } else { - $html .= Html::rawElement( 'p', array(), - wfMessage( 'massmessage-content-pagesonsite', $site )-parse() ); + $html .= Html::element( 'p', array(), + wfMessage( 'massmessage-content-pagesonsite', $site )-text() ); } } @@ -174,13
[MediaWiki-commits] [Gerrit] [WIP] Add UI to remove targets in list view - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/145755 Change subject: [WIP] Add UI to remove targets in list view .. [WIP] Add UI to remove targets in list view Change-Id: Id42c1391ad62ea97cb52fe27666c013d5ce57300 --- M MassMessage.hooks.php M MassMessage.php M includes/content/MassMessageListContent.php A modules/ext.MassMessage.content.css A modules/ext.MassMessage.content.js A modules/ext.MassMessage.content.nojs.css A modules/ext.MassMessage.content.nopermission.css 7 files changed, 85 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/55/145755/1 diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index 34d3433..d930dc6 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -136,8 +136,8 @@ /** * Override the Edit tab for delivery lists -* @param SkinTemplate $sktemplate -* @param array $links +* @param SkinTemplate $sktemplate +* @param array $links * @return bool */ public static function onSkinTemplateNavigation( $sktemplate, $links ) { @@ -151,4 +151,18 @@ } return true; } + + /** +* Add scripts and styles +* @param OutputPage $out +* @param Skin $skin +* @return bool +*/ + public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { + if ( $out-getTitle()-hasContentModel( 'MassMessageListContent' ) ) { + $out-addModuleStyles( 'ext.MassMessage.content.nojs' ); + $out-addModules( 'ext.MassMessage.content' ); + } + return true; + } } diff --git a/MassMessage.php b/MassMessage.php index 66d84e7..2d65ef6 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -103,6 +103,7 @@ $wgHooks['UnitTestsList'][] = 'MassMessageHooks::onUnitTestsList'; $wgHooks['BeforeEchoEventInsert'][] = 'MassMessageHooks::onBeforeEchoEventInsert'; $wgHooks['SkinTemplateNavigation'][] = 'MassMessageHooks::onSkinTemplateNavigation'; +$wgHooks['BeforePageDisplay'][] = 'MassMessageHooks::onBeforePageDisplay'; // Special pages $wgSpecialPages['MassMessage'] = 'SpecialMassMessage'; @@ -116,7 +117,10 @@ 'ext.MassMessage.autocomplete.js', 'ext.MassMessage.badhtml.js', ), - 'messages' = array( 'massmessage-badhtml', 'massmessage-parse-badpage' ), + 'messages' = array( + 'massmessage-badhtml', + 'massmessage-parse-badpage' + ), 'dependencies' = array( 'jquery.byteLimit', 'jquery.ui.autocomplete', @@ -131,10 +135,24 @@ 'localBasePath' = $dir . '/modules', 'remoteExtPath' = 'MassMessage/modules', ); +$wgResourceModules['ext.MassMessage.content'] = array( + 'styles' = 'ext.MassMessage.content.css', + 'scripts' = 'ext.MassMessage.content.js', + 'localBasePath' = $dir . '/modules', + 'remoteExtPath' = 'MassMessage/modules', +); +$wgResourceModules['ext.MassMessage.content.nojs'] = array( + 'styles' = 'ext.MassMessage.content.nojs.css', + 'localBasePath' = $dir . '/modules', + 'remoteExtPath' = 'MassMessage/modules', +); +$wgResourceModules['ext.MassMessage.content.nopermission'] = array( + 'styles' = 'ext.MassMessage.content.nopermission.css', + 'localBasePath' = $dir . '/modules', + 'remoteExtPath' = 'MassMessage/modules', +); $wgResourceModules['ext.MassMessage.create'] = array( - 'scripts' = array( - 'ext.MassMessage.create.js', - ), + 'scripts' = 'ext.MassMessage.create.js', 'localBasePath' = $dir . '/modules', 'remoteExtPath' = 'MassMessage/modules', ); diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index e17865e..6c501d7 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -161,15 +161,35 @@ $html .= Html::openElement( 'ul' ); foreach ( $targets as $target ) { + $title = Title::newFromText( $target ); + + // Generate the HTML for the link to the target. if ( $site === 'local' ) { - $html .= Html::rawElement( 'li', array(), - Linker::link( Title::newFromText( $target ) ) ); + $targetLink = Linker::link( $title ); } else { - $title = Title::newFromText( $target ); - $url = //$site$wgScript?title= . $title-getPrefixedURL(); -
[MediaWiki-commits] [Gerrit] Add common edit function and refactor code - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/144919 Change subject: Add common edit function and refactor code .. Add common edit function and refactor code Increase the amount of shared code. Not sure if the functions belong in MassMessageListContentHandler, though. Change-Id: Ic52cf52aa32f778f75567ae1ffa52e721c6718f9 --- M i18n/en.json M i18n/qqq.json M includes/ApiMassMessage.php M includes/MassMessageTargets.php M includes/SpecialCreateMassMessageList.php M includes/SpecialEditMassMessageList.php M includes/content/MassMessageListContentHandler.php 7 files changed, 145 insertions(+), 136 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/19/144919/1 diff --git a/i18n/en.json b/i18n/en.json index c181306..2303049 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -48,6 +48,8 @@ massmessage-content-pagesonsite: Pages on $1:, massmessage-content-localpages: Pages on this wiki:, massmessage-content-empty: There are no pages in this list., + massmessage-content-tojsonerror: The list could not be encoded for storage., + massmessage-content-apierror: Creating the list through the API failed with errror code $1., createmassmessagelist-legend: Create mass message delivery list, massmessage-create-title: Title:, massmessage-create-description: Description:, @@ -60,8 +62,6 @@ massmessage-create-exists: A page already exists at the specified title., massmessage-create-nopermission: You do not have permission to create a list at this title., massmessage-create-invalidsource: The specified source is not a valid delivery list or category., - massmessage-create-tojsonerror: The list could not be encoded for storage., - massmessage-create-apierror: Creating the list through the API failed with errror code $1., editmassmessagelist-legend: Edit mass message delivery list, massmessage-edit-title: Title:, massmessage-edit-description: Description:, @@ -70,7 +70,5 @@ massmessage-edit-editsummary: Updating mass message delivery list, massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., massmessage-edit-invalidtargets: One of more of the entries in the list are invalid., - massmessage-edit-nopermission: You do not have permission to edit the list., - massmessage-edit-tojsonerror: The list could not be encoded for storage., - massmessage-edit-apierror: Saving changes through the API failed with errror code $1. -} \ No newline at end of file + massmessage-edit-nopermission: You do not have permission to edit the list. +} diff --git a/i18n/qqq.json b/i18n/qqq.json index 4f4bedb..5905c91 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -49,6 +49,8 @@ massmessage-content-pagesonsite: Subheading for the list of pages on a particular wiki\n* $1 is the domain of the wiki, massmessage-content-localpages: Subheading for the list of pages on the local wiki, massmessage-content-empty: Message shown when viewing a delivery list if it is empty, + massmessage-content-tojsonerror: Error message shown when the input could not be successfully encoded as a delivery list, + massmessage-content-apierror: Error message shown when a request to the edit API to update a delivery list failed, createmassmessagelist-legend: Form legend for [[Special:CreateMassMessageList]], massmessage-create-title: Label for an inputbox on [[Special:CreateMassMessageList]], massmessage-create-description: Label for a textarea on [[Special:CreateMassMessageList]], @@ -60,9 +62,7 @@ massmessage-create-invalidtitle: Error message shown on [[Special:CreateMassMessageList]] when the title is inavlid, massmessage-create-exists: Error message shown on [[Special:CreateMassMessageList]] when a page with the title already exists, massmessage-create-nopermission: Error message shown on [[Special:CreateMassMessageList]] when the user cannot create a page with the title, - massmessage-create-tojsonerror: Error message shown on [[Special:CreateMassMessageList]] when the input could not be successfully encoded, massmessage-create-invalidsource: Error message shown on [[Special:CreateMassMessageList]] when the source from which to import targets is invalid, - massmessage-create-apierror: Error message shown on [[Special:CreateMassMessageList]] when the API request to create the page failed, editmassmessagelist-legend: Form legend for [[Special:EditMassMessageList]], massmessage-edit-title: Label for an inputbox on [[Special:EditMassMessageList]], massmessage-edit-description: Label for a textarea on [[Special:EditMassMessageList]], @@ -71,7 +71,5 @@
[MediaWiki-commits] [Gerrit] Add API for editing delivery lists - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/144920 Change subject: Add API for editing delivery lists .. Add API for editing delivery lists Change-Id: Ib2ef8adfe9f3ffd77f855063b6680455fcdde47a --- M MassMessage.php M i18n/en.json M i18n/qqq.json A includes/ApiEditMassMessageList.php 4 files changed, 184 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/20/144920/1 diff --git a/MassMessage.php b/MassMessage.php index f946512..66d84e7 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -68,6 +68,7 @@ // Classes $wgAutoloadClasses['MassMessageHooks'] = $dir/MassMessage.hooks.php; $wgAutoloadClasses['ApiMassMessage'] = $dir/includes/ApiMassMessage.php; +$wgAutoloadClasses['ApiEditMassMessageList'] = $dir/includes/ApiEditMassMessageList.php; $wgAutoloadClasses['MassMessage'] = $dir/includes/MassMessage.php; $wgAutoloadClasses['MassMessageTargets'] = $dir/includes/MassMessageTargets.php; $wgAutoloadClasses['SpecialMassMessage'] = $dir/includes/SpecialMassMessage.php; @@ -87,6 +88,7 @@ // API modules $wgAPIModules['massmessage'] = 'ApiMassMessage'; +$wgAPIModules['editmassmessagelist'] = 'ApiEditMassMessageList'; // Job classes $wgJobClasses['MassMessageJob'] = 'MassMessageJob'; diff --git a/i18n/en.json b/i18n/en.json index 2303049..e3bc63a 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -70,5 +70,6 @@ massmessage-edit-editsummary: Updating mass message delivery list, massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., massmessage-edit-invalidtargets: One of more of the entries in the list are invalid., - massmessage-edit-nopermission: You do not have permission to edit the list. + massmessage-edit-nopermission: You do not have permission to edit the list., + massmessage-api-editsummary: Updating mass message delivery list } diff --git a/i18n/qqq.json b/i18n/qqq.json index 5905c91..49c1fbe 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -71,5 +71,6 @@ massmessage-edit-editsummary: Edit summary for editing a delivery list, massmessage-edit-invalidtitle: Error message shown on [[Special:EditMassMessageList]] when the title is invalid, massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid, - massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list + massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list, + massmessage-api-editsummary: Edit summary for editing a delivery list using the API } diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php new file mode 100644 index 000..be0ad48 --- /dev/null +++ b/includes/ApiEditMassMessageList.php @@ -0,0 +1,178 @@ +?php + +class ApiEditMassMessageList extends ApiBase { + + public function execute() { + $data = $this-extractRequestParams(); + + if ( !isset( $data['spamlist'] ) ) { + $this-dieUsage( 'No spamlist was specified', 'nospamlist' ); + } + if ( !isset( $data['add'] ) !isset( $data['remove'] ) ) { + $this-dieUsage( 'No operation was specified', 'nooperation' ); + } + + $spamlist = Title::newFromText( $data['spamlist'] ); + if ( $spamlist === null + || !$spamlist-exists() + || !$spamlist-hasContentModel( 'MassMessageListContent' ) + ) { + $this-dieUsage( 'The specified spamlist is invalid', 'invalidspamlist' ); + } + + $content = Revision::newFromTitle( $spamlist )-getContent(); + $description = $content-getDescription(); + $targets = $content-getTargets(); + $newTargets = $targets; // Create a copy. + + if ( isset( $data['add'] ) ) { + foreach ( $data['add'] as $page ) { + $target = MassMessageListContentHandler::extractTarget( $page ); + if ( $target === null ) { + $this-dieUsage( 'One of the pages to be added is invalid', 'invalidadd' ); + } + $newTargets[] = $target; + } + // Remove duplicates + $newTargets = MassMessageListContentHandler::normalizeTargetArray( $newTargets ); + } + + if ( isset( $data['remove'] ) ) { + $toRemove = array(); + foreach ( $data['remove'] as
[MediaWiki-commits] [Gerrit] Use API itself as context - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/145020 Change subject: Use API itself as context .. Use API itself as context Followup to Ib2ef8adfe9f3ffd77f855063b6680455fcdde47a Change-Id: I9dc0a925dc9d59022983f935334437d92c56201d --- M includes/ApiEditMassMessageList.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/20/145020/1 diff --git a/includes/ApiEditMassMessageList.php b/includes/ApiEditMassMessageList.php index d46cea4..2129eb6 100644 --- a/includes/ApiEditMassMessageList.php +++ b/includes/ApiEditMassMessageList.php @@ -57,7 +57,7 @@ $description, $newTargets, 'massmessage-api-editsummary', - $this-getContext() + $this // APIs implement IContextSource ); if ( !$result-isGood() ) { $this-dieStatus( $result ); -- To view, visit https://gerrit.wikimedia.org/r/145020 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9dc0a925dc9d59022983f935334437d92c56201d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move target extraction and ordering - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/144365 Change subject: Move target extraction and ordering .. Move target extraction and ordering Move code for extracting title and site from 'title@site' and for sorting targets into MassMessageTargets so they can be reused by API code. Change-Id: I2e9e39198986fa02abed2bfc3409356fcecd502c --- M includes/MassMessageTargets.php M includes/SpecialEditMassMessageList.php 2 files changed, 50 insertions(+), 34 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/65/144365/1 diff --git a/includes/MassMessageTargets.php b/includes/MassMessageTargets.php index a6bf3f7..eda3c1d 100644 --- a/includes/MassMessageTargets.php +++ b/includes/MassMessageTargets.php @@ -132,4 +132,42 @@ return array(); // No parser functions on page } } + + /** +* Helper function to compare two targets for ordering in usort() +* @param array $a +* @paran array $b +* @return int +*/ + public static function compareTargets( $a, $b ) { + if ( !array_key_exists( 'site', $a ) array_key_exists( 'site', $b ) ) { + return -1; + } else if ( array_key_exists( 'site', $a ) !array_key_exists( 'site', $b ) ) { + return 1; + } else if ( array_key_exists( 'site', $a ) array_key_exists( 'site', $b ) +$a['site'] !== $b['site'] + ) { + return strcmp( $a['site'], $b['site'] ); + } else { + return strcmp( $a['title'], $b['title'] ); + } + } + + /** +* Helper function for extracting title and site strings from 'title@site' +* @param string $target +* @return array +*/ + public static function extractFromTarget( $target ) { + $target = trim( $target ); + $delimiterPos = strrpos( $target, '@' ); + if ( $delimiterPos !== false $delimiterPos strlen( $target ) ) { + $title = substr( $target, 0, $delimiterPos ); + $site = strtolower( substr( $target, $delimiterPos+1 ) ); + } else { + $title = $target; + $site = ''; + } + return array( 'title' = $title, 'site' = $site ); + } } diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 5743ddf..e6d791d 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -180,27 +180,25 @@ $targets = array(); foreach ( $lines as $line ) { - $delimiterPos = strrpos( $line, '@' ); - if ( $delimiterPos !== false ) { - $titleText = substr( $line, 0, $delimiterPos ); - $site = strtolower( substr( $line, $delimiterPos+1 ) ); - if ( $site === MassMessage::getBaseUrl( $wgCanonicalServer ) ) { - $site = null; // Don't store site for local pages. - } - } else { - $titleText = $line; - $site = null; - } + $data = MassMessageTargets::extractFromTarget( $line ); - $title = Title::newFromText( $titleText ); + $title = Title::newFromText( $data['title'] ); if ( !$title ) { return null; } $titleText = $title-getPrefixedText(); // Use the canonical form. + if ( $data['site'] === '' + || $data['site'] === MassMessage::getBaseUrl( $wgCanonicalServer ) + ) { + $site = null; + } else { + $site = $data['site']; + } + if ( $site ) { $wiki = MassMessage::getDBName( $site ); - if ( $wiki === null || !$wgAllowGlobalMessaging $wiki != wfWikiID() ) { + if ( $wiki === null || !$wgAllowGlobalMessaging $wiki !== wfWikiID() ) { return null; } } @@ -214,27 +212,7 @@ // Remove duplicates and sort. $targets = array_unique( $targets, SORT_REGULAR ); - usort( $targets, 'self::compareTargets' ); +
[MediaWiki-commits] [Gerrit] Split target-related functions into separate class - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/143578 Change subject: Split target-related functions into separate class .. Split target-related functions into separate class Change-Id: I4a1235a1dca653bf42bab3d54ef7319c531e38f4 --- M MassMessage.php M includes/MassMessage.php A includes/MassMessageTargets.php M includes/SpecialCreateMassMessageList.php M tests/MassMessageTest.php 5 files changed, 140 insertions(+), 132 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/78/143578/1 diff --git a/MassMessage.php b/MassMessage.php index 6228d6e..96a93a1 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -69,6 +69,7 @@ $wgAutoloadClasses['MassMessageHooks'] = $dir/MassMessage.hooks.php; $wgAutoloadClasses['ApiMassMessage'] = $dir/includes/ApiMassMessage.php; $wgAutoloadClasses['MassMessage'] = $dir/includes/MassMessage.php; +$wgAutoloadClasses['MassMessageTargets'] = $dir/includes/MassMessageTargets.php; $wgAutoloadClasses['SpecialMassMessage'] = $dir/includes/SpecialMassMessage.php; $wgAutoloadClasses['SpecialCreateMassMessageList'] = $dir/includes/SpecialCreateMassMessageList.php; $wgAutoloadClasses['SpecialEditMassMessageList'] = $dir/includes/SpecialEditMassMessageList.php; diff --git a/includes/MassMessage.php b/includes/MassMessage.php index 90e887e..9e4610a 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -150,134 +150,6 @@ } /** -* Get array of normalized targets with duplicates removed -* @param array $data -* @return array -*/ - public static function normalizeTargets( array $data ) { - global $wgNamespacesToConvert; - - foreach ( $data as $target ) { - if ( $target['wiki'] === wfWikiID() ) { - $title = Title::newFromText( $target['title'] ); - if ( $title === null ) { - continue; - } - if ( isset( $wgNamespacesToConvert[$title-getNamespace()] ) ) { - $title = Title::makeTitle( $wgNamespacesToConvert[$title-getNamespace()], - $title-getText() ); - } - $title = self::followRedirect( $title ); - if ( $title === null ) { - continue; // Interwiki redirect - } - $target['title'] = $title-getPrefixedText(); - } - } - - // Return $data with duplicates removed - return array_unique( $data, SORT_REGULAR ); - } - - /** -* Get an array of targets given a title; returns null if invalid. -* -* Each target is an associative array with the following keys: -* title: The title of the target -* wiki: The ID of the wiki (wfWikiID() for the local wiki) -* site: The hostname and port (if exists) of the wiki -* -* @param Title $spamlist -* @param IContextSource $context -* @return array|null -*/ -public static function getTargets( Title $spamlist, $context ) { - if ( !$spamlist-exists() !$spamlist-inNamespace( NS_CATEGORY ) ) { - return null; - } - - if ( $spamlist-inNamespace( NS_CATEGORY ) ) { - return self::getCategoryTargets( $spamlist ); - } elseif ( $spamlist-hasContentModel( 'MassMessageListContent' ) ) { - return self::getMassMessageListContentTargets( $spamlist ); - } elseif ( $spamlist-hasContentModel( CONTENT_MODEL_WIKITEXT ) ) { - return self::getParserFunctionTargets( $spamlist, $context ); - } else { - return null; - } -} - - /** -* Get an array of targets from a category -* @param Title $spamlist -* @return array -*/ - public static function getCategoryTargets( Title $spamlist ) { - global $wgCanonicalServer; - - $members = Category::newFromTitle( $spamlist )-getMembers(); - $targets = array(); - - /** @var Title $member */ - foreach ( $members as $member ) { - $targets[] = array( - 'title' = $member-getPrefixedText(), - 'wiki' = wfWikiID(), - 'site' = self::getBaseUrl( $wgCanonicalServer ), - ); - } - - return $targets; -
[MediaWiki-commits] [Gerrit] Tidy preview function and comments - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/143047 Change subject: Tidy preview function and comments .. Tidy preview function and comments Remove some commented-out code from SpecialMassMessage::preview() and fix some comments elsewhere. Change-Id: I6676a9693eb598c039e415db90b5a04974c36778 --- M includes/MassMessage.php M includes/SpecialMassMessage.php 2 files changed, 18 insertions(+), 22 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/47/143047/1 diff --git a/includes/MassMessage.php b/includes/MassMessage.php index 514c5bf..90e887e 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -150,7 +150,7 @@ } /** -* Normalize target array by following redirects and removing duplicates +* Get array of normalized targets with duplicates removed * @param array $data * @return array */ @@ -180,7 +180,13 @@ } /** -* Get an array of targets given a title. +* Get an array of targets given a title; returns null if invalid. +* +* Each target is an associative array with the following keys: +* title: The title of the target +* wiki: The ID of the wiki (wfWikiID() for the local wiki) +* site: The hostname and port (if exists) of the wiki +* * @param Title $spamlist * @param IContextSource $context * @return array|null @@ -440,7 +446,7 @@ return count( $pages ); } - /* + /** * Gets a regular expression that will match this wiki's * timestamps as given by . * diff --git a/includes/SpecialMassMessage.php b/includes/SpecialMassMessage.php index ba11108..b6945b0 100644 --- a/includes/SpecialMassMessage.php +++ b/includes/SpecialMassMessage.php @@ -261,31 +261,23 @@ * @return Status */ protected function preview( array $data ) { - // $spamlist = $this-getSpamlist( $data['spamlist'] ); - // $targets = MassMessage::getParserFunctionTargets( $spamlist, $this-getContext() ); - // $firstTarget = array_values( $targets )[0]; // Why doesn't this work?? - $firstTarget = Title::newFromText( 'Project:Example' ); - $wikipage = WikiPage::factory( $firstTarget ); - - // Hacked up from EditPage.php - // Is this really the best way to do this??? - - $subject = $data['subject']; - $message = $data['message']; + // Use a mock target as the context for rendering the preview + $mockTarget = Title::newFromText( 'Project:Example' ); + $wikipage = WikiPage::factory( $mockTarget ); // Convert into a content object - $content = ContentHandler::makeContent( $message, $firstTarget ); + $content = ContentHandler::makeContent( $data['message'], $mockTarget ); // Parser stuff. Taken from EditPage::getPreviewText() $parserOptions = $wikipage-makeParserOptions( $this-getContext() ); $parserOptions-setEditSection( false ); $parserOptions-setIsPreview( true ); $parserOptions-setIsSectionPreview( false ); - $content = $content-addSectionHeader( $subject ); + $content = $content-addSectionHeader( $data['subject'] ); // Hooks not being run: EditPageGetPreviewContent, EditPageGetPreviewText - $content = $content-preSaveTransform( $firstTarget, MassMessage::getMessengerUser(), $parserOptions ); - $parserOutput = $content-getParserOutput( $firstTarget, null, $parserOptions ); + $content = $content-preSaveTransform( $mockTarget, MassMessage::getMessengerUser(), $parserOptions ); + $parserOutput = $content-getParserOutput( $mockTarget, null, $parserOptions ); $previewHTML = $parserOutput-getText(); $this-getOutput()-addWikiMsg( 'massmessage-just-preview' ); $fieldsetMessage = $this-msg( 'massmessage-fieldset-preview' )-text(); @@ -298,13 +290,11 @@ } // Check for unclosed HTML tags (Bug 54909) - $unclosedTags = $this-getUnclosedTags( $message ); + $unclosedTags = $this-getUnclosedTags( $data['message'] ); if ( !empty( $unclosedTags ) ) { $this-status-fatal( $this-msg( 'massmessage-badhtml' ) - -params( - htmlspecialchars( $this-getLanguage()-commaList( $unclosedTags ) ) - ) +
[MediaWiki-commits] [Gerrit] Improve Special:MassMessage state checking - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/142859 Change subject: Improve Special:MassMessage state checking .. Improve Special:MassMessage state checking Use getVal() instead of getText() to check for form state; replace == with ===. Change-Id: Ief4a334a1eef1fce382ebdf50011e04e4d7db702 --- M includes/SpecialMassMessage.php 1 file changed, 7 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/59/142859/1 diff --git a/includes/SpecialMassMessage.php b/includes/SpecialMassMessage.php index 8d6fb67..ba11108 100644 --- a/includes/SpecialMassMessage.php +++ b/includes/SpecialMassMessage.php @@ -47,9 +47,9 @@ $this-status = new Status(); // Figure out what state we're in. - if ( $request-getText( 'submit-button' ) == $this-msg( 'massmessage-form-submit' )-text() ) { + if ( $request-getVal( 'submit-button' ) !== null ) { $this-state = 'submit'; - } elseif ( $request-getText( 'preview-button' ) == $this-msg( 'massmessage-form-preview' )-text() ) { + } elseif ( $request-getVal( 'preview-button' ) !== null ) { $this-state = 'preview'; } else { $this-state = 'form'; @@ -58,7 +58,7 @@ $form = new HtmlForm( $this-createForm(), $context ); $form-setId( 'mw-massmessage-form' ); $form-setDisplayFormat( 'div' ); - if ( $this-state == 'form' ) { + if ( $this-state === 'form' ) { $form-addPreText( $this-msg( 'massmessage-form-header' )-parse() ); } $form-setWrapperLegendMsg( 'massmessage' ); @@ -69,13 +69,13 @@ $form-prepareForm(); $result = $form-tryAuthorizedSubmit(); if ( $result === true || ( $result instanceof Status $result-isGood() ) ) { - if ( $this-state == 'submit' ) { // If it's preview, everything is shown already. + if ( $this-state === 'submit' ) { // If it's preview, everything is shown already. $msg = $this-msg( 'massmessage-submitted' )-params( $this-count )-plain(); $output-addWikiText( $msg ); $output-addWikiMsg( 'massmessage-nextsteps' ); } } else { - if ( $this-state == 'preview' ) { + if ( $this-state === 'preview' ) { $result = $this-status; } $form-displayForm( $result ); @@ -140,7 +140,7 @@ 'default' = $request-getText( 'message' ) ); - if ( $this-state == 'preview' ) { + if ( $this-state === 'preview' ) { // Adds it right before the 'Send' button $m['message']['help'] = EditPage::getCopyrightWarning( $this-getPageTitle( false ), 'parse' ); $m['submit-button'] = array( @@ -183,7 +183,7 @@ return $this-status; } - if ( $this-state == 'submit' ) { + if ( $this-state === 'submit' ) { $this-count = MassMessage::submit( $this-getContext(), $data ); return $this-status; } else { // $this-state can only be 'preview' here -- To view, visit https://gerrit.wikimedia.org/r/142859 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ief4a334a1eef1fce382ebdf50011e04e4d7db702 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Change PF handling; include site in getTargets - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/142986 Change subject: Change PF handling; include site in getTargets .. Change PF handling; include site in getTargets * Simplify and rename verifyPFData * We don't need to check if URL is well-formed; if not it'd fail on getDBName * Always include the 'site' key in MassMessage::getTargets for consistent behaviour * Index databases by host:port if port is specified Change-Id: Ic0ce01bd6954db02e10d9674454297d80582f5ea --- M MassMessage.hooks.php M includes/MassMessage.php M includes/SpecialEditMassMessageList.php M tests/MassMessageTest.php 4 files changed, 40 insertions(+), 59 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/86/142986/1 diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index 3fd4f88..7bce78b 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -17,35 +17,30 @@ } /** -* Verifies the user submitted data to check it's valid +* Verify that parser function data is valid and return processed data as an array * @param string $page * @param string $site * @return array */ - public static function verifyPFData( $page, $site ) { - global $wgServer, $wgAllowGlobalMessaging; - $data = array( 'site' = $site, 'title' = $page ); - if ( trim( $site ) === '' ) { - $site = MassMessage::getBaseUrl( $wgServer ); - $data['site'] = $site; - $data['wiki'] = wfWikiID(); - } elseif ( filter_var( 'http://' . $site, FILTER_VALIDATE_URL ) === false ) { - // Try and see if the site provided is not valid - // We can just prefix http:// in front since it needs some kind of protocol - return MassMessage::parserError( 'massmessage-parse-badurl', $site ); - } - if ( is_null( Title::newFromText( $page ) ) ) { - // Check if the page provided is not valid + public static function processPFData( $page, $site ) { + global $wgAllowGlobalMessaging; + + if ( Title::newFromText( $page ) === null ) { return MassMessage::parserError( 'massmessage-parse-badpage', $page ); } - if ( !isset( $data['wiki'] ) ) { + + $data = array( 'title' = $page, 'site' = trim( $site ) ); + if ( $data['site'] === '' ) { + $data['site'] = MassMessage::getBaseUrl(); + $data['wiki'] = wfWikiID(); + } else { $data['wiki'] = MassMessage::getDBName( $data['site'] ); if ( $data['wiki'] === null ) { return MassMessage::parserError( 'massmessage-parse-badurl', $site ); } - } - if ( !$wgAllowGlobalMessaging $data['wiki'] != wfWikiID() ) { - return MassMessage::parserError( 'massmessage-global-disallowed' ); + if ( !$wgAllowGlobalMessaging $data['wiki'] != wfWikiID() ) { + return MassMessage::parserError( 'massmessage-global-disallowed' ); + } } return $data; } @@ -62,16 +57,15 @@ public static function outputParserFunction( Parser $parser, $page, $site = '' ) { global $wgScript; - $data = self::verifyPFData( $page, $site ); + $data = self::processPFData( $page, $site ); if ( isset( $data['error'] ) ) { return $data; } - $site = $data['site']; - $page = $data['title']; - // Use a message so wikis can customize the output - $msg = wfMessage( 'massmessage-target' )-params( $site, $wgScript, $page )-plain(); + $msg = wfMessage( 'massmessage-target' ) + -params( $data['site'], $wgScript, $data['title'] ) + -plain(); return array( $msg, 'noparse' = false ); } @@ -84,7 +78,7 @@ * @return string */ public static function storeDataParserFunction( Parser $parser, $page, $site = '' ) { - $data = self::verifyPFData( $page, $site ); + $data = self::processPFData( $page, $site ); if ( isset( $data['error'] ) ) { return ''; // Output doesn't matter } diff --git a/includes/MassMessage.php b/includes/MassMessage.php index e29c3ac..1c82346 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -68,17 +68,22 @@
[MediaWiki-commits] [Gerrit] Add ability to import pages when creating lists - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/142488 Change subject: Add ability to import pages when creating lists .. Add ability to import pages when creating lists Contains the following minor changes: * Simplify MassMessage::getCategoryTargets() * Bugfix wrt. error message on API errors Change-Id: Ic0d3d212bc51d8b5732d5371e41a2a9ad5749254 --- M MassMessage.php M i18n/en.json M i18n/qqq.json M includes/MassMessage.php M includes/SpecialCreateMassMessageList.php M includes/SpecialEditMassMessageList.php A modules/ext.MassMessage.create.js 7 files changed, 93 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/88/142488/1 diff --git a/MassMessage.php b/MassMessage.php index 1033937..6228d6e 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -127,6 +127,13 @@ 'localBasePath' = $dir . '/modules', 'remoteExtPath' = 'MassMessage/modules', ); +$wgResourceModules['ext.MassMessage.create'] = array( + 'scripts' = array( + 'ext.MassMessage.create.js', + ), + 'localBasePath' = $dir . '/modules', + 'remoteExtPath' = 'MassMessage/modules', +); // Logging $wgLogTypes[] = 'massmessage'; diff --git a/i18n/en.json b/i18n/en.json index 2d3a73a..c181306 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -59,6 +59,7 @@ massmessage-create-invalidtitle: The specified title is invalid., massmessage-create-exists: A page already exists at the specified title., massmessage-create-nopermission: You do not have permission to create a list at this title., + massmessage-create-invalidsource: The specified source is not a valid delivery list or category., massmessage-create-tojsonerror: The list could not be encoded for storage., massmessage-create-apierror: Creating the list through the API failed with errror code $1., editmassmessagelist-legend: Edit mass message delivery list, diff --git a/i18n/qqq.json b/i18n/qqq.json index 47b349a..4f4bedb 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -61,6 +61,7 @@ massmessage-create-exists: Error message shown on [[Special:CreateMassMessageList]] when a page with the title already exists, massmessage-create-nopermission: Error message shown on [[Special:CreateMassMessageList]] when the user cannot create a page with the title, massmessage-create-tojsonerror: Error message shown on [[Special:CreateMassMessageList]] when the input could not be successfully encoded, + massmessage-create-invalidsource: Error message shown on [[Special:CreateMassMessageList]] when the source from which to import targets is invalid, massmessage-create-apierror: Error message shown on [[Special:CreateMassMessageList]] when the API request to create the page failed, editmassmessagelist-legend: Form legend for [[Special:EditMassMessageList]], massmessage-edit-title: Label for an inputbox on [[Special:EditMassMessageList]], diff --git a/includes/MassMessage.php b/includes/MassMessage.php index 8bcbbe6..763fe23 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -151,16 +151,15 @@ * @return array */ public static function getCategoryTargets( Title $spamlist ) { - $cat = Category::newFromTitle( $spamlist ); - $members = $cat-getMembers(); + $members = Category::newFromTitle( $spamlist )-getMembers(); $targets = array(); /** @var Title $member */ foreach ( $members as $member ) { - $target = array(); - $target['title'] = $member-getPrefixedText(); - $target['wiki'] = wfWikiID(); - $targets[] = $target; + $targets[] = array( + 'title' = $member-getPrefixedText(), + 'wiki' = wfWikiID(), + ); } return self::normalizeTargets( $targets ); diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index 0d7b48e..d502a7b 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -7,6 +7,15 @@ } /** +* Add ResourceLoader module and call parent implementation. +* @param string $par +*/ + public function execute( $par ) { + $this-getOutput()-addModules( 'ext.MassMessage.create' ); + parent::execute( $par ); + } + + /** * @return array */ protected function getFormFields() { @@ -28,7 +37,6 @@ ), 'source' = array( 'type' = 'text', -
[MediaWiki-commits] [Gerrit] Make site handling more consistent - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/142498 Change subject: Make site handling more consistent .. Make site handling more consistent Never store the site for local pages, instead having Special:EditMassMessageList decide whether to add it on output. Change-Id: I04c6ab7281ba9238934181b19c3bcb2b42b2d524 --- M includes/SpecialEditMassMessageList.php 1 file changed, 8 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/98/142498/1 diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 877ef8f..1d28014 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -152,10 +152,14 @@ * @return string */ protected static function parseTargets( $targets ) { + global $wgServerName; + $lines = array(); foreach ( $targets as $target ) { if ( array_key_exists( 'site', $target ) ) { $lines[] = $target['title'] . '@' . $target['site']; + } elseif ( strpos( $target['title'], '@' ) !== false ) { + $lines[] = $target['title'] . '@' . $wgServerName; // List site where ambiguous. } else { $lines[] = $target['title']; } @@ -169,7 +173,7 @@ * @return array|null */ protected static function parseInput( $input ) { - global $wgAllowGlobalMessaging; + global $wgServerName, $wgAllowGlobalMessaging; $lines = array_filter( explode( \n, $input ), 'trim' ); // Array of non-empty lines @@ -179,6 +183,9 @@ if ( $delimiterPos !== false ) { $titleText = substr( $line, 0, $delimiterPos ); $site = strtolower( substr( $line, $delimiterPos+1 ) ); + if ( $site === $wgServerName ) { + $site = null; // Don't store site for local pages. + } } else { $titleText = $line; $site = null; -- To view, visit https://gerrit.wikimedia.org/r/142498 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I04c6ab7281ba9238934181b19c3bcb2b42b2d524 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Use Html class for generating displayed list - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/142202 Change subject: Use Html class for generating displayed list .. Use Html class for generating displayed list Change-Id: I853f4207db18d02b0603c3b283e3e66409d93f1d --- M includes/content/MassMessageListContent.php 1 file changed, 14 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/02/142202/1 diff --git a/includes/content/MassMessageListContent.php b/includes/content/MassMessageListContent.php index d37b87f..e17865e 100644 --- a/includes/content/MassMessageListContent.php +++ b/includes/content/MassMessageListContent.php @@ -132,13 +132,15 @@ protected function getTargetsHtml() { global $wgScript; - $html = 'h2' . wfMessage( 'massmessage-content-pages' )-parse() . /h2\n; + $html = Html::rawElement( 'h2', array(), + wfMessage( 'massmessage-content-pages' )-parse() ); $sites = $this-getTargetsBySite(); // If the list is empty if ( count( $sites ) === 0 ) { - $html .= 'p' . wfMessage( 'massmessage-content-empty' )-parse() . /p\n; + $html .= Html::rawElement( 'p', array(), + wfMessage( 'massmessage-content-empty' )-parse() ); return $html; } @@ -149,28 +151,27 @@ foreach ( $sites as $site = $targets ) { if ( $printSites ) { if ( $site === 'local' ) { - $html .= 'p' . wfMessage( 'massmessage-content-localpages' )-parse() - . /p\n; + $html .= Html::rawElement( 'p', array(), + wfMessage( 'massmessage-content-localpages' )-parse() ); } else { - $html .= 'p' - . wfMessage( 'massmessage-content-pagesonsite', $site )-parse() - . /p\n; + $html .= Html::rawElement( 'p', array(), + wfMessage( 'massmessage-content-pagesonsite', $site )-parse() ); } } - $html .= ul\n; + $html .= Html::openElement( 'ul' ); foreach ( $targets as $target ) { if ( $site === 'local' ) { - $html .= 'li' . Linker::link( Title::newFromText( $target ) ) . /li\n; + $html .= Html::rawElement( 'li', array(), + Linker::link( Title::newFromText( $target ) ) ); } else { $title = Title::newFromText( $target ); $url = //$site$wgScript?title= . $title-getPrefixedURL(); - $html .= 'li' - . Linker::makeExternalLink( $url, $title-getPrefixedText() ) - . /li\n; + $html .= Html::rawElement( 'li', array(), + Linker::makeExternalLink( $url, $title-getPrefixedText() ) ); } } - $html .= /ul\n; + $html .= Html::closeElement( 'ul' ); } return $html; -- To view, visit https://gerrit.wikimedia.org/r/142202 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I853f4207db18d02b0603c3b283e3e66409d93f1d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MassMessage Gerrit-Branch: contenthandler Gerrit-Owner: Wctaiwan wctai...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Error for invalid targets when editing spamlist - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/141911 Change subject: Error for invalid targets when editing spamlist .. Error for invalid targets when editing spamlist This shows a simple error message for invalid targets, instead of silently ignoring them as before. I considered using a Status object to show details (which targets are invalid, invalid title or wiki), but that isn't practical until we move away from FormSpecialPage. Followup to Ibddb6e2cf547e5d158eba45df0c3ed0c6f56bf42 Change-Id: I3c29391c4fe3f21c92c61f61fc545a260b43a9b8 --- M i18n/en.json M i18n/qqq.json M includes/SpecialEditMassMessageList.php 3 files changed, 25 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/11/141911/1 diff --git a/i18n/en.json b/i18n/en.json index edda76d..5f8b6c9 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -67,6 +67,7 @@ massmessage-edit-header: List one title per line, and use title@domain (e.g. User talk:exam...@en.wikipedia.org) to specify a page on a different wiki, if cross-wiki delivery is enabled., massmessage-edit-editsummary: Updating mass message delivery list, massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., + massmessage-edit-invalidtargets: One of more of the entries in the list are invalid., massmessage-edit-nopermission: You do not have permission to edit the list., massmessage-edit-tojsonerror: The list could not be encoded for storage. } \ No newline at end of file diff --git a/i18n/qqq.json b/i18n/qqq.json index 558b656..22a8ef0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -68,6 +68,7 @@ massmessage-edit-header: Instructions for [[Special:EditMassMessageList]], massmessage-edit-editsummary: Edit summary for editing a delivery list, massmessage-edit-invalidtitle: Error message shown on [[Special:EditMassMessageList]] when the title is invalid, + massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid, massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list, massmessage-edit-tojsonerror: Error message shown on [[Special:EditMassMessageList]] when the input could not be successfully encoded } diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 4876857..f70b7a6 100644 --- a/includes/SpecialEditMassMessageList.php +++ b/includes/SpecialEditMassMessageList.php @@ -106,10 +106,18 @@ return Status::newFatal( 'massmessage-edit-invalidtitle' ); } - $jsonText = self::convertToJson( $data['description'], $data['content'] ); - if ( !$jsonText ) { + $targets = self::parseInput( $data['content'] ); + if ( $targets === null ) { + return Status::newFatal( 'massmessage-edit-invalidtargets' ); + } + + $jsonText = FormatJson::encode( + array( 'description' = $data['description'], 'targets' = $targets ) + ); + if ( $jsonText === null ) { return Status::newFatal( 'massmessage-edit-tojsonerror' ); } + try { $content = ContentHandler::makeContent( $jsonText, $this-title, 'MassMessageListContent' ); @@ -149,13 +157,14 @@ } /** -* Parse user input and convert it to JSON format. -* @param string $description -* @param string $targetsText -* @return string +* Parse user input into targets array. Returns null if input contains invalid data. +* @param string $input +* @return array|null */ - protected static function convertToJson( $description, $targetsText ) { - $lines = array_filter( explode( \n, $targetsText ), 'trim' ); // Array of non-empty lines + protected static function parseInput( $input ) { + global $wgAllowGlobalMessaging; + + $lines = array_filter( explode( \n, $input ), 'trim' ); // Array of non-empty lines $targets = array(); foreach ( $lines as $line ) { @@ -170,13 +179,14 @@ $title = Title::newFromText( $titleText ); if ( !$title ) { - continue; // Silently skip invalid titles. + return null; } $titleText = $title-getPrefixedText(); // Use the canonical form. if ( $site ) { - if (
[MediaWiki-commits] [Gerrit] Call API internally for list creation and editing - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/142023 Change subject: Call API internally for list creation and editing .. Call API internally for list creation and editing Change-Id: I977ed5d9997c2f7c5e2461b73dba421d81c548e1 --- M i18n/en.json M i18n/qqq.json M includes/SpecialCreateMassMessageList.php M includes/SpecialEditMassMessageList.php 4 files changed, 43 insertions(+), 26 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/23/142023/1 diff --git a/i18n/en.json b/i18n/en.json index 5f8b6c9..e4c505c 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -60,6 +60,7 @@ massmessage-create-exists: A page already exists at the specified title., massmessage-create-nopermission: You do not have permission to create a list at this title., massmessage-create-tojsonerror: The list could not be encoded for storage., + massmessage-create-apierror: The list could not be created., editmassmessagelist-legend: Edit mass message delivery list, massmessage-edit-title: Title:, massmessage-edit-description: Description:, @@ -69,5 +70,6 @@ massmessage-edit-invalidtitle: There is no valid mass message delivery list at the title., massmessage-edit-invalidtargets: One of more of the entries in the list are invalid., massmessage-edit-nopermission: You do not have permission to edit the list., - massmessage-edit-tojsonerror: The list could not be encoded for storage. + massmessage-edit-tojsonerror: The list could not be encoded for storage., + massmessage-edit-apierror: Your changes could not be saved. } \ No newline at end of file diff --git a/i18n/qqq.json b/i18n/qqq.json index 22a8ef0..47b349a 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -61,6 +61,7 @@ massmessage-create-exists: Error message shown on [[Special:CreateMassMessageList]] when a page with the title already exists, massmessage-create-nopermission: Error message shown on [[Special:CreateMassMessageList]] when the user cannot create a page with the title, massmessage-create-tojsonerror: Error message shown on [[Special:CreateMassMessageList]] when the input could not be successfully encoded, + massmessage-create-apierror: Error message shown on [[Special:CreateMassMessageList]] when the API request to create the page failed, editmassmessagelist-legend: Form legend for [[Special:EditMassMessageList]], massmessage-edit-title: Label for an inputbox on [[Special:EditMassMessageList]], massmessage-edit-description: Label for a textarea on [[Special:EditMassMessageList]], @@ -70,5 +71,6 @@ massmessage-edit-invalidtitle: Error message shown on [[Special:EditMassMessageList]] when the title is invalid, massmessage-edit-invalidtargets: Error message shown on [[Special:EditMassMessageList]] when one ore more targets are invalid, massmessage-edit-nopermission: Error message shown on [[Special:EditMassMessageList]] when the user cannot edit the list, - massmessage-edit-tojsonerror: Error message shown on [[Special:EditMassMessageList]] when the input could not be successfully encoded + massmessage-edit-tojsonerror: Error message shown on [[Special:EditMassMessageList]] when the input could not be successfully encoded, + massmessage-edit-apierror: Error message shown on [[Special:EditMassMessageList]] when the API request to create the page failed } diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index b109f88..ada286d 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -57,27 +57,34 @@ $targets = array(); } - $jsonText = FormatJson::encode( array( 'description' = $data['description'], 'targets' = $targets ) ); if ( !$jsonText ) { return Status::newFatal( 'massmessage-create-tojsonerror' ); } + + $request = new DerivativeRequest( + $this-getRequest(), + array( + 'action' = 'edit', + 'title' = $title-getFullText(), + 'contentmodel' = 'MassMessageListContent', + 'text' = $jsonText, + 'summary' = $this-msg( 'massmessage-create-editsummary' )-plain(), + 'token' = $this-getUser()-getEditToken(), + ), + true // Treat data as POSTed + ); + try { - $content = ContentHandler::makeContent( $jsonText, $title,
[MediaWiki-commits] [Gerrit] [WIP] Various improvements - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/141283 Change subject: [WIP] Various improvements .. [WIP] Various improvements * Separate errors for nonexistent and invalid pages * Add checks for external targets where forbidden in validation * Improve target construction * Other minor changes Change-Id: Ie9a9497b874707e0484e6533f1a683c7abe19c35 TODO: Improve validation in SpecialEditMassMessageList --- M i18n/en.json M i18n/qqq.json M includes/MassMessage.php M includes/content/MassMessageListContent.php M includes/content/MassMessageListContentHandler.php 5 files changed, 26 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/83/141283/1 diff --git a/i18n/en.json b/i18n/en.json index 028ac36..edda76d 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -17,7 +17,8 @@ massmessage-fieldset-preview: Preview, massmessage-submitted: Your message delivery to {{PLURAL:$1|$1 page|$1 pages}} has been queued., massmessage-just-preview: This is just a preview. Press \{{int:massmessage-form-submit}}\ to send the message., - massmessage-spamlist-doesnotexist: The specified page-list page does not exist., + massmessage-spamlist-doesnotexist: The specified delivery list page or category does not exist., + massmessage-spamlist-invalid: The specified page does not contain a valid delivery list., massmessage-empty-subject: The subject line is empty., massmessage-empty-message: The message body is empty., massmessage-unescaped-langlinks: Warning: There are unescaped language links in your message., diff --git a/i18n/qqq.json b/i18n/qqq.json index 920b81e..558b656 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -18,7 +18,8 @@ massmessage-fieldset-preview: Label for the fieldset box around the page preview.\n{{Identical|Preview}}, massmessage-submitted: Confirmation message the user sees after the form is submitted successfully and the request is queued in the job queue.\n\nParameters:\n* $1 - the number of deliveries that have been queued, massmessage-just-preview: Warning to user that what they are seeing is just a preview, and they should hit the send button to actually submit it.\n\nRefers to {{msg-mw|Massmessage-form-submit}}., - massmessage-spamlist-doesnotexist: Error message the user sees if an invalid spamlist is provided.\n\nThe spamlist is the page containing list of pages to leave a message on.\n\nThis message probably means that said page, as provided by the user, does not exist., + massmessage-spamlist-doesnotexist: Error message the user sees if the delivery list page or category they entered does not exist., + massmessage-spamlist-invalid: Error message the user sees if the delivery list page they entered is invalid., massmessage-empty-subject: Error message the user sees if the \subject\ field is empty., massmessage-empty-message: Error message the user sees if the \message\ field is empty., massmessage-unescaped-langlinks: Warning shown to user when previewing if their message text has unescaped language links., diff --git a/includes/MassMessage.php b/includes/MassMessage.php index 717934a..de78f73 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -185,10 +185,15 @@ * @return array */ public static function getMassMessageListContentTargets ( Title $spamlist ) { + global $wgServer; + $targets = Revision::newFromTitle( $spamlist )-getContent()-getTargets(); - foreach ( $targets as $index = $target ) { + foreach ( $targets as $target ) { if ( !array_key_exists( 'site', $target ) ) { + $target['site'] = MassMessage::getBaseUrl( $wgServer ); $target['wiki'] = wfWikiID(); + } else { + $target['wiki'] = MassMessage::getDBName( $target['site'] ); } } return self::normalizeTargets( $targets ); @@ -291,7 +296,7 @@ wfWikiID(), $url ); - } else { + } else { // $spamlist contains a message key for an error message $status-fatal( $spamlist ); } @@ -326,17 +331,20 @@ // Page exists, follow a redirect if possible $target = MassMessage::followRedirect( $spamlist ); if ( $target === null || !$target-exists() ) { - return 'massmessage-spamlist-doesnotexist'; // Interwiki redirect or non-existent page. + return
[MediaWiki-commits] [Gerrit] [WIP] Various fixes - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/140691 Change subject: [WIP] Various fixes .. [WIP] Various fixes * Change edit summaries to use -plain() * Improved validation * Use ContentHandler for creating content objects Change-Id: Ibddb6e2cf547e5d158eba45df0c3ed0c6f56bf42 --- M includes/MassMessage.php M includes/SpecialCreateMassMessageList.php M includes/SpecialEditMassMessageList.php M includes/content/MassMessageListContent.php M includes/content/MassMessageListContentHandler.php 5 files changed, 45 insertions(+), 34 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/91/140691/1 diff --git a/includes/MassMessage.php b/includes/MassMessage.php index e33c87c..e1c5240 100644 --- a/includes/MassMessage.php +++ b/includes/MassMessage.php @@ -90,29 +90,38 @@ * @return string */ public static function getDBName( $host ) { - global $wgConf, $wgMemc; - static $mapping = null; - if ( $mapping === null ) { - // Don't use wfMemcKey since it splits cache per wiki - $key = 'massmessage:urltodb'; - $data = $wgMemc-get( $key ); - if ( $data === false ) { - $dbs = $wgConf-getLocalDatabases(); - $mapping = array(); - foreach ( $dbs as $dbname ) { - $url = WikiMap::getWiki( $dbname )-getCanonicalServer(); - $parse = wfParseUrl( $url ); - $mapping[$parse['host']] = $dbname; + // Temporarily replaced with dummy code testing on a single-wiki setup + // TODO: Restore before merging into master. + /** + global $wgConf, $wgMemc; + static $mapping = null; + if ( $mapping === null ) { + // Don't use wfMemcKey since it splits cache per wiki + $key = 'massmessage:urltodb'; + $data = $wgMemc-get( $key ); + if ( $data === false ) { + $dbs = $wgConf-getLocalDatabases(); + $mapping = array(); + foreach ( $dbs as $dbname ) { + $url = WikiMap::getWiki( $dbname )-getCanonicalServer(); + $parse = wfParseUrl( $url ); + $mapping[$parse['host']] = $dbname; + } + $wgMemc-set( $key, $mapping, 60 * 60 * 24 * 7 ); + } else { + $mapping = $data; } - $wgMemc-set( $key, $mapping, 60 * 60 * 24 * 7 ); - } else { - $mapping = $data; } + if ( isset( $mapping[$host] ) ) { + return $mapping[$host]; + } + return null; // Couldn't find anything + */ + if ( $host === 'en.wikipedia.org' ) { + return array(); + } else { + return null; } - if ( isset( $mapping[$host] ) ) { - return $mapping[$host]; - } - return null; // Couldn't find anything } /** diff --git a/includes/SpecialCreateMassMessageList.php b/includes/SpecialCreateMassMessageList.php index 76f26a2..1dcd5f6 100644 --- a/includes/SpecialCreateMassMessageList.php +++ b/includes/SpecialCreateMassMessageList.php @@ -64,11 +64,11 @@ if ( !$jsonText ) { return Status::newFatal( 'massmessage-create-tojsonerror' ); } - $content = new MassMessageListContent( $jsonText ); + $content = ContentHandler::makeContent( $jsonText, $title, 'MassMessageListContent' ); $result = WikiPage::factory( $title )-doEditContent( $content, - $this-msg( 'massmessage-create-editsummary' )-escaped() + $this-msg( 'massmessage-create-editsummary' )-plain() ); if ( $result-isOK() ) { $this-getOutput()-redirect( $title-getFullUrl() ); diff --git a/includes/SpecialEditMassMessageList.php b/includes/SpecialEditMassMessageList.php index 76cfc75..2e21d9b 100644 ---
[MediaWiki-commits] [Gerrit] Merge MassMessageBackend - change (mediawiki...MassMessage)
Wctaiwan has uploaded a new change for review. https://gerrit.wikimedia.org/r/140106 Change subject: Merge MassMessageBackend .. Merge MassMessageBackend Change-Id: I98bd684ed1637de8f25e465ce1ffd24ca2171540 --- M .gitreview M MassMessage.hooks.php M MassMessage.php M i18n/en.json A includes/SpecialCreateMassMessageList.php A includes/SpecialEditMassMessageList.php A includes/content/MassMessageListContent.php A includes/content/MassMessageListContentHandler.php 8 files changed, 602 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassMessage refs/changes/06/140106/1 diff --git a/.gitreview b/.gitreview index 6f1d181..f83ca08 100644 --- a/.gitreview +++ b/.gitreview @@ -2,5 +2,5 @@ host=gerrit.wikimedia.org port=29418 project=mediawiki/extensions/MassMessage.git -defaultbranch=master +defaultbranch=contenthandler defaultrebase=0 \ No newline at end of file diff --git a/MassMessage.hooks.php b/MassMessage.hooks.php index 5be2ba8..03fdefe 100644 --- a/MassMessage.hooks.php +++ b/MassMessage.hooks.php @@ -156,7 +156,6 @@ /** * Echo! -* * @param $event EchoEvent * @return bool */ @@ -170,4 +169,21 @@ return true; } + /** +* Override the Edit tab for delivery lists +* @param SkinTemplate $sktemplaye +* @param array $links +* @return bool +*/ + public static function onSkinTemplateNavigation( $sktemplate, $links ) { + $title = $sktemplate-getTitle(); + if ( $title-hasContentModel( 'MassMessageListContent' ) +array_key_exists( 'edit', $links['views'] ) + ) { + $links['views']['edit']['href'] = SpecialPage::getTitleFor( + 'EditMassMessageList', $title + )-getFullUrl(); + } + return true; + } } diff --git a/MassMessage.php b/MassMessage.php index ca6c0c9..b96c7c4 100644 --- a/MassMessage.php +++ b/MassMessage.php @@ -55,33 +55,44 @@ $wgExtensionCredits['specialpage'][] = array( 'path' = __FILE__, 'name' = 'MassMessage', - 'author' = 'Kunal Mehta', + 'author' = array( 'Kunal Mehta', 'wctaiwan' ), 'url' = 'https://www.mediawiki.org/wiki/Extension:MassMessage', 'descriptionmsg' = 'massmessage-desc', - 'version' = '0.1.0', + 'version' = '0.2.0', ); $dir = __DIR__; -$wgSpecialPages['MassMessage'] = 'SpecialMassMessage'; -$wgMessagesDirs['MassMessage'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['MassMessage'] = $dir/MassMessage.i18n.php; +// Messages +$wgMessagesDirs['MassMessage'] = $dir/i18n; $wgExtensionMessagesFiles['MassMessageAlias'] = $dir/MassMessage.alias.php; $wgExtensionMessagesFiles['MassMessageMagic'] = $dir/MassMessage.i18n.magic.php; + +// Classes $wgAutoloadClasses['MassMessageHooks'] = $dir/MassMessage.hooks.php; $wgAutoloadClasses['ApiMassMessage'] = $dir/includes/ApiMassMessage.php; $wgAutoloadClasses['MassMessage'] = $dir/includes/MassMessage.php; $wgAutoloadClasses['SpecialMassMessage'] = $dir/includes/SpecialMassMessage.php; +$wgAutoloadClasses['SpecialCreateMassMessageList'] = $dir/includes/SpecialCreateMassMessageList.php; +$wgAutoloadClasses['SpecialEditMassMessageList'] = $dir/includes/SpecialEditMassMessageList.php; $wgAutoloadClasses['MassMessageJob'] = $dir/includes/job/MassMessageJob.php; $wgAutoloadClasses['MassMessageSubmitJob'] = $dir/includes/job/MassMessageSubmitJob.php; $wgAutoloadClasses['MassMessageFailureLogFormatter'] = $dir/includes/logging/MassMessageFailureLogFormatter.php; $wgAutoloadClasses['MassMessageSendLogFormatter'] = $dir/includes/logging/MassMessageSendLogFormatter.php; $wgAutoloadClasses['MassMessageSkipLogFormatter'] = $dir/includes/logging/MassMessageSkipLogFormatter.php; +$wgAutoloadClasses['MassMessageListContent'] = $dir/includes/content/MassMessageListContent.php; +$wgAutoloadClasses['MassMessageListContentHandler'] = $dir/includes/content/MassMessageListContentHandler.php; +// ContentHandler +$wgContentHandlers['MassMessageListContent'] = 'MassMessageListContentHandler'; + +// API modules $wgAPIModules['massmessage'] = 'ApiMassMessage'; +// Job classes $wgJobClasses['MassMessageJob'] = 'MassMessageJob'; $wgJobClasses['MassMessageSubmitJob'] = 'MassMessageSubmitJob'; +// Hooks $wgHooks['ParserFirstCallInit'][] = 'MassMessageHooks::onParserFirstCallInit'; $wgHooks['SpecialStatsAddExtra'][] = 'MassMessageHooks::onSpecialStatsAddExtra'; $wgHooks['APIQuerySiteInfoStatisticsInfo'][] = 'MassMessageHooks::onAPIQuerySiteInfoStatisticsInfo'; @@ -89,7 +100,14 @@ $wgHooks['UserGetReservedNames'][] = 'MassMessageHooks::onUserGetReservedNames'; $wgHooks['UnitTestsList'][] = 'MassMessageHooks::onUnitTestsList';