Werdna has uploaded a new change for review. https://gerrit.wikimedia.org/r/134997
Change subject: Use dummy user to make taking-over revision ...................................................................... Use dummy user to make taking-over revision Instead of using the user viewing the page, use a dummy username to add the revision made when a page is taken over by flow. Bug: 64344 Change-Id: I923623881431011aff6d3a3f01c2da56017e79de --- M Hooks.php M i18n/en.json M i18n/qqq.json M includes/TalkpageManager.php 4 files changed, 24 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow refs/changes/97/134997/1 diff --git a/Hooks.php b/Hooks.php index 5d8f1ad..e3b41b3 100644 --- a/Hooks.php +++ b/Hooks.php @@ -393,7 +393,8 @@ /** * Make sure no user can register a flow-*-usertext username, to avoid * confusion with a real user when we print e.g. "Suppressed" instead of a - * username. + * username. Additionally reserve the username used to add a revision on + * taking over a page. * * @param array $names * @return bool @@ -403,8 +404,12 @@ foreach ( $permissions as $permission ) { $names[] = "msg:flow-$permission-usertext"; } + $names[] = 'msg:flow-system-usertext'; - $names[] = "msg:flow-system-usertext"; + // Reserve both the localized username and the English fallback for the + // taking-over revision. + $names[] = 'msg:flow-talk-username'; + $names[] = 'Flow talk page manager'; return true; } diff --git a/i18n/en.json b/i18n/en.json index 5bb5c16..b4c2204 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -11,6 +11,7 @@ }, "flow-desc": "Workflow management system", "flow-talk-taken-over": "This talk page has been taken over by a [https://www.mediawiki.org/wiki/Special:MyLanguage/Flow_Portal Flow board].", + "flow-talk-username": "Flow talk page manager", "log-name-flow": "Flow activity log", "logentry-delete-flow-delete-post": "$1 {{GENDER:$2|deleted}} a [$4 post] on [[$3]]", "logentry-delete-flow-restore-post": "$1 {{GENDER:$2|restored}} a [$4 post] on [[$3]]", diff --git a/i18n/qqq.json b/i18n/qqq.json index 6dc71b6..c980d6c 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -13,6 +13,7 @@ }, "flow-desc": "{{desc|name=Flow|url=http://www.mediawiki.org/wiki/Extension:Flow}}", "flow-talk-taken-over": "Content to replace existing page content by for pages that are turned into Flow boards.", + "flow-talk-username": "Username used for the revision added when Flow takes over a talk page.", "log-name-flow": "{{doc-logpage}}\nName of the Flow log filter on the [[Special:Log]] page.", "logentry-delete-flow-delete-post": "Text for a deletion log entry when a post was deleted. Parameters:\n* $1 - the user: link to the user page\n* $2 - the username. Can be used for GENDER.\n* $3 - the page where the post was moderated\n* $4 - permalink URL to the moderated post\n{{Related|Flow-logentry}}", "logentry-delete-flow-restore-post": "Text for a deletion log entry when a deleted post was restored. Parameters:\n* $1 - the user: link to the user page\n* $2 - the username. Can be used for GENDER.\n* $3 - the page where the post was moderated\n* $4 - permalink URL to the moderated post\n{{Related|Flow-logentry}}", diff --git a/includes/TalkpageManager.php b/includes/TalkpageManager.php index d3b0ed6..62424b4 100644 --- a/includes/TalkpageManager.php +++ b/includes/TalkpageManager.php @@ -7,6 +7,7 @@ use ContentHandler; use Revision; use Title; +use User; // I got the feeling NinetyNinePercentController was a bit much. interface OccupationController { @@ -64,17 +65,29 @@ throw new InvalidInputException( 'Requested article is not Flow enabled', 'invalid-input' ); } - // comment to add to the Revision to indicate Flow taking over + // Comment to add to the Revision to indicate Flow taking over $comment = '/* Taken over by Flow */'; $page = $article->getPage(); $revision = $page->getRevision(); - // make sure a Flow revision has not yet been inserted + // Add a revision only if a Flow revision has not yet been inserted. if ( $revision === null || $revision->getComment( Revision::RAW ) != $comment ) { $message = wfMessage( 'flow-talk-taken-over' )->inContentLanguage()->text(); $content = ContentHandler::makeContent( $message, $title ); $page->doEditContent( $content, $comment, EDIT_FORCE_BOT | EDIT_SUPPRESS_RC ); + + $user = User::newFromName( + wfMessage( 'flow-talk-username' )->inContentLanguage()->text() + ); + // Use the English fallback if the localized username is invalid or if a user + // with the name exists. + if ( $user === false || $user->getId() !== 0 ) { + $user = User::newFromName( 'Flow talk page manager', false ); + } + + $page->doEditContent( $content, $comment, EDIT_FORCE_BOT | EDIT_SUPPRESS_RC, + false, $user ); } } } -- To view, visit https://gerrit.wikimedia.org/r/134997 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I923623881431011aff6d3a3f01c2da56017e79de Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Flow Gerrit-Branch: frontend-rewrite Gerrit-Owner: Werdna <agarr...@wikimedia.org> Gerrit-Reviewer: Wctaiwan <wctai...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits