Mattflaschen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/193554
Change subject: Block the user from the using the action=delete interface for
topics.
......................................................................
Block the user from the using the action=delete interface for topics.
This is not shown in the UI, so it is only accessible by URL-hacking.
This interface has essentially no effect currently. It is deleted as far
as core knows, but it is still fully accessible with the normal URL.
We should probably have this feed into the Flow deletion mechanism
somehow, but in the meantime this avoids confusing users.
Bug: T91150
Change-Id: Ibad375beaae62257bc98c53a6c826605853904fd
---
M Flow.php
M Hooks.php
M i18n/en.json
M i18n/qqq.json
4 files changed, 48 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/54/193554/1
diff --git a/Flow.php b/Flow.php
index ecaecee..ccc39fa 100644
--- a/Flow.php
+++ b/Flow.php
@@ -96,6 +96,8 @@
$wgHooks['NamespaceIsMovable'][] = 'FlowHooks::onNamespaceIsMovable';
$wgHooks['CategoryViewer::doCategoryQuery'][] =
'FlowHooks::onCategoryViewerDoCategoryQuery';
$wgHooks['CategoryViewer::generateLink'][] =
'FlowHooks::onCategoryViewerGenerateLink';
+$wgHooks['ArticleConfirmDelete'][] = 'FlowHooks::onArticleConfirmDelete';
+$wgHooks['ArticleDelete'][] = 'FlowHooks::onArticleDelete';
// Extension:UserMerge support
$wgHooks['UserMergeAccountFields'][] = 'FlowHooks::onUserMergeAccountFields';
diff --git a/Hooks.php b/Hooks.php
index 3a853c6..1b8c3f1 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -1181,4 +1181,48 @@
return true;
}
+
+ // This should block them from wasting their time filling the form, but
it won't
+ // without a core change. However, it does show the message.
+ /**
+ * Blocks the user from visiting the deletion form if the page is in
the Topic
+ * namespace
+ *
+ * @param WikiPage $article Page the user requested to delete
+ * @param OutputPage $out Output page
+ * @param string &$reason Pre-filled reason given for deletion (note,
this could
+ * be used to customize this for boards and/or topics later)
+ * @return bool False if it is a Topic; otherwise, true
+ */
+ public static function onArticleConfirmDelete( $article, $output,
&$reason ) {
+ $title = $article->getTitle();
+ if ( $title->inNamespace( NS_TOPIC ) ) {
+ $error = wfMessage( 'flow-error-core-topic-deletion',
$title->getFullURL() )->parse();
+ $output->addHTML( $error );
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Blocks topics from being deleted using the core deletion process,
since it
+ * doesn't work (this hook only fires if they hack the form submission,
since the
+ * above should block them from visiting the form).
+ *
+ * @param WikiPage &$article Page the user requested to delete
+ * @param User &$user User who requested to delete the article
+ * @param string &$reason Reason given for deletion
+ * @param string &$error Error explaining why we are not allowing the
deletion
+ * @return bool False if it is a Topic (to block it); otherwise, true
+ */
+ public static function onArticleDelete( WikiPage &$article, User
&$user, &$reason, &$error ) {
+ $title = $article->getTitle();
+ if ( $title->inNamespace( NS_TOPIC ) ) {
+ $error = wfMessage( 'flow-error-core-topic-deletion',
$title->getFullURL() )->parse();
+ return false;
+ }
+
+ return true;
+ }
}
diff --git a/i18n/en.json b/i18n/en.json
index 5efbd21..1bb24b3 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -148,6 +148,7 @@
"flow-error-missing-prev-revision-identifier": "Previous revision
identifier is missing.",
"flow-error-prev-revision-mismatch": "Another user just edited this
post a few seconds ago. Are {{GENDER:$3|you}} sure you want to overwrite the
recent change?",
"flow-error-prev-revision-does-not-exist": "Could not find the previous
revision.",
+ "flow-error-core-topic-deletion": "To delete a topic, use the ... menu
on the Flow board or [$1 topic page]. Do not visit action=delete for the topic
directly.",
"flow-error-default": "An error has occurred.",
"flow-error-invalid-input": "Invalid value was provided for loading
Flow content.",
"flow-error-invalid-title": "Invalid page title was provided.",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 610b2e9..7bacd18 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -153,6 +153,7 @@
"flow-error-missing-prev-revision-identifier": "Error message when the
identifier for the previous header revision is missing.",
"flow-error-prev-revision-mismatch": "Error message when the provided
previous revision identifier does not match the last stored revision.",
"flow-error-prev-revision-does-not-exist": "Error message when the
provided previous revision identifier could not be found.",
+ "flow-error-core-topic-deletion": "Error message when the user tries to
use core's deletion mechanism for a Topic (this is not exposed in the UI, and
should not be used currently). Parameters:\n* $1 - Full URL of topic page.",
"flow-error-default": "General error message for flow.",
"flow-error-invalid-input": "Error message when invalid input is
provided.",
"flow-error-invalid-title": "Error message when invalid title is
provided.",
--
To view, visit https://gerrit.wikimedia.org/r/193554
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibad375beaae62257bc98c53a6c826605853904fd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mattflaschen <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits