Matthias Mullie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/217274
Change subject: Make sure Topic:xyz pages exist() as soon as the topic is
created
......................................................................
Make sure Topic:xyz pages exist() as soon as the topic is created
We delay the creation of the Topic:xyz page because it's not critical
to that process. However, Echo seems to send emails with a link for
which it ends up using Linker::link, which checks if the page exists.
If a page doesn't exist, it alters the url, adding
&action=edit&redlink=1
We want to make sure that topics for which a page has not yet been
created are recognized as existing should anything ever request it
before it exists for real.
Bug: T96162
Change-Id: Iaf87665019208653685a8063cd43cc013a70f3d2
---
M Flow.php
M Hooks.php
2 files changed, 40 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/74/217274/1
diff --git a/Flow.php b/Flow.php
index 0258a38..39d6cef 100644
--- a/Flow.php
+++ b/Flow.php
@@ -146,6 +146,7 @@
$wgHooks['ArticleConfirmDelete'][] = 'FlowHooks::onArticleConfirmDelete';
$wgHooks['ArticleDelete'][] = 'FlowHooks::onArticleDelete';
$wgHooks['ArticleUndelete'][] = 'FlowHooks::onArticleUndelete';
+$wgHooks['TitleExists'][] = 'FlowHooks::onTitleExists';
// Extension:UserMerge support
$wgHooks['UserMergeAccountFields'][] = 'FlowHooks::onUserMergeAccountFields';
diff --git a/Hooks.php b/Hooks.php
index 5fbe29a..e43e096 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -1456,4 +1456,43 @@
return true;
}
+
+ /**
+ * NS_TOPIC titles are created slightly after the topic has been stored,
+ * in a listener.
+ * Other things could try to figure out if that given title exists in
the
+ * meantime (e.g. Echo, when sending an email about the new topic), even
+ * before we have created it.
+ * This will make sure that Topic:xyz titles that exist but have yet to
+ * be created are already recognized as pages that exist.
+ *
+ * @param Title $title
+ * @param bool $exists
+ * @return bool
+ */
+ public static function onTitleExists( Title $title, &$exists ) {
+ if ( $exists ) {
+ // already known to exist, don't waste any more CPU
+ return true;
+ }
+
+ if ( $title->getNamespace() !== NS_TOPIC ) {
+ // we only care about "fixing" Topic:xyz titles
+ return true;
+ }
+
+ try {
+ $uuid = strtolower( $title->getDBkey() );
+ $uuid = UUID::create( $uuid );
+
+ // a topic should have a workflow with the same UUID
+ $collection = PostCollection::newFromId( $uuid );
+ $workflowId = $collection->getWorkflowId();
+ $exists = $workflowId->equals( $uuid );
+ } catch ( \Exception $e ) {
+ return true;
+ }
+
+ return true;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/217274
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf87665019208653685a8063cd43cc013a70f3d2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits